how to call testng.xml from java main method?

前端 未结 5 1497
深忆病人
深忆病人 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:19

    This work for me. More details here.

    // Create object of TestNG Class
    TestNG runner=new TestNG();
    
    // Create a list of String 
    List suitefiles=new ArrayList();
    
    // Add xml file which you have to execute
    suitefiles.add("C:\\Automation Test\\Git\\vne_automation\\testng.xml");
    
    // now set xml file for execution
    runner.setTestSuites(suitefiles);
    
    // finally execute the runner using run method
    runner.run();
    

    Hope this helps!

提交回复
热议问题