如果我有多个测试 类 并且其中有多个优先测试,我如何 运行 使用 maven 进行测试?
How do I run tests using maven if I have multiple test classes with multiple tests in them which are prioritized?
我有 6 个测试 classes,每个我有大约 5 个测试,它们是优先的。
当我 运行 使用 Maven 的测试服时,测试 classes 以某种方式组合在一起。
虽然测试未从测试 class 完成,但另一个测试开始,但未通过我的测试。
有没有办法,首先 运行 1 测试 class 及其所有测试,然后 运行 第二个 class 在第一个测试完成后等等?
注意:我 运行 在终端中使用 mvn 命令进行测试。
每个class应该有自己的set-up和tear-down机制,这样不同测试class的测试是完全独立的。如果多个测试使用昂贵的公共资源,请将这些测试放在一起 class 并在设置方法中创建资源。
如果您绝对需要按给定顺序调用某些方法,您已经编写了一个调用这些方法(按指定顺序)的测试方法。但是你应该尽量避免这种情况。
I have around 5 tests, which are prioritized
可能您正在使用 TestNG,每个测试方法都有这样的东西:
@Test( priority = 1 )
如果是这种情况,您应该将其添加为标签,因为它非常相关。
the test classes are combined somehow
可能你 运行 他们平行。
Is there a way, to run 1 test class with all of its tests first, and to run the second class after the first one is finished and so on
是的。 运行 类 依次!
找到定义测试套件的 XML 文件,如 testng.xml。它应该包含如下内容:
<suite name="YourSuite" parallel="classes" thread-count="6">
删除 parallel="classes" thread-count="6"
以实现您上面描述的内容。
有关其他详细信息,请参阅 TestNG - parallel tests。
我有 6 个测试 classes,每个我有大约 5 个测试,它们是优先的。 当我 运行 使用 Maven 的测试服时,测试 classes 以某种方式组合在一起。 虽然测试未从测试 class 完成,但另一个测试开始,但未通过我的测试。 有没有办法,首先 运行 1 测试 class 及其所有测试,然后 运行 第二个 class 在第一个测试完成后等等? 注意:我 运行 在终端中使用 mvn 命令进行测试。
每个class应该有自己的set-up和tear-down机制,这样不同测试class的测试是完全独立的。如果多个测试使用昂贵的公共资源,请将这些测试放在一起 class 并在设置方法中创建资源。
如果您绝对需要按给定顺序调用某些方法,您已经编写了一个调用这些方法(按指定顺序)的测试方法。但是你应该尽量避免这种情况。
I have around 5 tests, which are prioritized
可能您正在使用 TestNG,每个测试方法都有这样的东西:
@Test( priority = 1 )
如果是这种情况,您应该将其添加为标签,因为它非常相关。
the test classes are combined somehow
可能你 运行 他们平行。
Is there a way, to run 1 test class with all of its tests first, and to run the second class after the first one is finished and so on
是的。 运行 类 依次!
找到定义测试套件的 XML 文件,如 testng.xml。它应该包含如下内容:
<suite name="YourSuite" parallel="classes" thread-count="6">
删除 parallel="classes" thread-count="6"
以实现您上面描述的内容。
有关其他详细信息,请参阅 TestNG - parallel tests。