【发布时间】:2015-06-03 09:31:49
【问题描述】:
我在 1 个测试类中有大约 50 个测试用例,其中一些是依赖测试用例。我努力使用 testng 注释使它们以我想要的方式运行。我希望测试的输出是:run1、run 2、run 3、run 4、run 5、run 6、run 7、run8。我知道我的注释是错误的,因为它没有按那个顺序运行。 priority1 和 priority2 在其依赖测试之前运行。
任何帮助将不胜感激。
我的测试类如下所示:
public class Help {
@BeforeTest
public void aa() {
System.out.println("run 1");
}
@Test(priority = 1)
public void bb() {
System.out.println("run 2");
}
@Test(dependsOnMethods = { "bb" })
public void cc() {
System.out.println("run 3");
}
@Test(dependsOnMethods = { "cc" })
public void dd() {
System.out.println("run 4");
}
@Test(priority = 2)
public void ee() {
System.out.println("run 5");
}
@Test(dependsOnMethods = { "ee" })
public void ff() {
System.out.println("run 6");
}
@Test(dependsOnMethods = { "ff" })
public void gg() {
System.out.println("run 7");
}
@AfterTest
public void hh() {
System.out.println("run eight");
}
}
【问题讨论】:
-
确保您的代码格式正确,以便于理解
-
出于好奇:为什么您认为您的测试之间需要有如此复杂的依赖关系?
-
请问代码格式有什么问题?
-
@Jägermeister,是因为我公司的业务逻辑。
-
好吧,也许你以前做过;但仍然:你有没有想过你的业务逻辑是否必须是这样的?你知道,当事情需要按特定顺序完成时......所有处理这种“API”的“客户”都必须知道这个顺序......这通常表明设计改进。
标签: java selenium-webdriver maven-2 testng