作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
TestNG
测试用例类中的测试方法如下:
@Test (priority=0)
public void test01() {
}
@Test (priority=1, dependsOnMethods="test01")
public void test02() {
}
@Test (priority=2)
public void test03() {
}
@Test (priority=3)
public void test04() {
}
执行顺序是test01 - test03 - test04 - test02
。嗯,这似乎是不正确的,因为在到达 test02
时,相关测试方法 test01
已经执行。因此 test02
应该立即执行。我觉得正确的顺序是 test01 - test02 - test03 - test04
这是 TestNG
中的一个 bug 还是出于我遗漏的某些特定原因故意设计的?
最佳答案
不要同时提供优先级和依赖,可以分组测试。你可以这样做:
@Test(priority = 1, groups = { "qty" })
public void increaseQty() {
System.out.println("in increase qty");
}
@Test(dependsOnMethods = { "increaseQty" }, groups = { "qty" })
public void decreaseQty() {
System.out.println("in decrease qty");
}
@Test(dependsOnGroups = { "qty" })
public void removeFromCart() throws Exception {
System.out.println("remove qty");
}
@Test(dependsOnMethods = { "removeFromCart" })
public void emptyCart() throws InterruptedException {
System.out.println("empty Cart");
}
关于java - 具有优先级的测试用例执行的 TestNG 顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39330510/
我最近购买了《C 编程语言》并尝试了 Ex 1-8这是代码 #include #include #include /* * */ int main() { int nl,nt,nb;
早上好!我有一个变量“var”,可能为 0。我检查该变量是否为空,如果不是,我将该变量保存在 php session 中,然后调用另一个页面。在这个新页面中,我检查我创建的 session 是否为空,
我正在努力完成 Learn Python the Hard Way ex.25,但我无法理解某些事情。这是脚本: def break_words(stuff): """this functio
我是一名优秀的程序员,十分优秀!