多次运行 TestNg 套件 [英] Running TestNg suite multiple times

查看:40
本文介绍了多次运行 TestNg 套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have say N number of test classes and I have one test suite say testing.xml which can run all those N tests , how to run testing.xml that is test suite multiple times ? Please help me out how to programatically run it multiple times

<?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>    

推荐答案

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

Here try this, you can modify this for whatever n times you want

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
        }

这篇关于多次运行 TestNg 套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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