到处搜索但找不到解决方案如何执行以下操作: 例如:
for (int i = 0; i < 5; i++) {
@Test
public void test1(){
assertThat(assertvalue 1);
}
@Test
public void test2(){
assertThat(assertvalue 2);
}
@Test
public void test3(){
assertThat(assertvalue 3);
}
}
当然,我可以使用 dataProvider 或 invokingCount 并在一个测试用例中执行所有断言,但如果一个断言失败,则整个测试用例都会失败。我想要一种单独的 3 个小测试用例的大测试用例 任何帮助表示赞赏
最佳答案
不鼓励测试用例之间存在依赖关系。您可以使用 SoftAssert
获得类似的结果 - 检查每个值 1-5,而不会短路并在 2 失败后停止。
SoftAssert soft = new SoftAssert();
soft.fail("Failure # 1\n");
soft.fail("Failure # 2");
soft.assertAll();
应该输出:
The following assertions failed:
Failure # 1
Failure # 2
关于java - TestNG 在循环中运行一组测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38775020/