how to call testng.xml from java main method?

前端 未结 5 1506
深忆病人
深忆病人 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条回答
  •  旧时难觅i
    2020-12-10 16:32

    Please try below code and make sure you have testNG jar added in your jar manifest file.

    public static void main(String[] args)
    {
        org.testng.TestNG.main(args);
    }
    

    now you can pass all the parameters to your jar which are same for testNG jar file.

    e.g.

    java -jar yourjar.jar testng.xml

    or

    java -jar yourjar.jar -testclass org.test.xyz.java

提交回复
热议问题