【发布时间】:2021-11-30 15:54:05
【问题描述】:
我一直在寻找某种方式让一些 @beforeMethod 逻辑仅针对一组 java 单元测试(使用 TestNG )执行。 我在 TestNG 文档中找到:
onlyForGroups:仅适用于@BeforeMethod 和@AfterMethod。如果指定, 那么这个 setup/teardown 方法只会被调用,如果 相应的测试方法属于列出的组之一。
这似乎是我要找的。p>
但是当我尝试使用它时,它并没有在@BeforeMethod 和@AfterMethod 注解中实现。我在网上找不到任何关于它丢失的信息。
Maven 依赖:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.2</version>
<scope>test</scope>
</dependency>
感谢您的帮助
【问题讨论】: