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 ( String [ ] args)
{
Run(testng.xml);
}
}
This work for me. More details here.
// Create object of TestNG Class
TestNG runner=new TestNG();
// Create a list of String
List<String> suitefiles=new ArrayList<String>();
// 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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With