Advantages of this method:
- You can execute your tests outside eclipse, any machine provided JRE is installed on the machine. You don't need to place the libraries too, The JAR will have all these.
- Without a Selenium grid, this enables you to run the tests on any previous versions of browsers running on another machine.
- This can be executed by anyone without any knowledge of Eclipse, scripting etc.
How to do this:
Assuming you are running your test cases by executing testNG.xml as TestNG.
Steps:
Create a Java class with main method with below code.
public class MainTest {
public static void main(String[] args){
List<String> file = new ArrayList<String>();
file.add("D:/Selenium_workspace/Framework/src/Framework.xml");
TestNG testNG = new TestNG();
testNG.setTestSuites(file);
testNG.run();}
}
Now Export your whole project to runnable JAR. Double click the JAR, will execute the xml as testNG. You may create a user interface to select XML so that it adds flexibility to select which test you need to run.
When i tried above code, displays "The System cannot find the filepath specified". Kindly advise on this.
ReplyDeleteDid you place the testng xml file in the given path?
Delete