maven 故障安全插件需要能够区分单元测试和集成测试。似乎在使用 JUnit 时,一种分离测试的方法是使用 JUnit @Categories 注释。这篇博文展示了如何使用 junit http://www.agile-engineering.net/2012/04/unit-and-integration-tests-with-maven.html 来做到这一点
@Category(IntegrationTest.class)
public class ExampleIntegrationTest{
@Test
public void longRunningServiceTest() throws Exception {
}
}
如何使用 TestNG 和 Maven 故障安全插件完成同样的事情。我想在测试类上使用注释将它们标记为集成测试。
最佳答案
这可以添加到测试中。
@IfProfileValue(name="test-profile", value="IntegrationTest")
public class PendingChangesITCase extends AbstractControllerIntegrationTest {
...
}
要选择要执行的测试,只需将值添加到用于执行集成测试的配置文件中即可。
<properties>
<test-profile>IntegrationTest</test-profile>
</properties>
如果选择的 maven 配置文件没有属性值,它将不会执行集成测试。
关于java - 如何使用注释在 testng + maven 中分离单元测试和集成测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19377181/