TestNG:如何多次运行相同的测试用例? [英] TestNG: How can I run same test case multiple times?

查看:85
本文介绍了TestNG:如何多次运行相同的测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想多次运行一个测试用例.是否可以在 testng.xml 中配置?如果我在测试方法中添加一个循环,那么每次运行的结果都不会在testng报告中受到影响.

I want to run a test case multiple times. Is that configurable in the testng.xml? If I add a loop in the test method, then the results of each run will not be affected in the testng report.

推荐答案

您不能从 xml 中执行此操作,但在 @Test 注释中 - 您可以添加一个 invocationCount 属性以及您想要运行它的次数.它会随着报告中运行的许多测试而出现.

You cannot do it from the xml, but in the @Test annotation - you can add a invocationCount attribute with the number of times you want to run it. It would come out as those many tests run in the report.

例如

@Test(invocationCount = 10)
public void testCount() {..}

您错过了最后的结束大括号,因此请稍作修正.

You have missed closing curly bracket at the end, so a small correction.

这篇关于TestNG:如何多次运行相同的测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆