我有这个示例代码:
//example :
template `
<div>{{'\'}}{{content}}</div>
`
where content is an @Input string
输出是:
public class A {
@BeforeTest(groups = "group1")
public void beforeTest() {
System.out.println("Before test");
}
@BeforeMethod(groups = "group1")
public void beforeMethod() {
System.out.println("Before method");
}
@Test(groups = { "group1" })
public void test1() {
System.out.println("Test1");
}
@Test(groups = {"group2"})
public void test2() {
System.out.println("Test2");
}
@AfterMethod(groups = { "group2" }, alwaysRun = false)
public void afterMethod() {
System.out.println("After method");
}
@AfterTest(groups = "grupa1")
public void afterTest() {
System.out.println("AfterTest");
}
}
但我想收到这样的话:
Before test
Before method
Test1
After method
Before method
Test2
After method
AfterTest
有没有选项只能在第二种测试方法之后调用afterMethod方法?我不能使用afterGroup注释。
答案 0 :(得分:0)
将@AfterMethod
替换为@AfterClass
,您将获得预期的输出。
答案 1 :(得分:0)
尝试dependsOnGroups
例如,如果您只想在第2组测试后运行方法,请使用以下命令:
@AfterMethod(dependsOnGroups = {"group2"})
对于@Before
配置也应如此