0
votes

I have a TestNG project where I use testng.xml file to execute. How to take a jar of my project and execute it on another machine. I know how to execute it on the same machine by giving path of bin & lib folders i.e

cd C:\Workspace\projectname java -cp C:\Workspace\projectname\lib*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml.

But if i want to do on another machine how to do this?

1
Exactly the same way. Preferably you use build script to package your code and libraries and resource files into one JAR and then directly execute that on the target machine. Google Maven or Gradle for more information. - xaviert
I have created a zip file of my project, so how do I execute it using xml file - Grishma Oswal
You can't execute the ZIP file using your XML file. Either use the command line (like you already did) or use a bash/shell script to invoke the java ... command using the ZIP file and XML file. - xaviert

1 Answers

1
votes

You can create a bash file which points to your testng.xml file.

Use this: Bash file is running fine in windows for testng but it is not working in linux/mac

Steps:-

 1. Create a notepad file
 2. Copy -> java -cp ./src/lib/*:./bin org.testng.TestNG testng.xml(use ; instead of : if you are using windows) (./src/lib/* -> All your jars files must present in this location, ./bin -> all your class files must be present here)
 3. save the file.
 4. Rename the file as something.bat
 5. Double click on file if you are using windows or use **bash filename** if using linux or mac

Note: - Java, require browsers must be present in other computer and it's a prerequisite which is nothing to do with your automation script run. they must be pre-installed