我已经编写了几个测试类来使用 testng 测试 Web 应用程序。每个测试类都是独立的。(我使用Java,maven和selenium webdriver)
我在 testng.xml 中定义了我的测试类和测试组,如下所示。
<test name="generalTest">
<groups>
<run>
<include name="login" />
<include name="signUp" />
<include name="profileCreation" />
</run>
</groups>
<classes>
<class name="my.test.Test_1_LoginTestCases"/>
<class name="my.test.Test_2_SignUpTestCases"/>
<class name="my.test.Test_3_CreatePeopleProfileTestCases"/>
</classes>
</test>
我在命令行中运行此命令来运行测试类。
mvn test -DsuiteXmlFile=/src/testng.xml -Dgroups=login,signUp,profileCreation
我使用 testng“优先级”标签来定义在测试类中运行测试用例的顺序。
但问题是当我使用上面的命令运行 testng.xml 时,它会同时运行所有测试类(并行)。如果有 10 个测试类,那么它会同时打开 10 个 Web 浏览器实例并尝试运行每个测试类同一时间。
我需要的是运行第一个测试类,完成后然后使用上面的 maven 命令开始运行第二个测试类。
有人可以帮我做这件事吗?我非常感谢您的帮助。
最佳答案
只需在 xml 中添加一个属性parallel="false",如下所示:
<test name="generalTest" parallel="false">
关于java - 使用 webdriver 的 testng 逐一运行测试类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13466767/