如何从詹金斯运行单个测试用例

时间:2020-05-27 06:42:28

标签: selenium jenkins

我在testng套件中有10个测试用例,我需要从jenkinks执行单个或单个测试用例,请问有人可以帮助我如何从jenkins执行单个测试用例吗,我尝试了maven surfire命令mvn -Dtest = TestCircle test将测试命令包含到golas中并已执行但无法正常工作,请参考数据并更正我如何在詹金斯中设定目标以执行单个测试用例。 “ mvn clean compile install -DPICK_CONFIGURATION_FROM =” JENKINS“ -DEXECUTION_MODE =” Remote“- Dtest = TestCircle#EAConsoleLandingPageTest测试 -DPLATFORM =” WEB“ -DOPERATING_SYSTEM =” WINDOWS“ -DBROWSER =” chrome“- DCOMPUTERNAME =“ Test” -DTEST_ENVIRONMENT =“ RUNFC” -DPLAN_ID =“” -DTEST_TYPE =“烟雾” -DGRID_URL =“ http:// localhost:4444 / wd / hub”“

下面是示例测试套件: 类>

        <class
            name="com.ea.automation.tests.EAConsoleLandingPageTest">
            <methods>
                <include name="clickOnGetStartedBtn" />
                <include name="selectProjectFromLandingPage" />
                <include name="clickOnEAConsoleIcon" />
                <include name="verifyRequestProjectAccess" />
                <include name="verifyProjectAccess" />
                <include name="verifyHomePageRedierecting" />
            </methods>
        </class>
        <class
            name="com.ea.automation.tests.EAConsoleSelfServiceTest">
            <methods>
                <include name="clickOnCreateNewproject" />
                <include name="verifyProjectUserAcess" />
                <include name="switchProjects" />
                <include name="clickOnProjectSettings" />
            </methods>
        </class>
        <class
            name="com.ea.automation.tests.EAConsoleNotificationAppTest">
            <methods>
                <include name="selectProject" />
                <include name="clickOnNotification" />
                <include name="checkAllWdgetNotifications" />
            </methods>
        </class>
        <class
            name="com.ea.automation.tests.EAConsoleSupportAppTest">
            <methods>
                <include name="clickOnSupportApp" />
                <include name="checkCreateTicket" />
                <include name="clickOnCloseErrorMessageModel" />
                <include name="clickOnSupportFromApp" />
                <include name="clickOnSupportEmail" />
            </methods>
        </class>
        <class
            name="com.ea.automation.tests.EAConsoleSDKDownloadsAppTest">
            <methods>
                <include name="selectProject" />
                <include name="clickOnSDKDownloads" />
            </methods>
        </class>

1 个答案:

答案 0 :(得分:0)

我建议的方法不是可取的。因为运行Jenkins的唯一目的是运行一组测试用例,而不是单个测试用例。但是您可以通过以下方式实现您的想法。

  1. 向Jenkins作业添加三个字符串参数。一个参数指向testng xml文件名,第二个参数指向类名,第三个参数指向测试名。
  2. 在项目存储库中创建另一个testng.xml文件。将此文件重命名为small.xml
  3. 因此第一个Build参数应为small.xml
  4. Jenkins能够在maven构建开始之前执行shell脚本。
  5. 因此,我们将在外壳程序脚本中获取用作Jenkins Build参数的参数,以修改small.xml文件并修改pom.xml文件以指向small.xml。
  6. Shell脚本中的
  7. sed 命令将有助于替换pom.xml和small.xml文件中的现有文本。您可以在互联网上搜索。

我已经在一个用于根据Jenkins构建参数选择不同套件文件的项目中实现了这种方法。这种方法有效。因此,在运行时,根据您通过的Jenkins Build参数,相应的测试将由Jenkins运行。