【问题标题】:Running TestNg suite multiple times多次运行 TestNg 套件
【发布时间】:2016-07-18 08:39:45
【问题描述】:

我说 N 个测试类,我有一个测试套件,说 testing.xml,它可以运行所有这些 N 个测试,如何多次运行测试套件的 testing.xml?请帮助我如何以编程方式多次运行它

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite1">
<test name="exampletest1">
<classes>
       <class name="tester.NewTest1" />
    </classes>
  </test>

  <test name="exampletest2">
    <classes>
       <class name="tester.NewTest2" />
    </classes>
  </test>

</suite>    

【问题讨论】:

  • 我不知道如何在 xml 中执行但在 @Test 注释中您可以添加 invocationcount 属性来设置您的测试多次。希望这会阻止你!
  • 我知道invocationcount方法!!事情是我想运行所有测试“N”次.. XML 文件实际上是包含所有测试类要运行的测试套件
  • 请检查这个...testng.org/doc/…
  • 谢谢它的工作,我在循环中使用了 run 方法!
  • 这个问题的高级版本 - stackoverflow.com/questions/50614115/…

标签: java testng


【解决方案1】:

试试这个,你可以随意修改n次

for(int i=0;i<3;i++)
        {
            List<String> suites = new ArrayList<String>();
            suites.add("testng.xml"); //path of .xml file to be run-provide complete path

            TestNG tng = new TestNG();
            tng.setTestSuites(suites);

            tng.run(); //run test suite
        }

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-01-08
  • 1970-01-01
  • 2011-05-28
  • 2020-08-30
  • 2023-03-10
  • 2011-12-24
  • 2022-01-23
  • 1970-01-01
相关资源
最近更新 更多