how to call testng.xml from java main method?

前端 未结 5 1500
深忆病人
深忆病人 2020-12-10 15:40

I have testng.xml file created. Is there any way to run this file from java main method?

Something like -

Class test {
  public static void main ( St         


        
5条回答
  •  隐瞒了意图╮
    2020-12-10 16:20

    You can run testng directly from commandline, probably make a bat file on top of it or use jenkins to trigger it. Refer here

    or

    If you want it in main, then you can try

    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();
    List suites = Lists.newArrayList();
    suites.add("c:/tests/testng1.xml");//path to xml..
    suites.add("c:/tests/testng2.xml");
    testng.setTestSuites(suites);
    testng.run();
    

提交回复
热议问题