Create Jar File to run the TestNG testcase
Answered
I'm new to QA automation thing and just start to create UI automation with Maven Project, testng and selenium.
I'm using InteliJ IDE all the time and it works fine. I can create testng.xml and can point to the Test Suit and I can run the test case.
But, thought to create a jar file which anyone can run the test without IDE. So, have to create an artifact and try to create jar using install command in maven lifecycle. it creates a jar file, but when I try to run it, it just prints hello world, not run the test case.
How can Irun test case with this JAR file




Please sign in to leave a comment.
This can be solved with Maven, see https://niharikawhatsnext.wordpress.com/2015/03/11/running-maven-testng-tests-as-a-jar/.
Thanks for quick response. I have tried this and many more, but still no luck
E:\Eutech\ServiceDeskv3\Apps\5_QA\HG_QA\Library\Cloud\target>java -cp ivivacloud-1.0.jar;ivivacloud-1.0-jar-with-dependencies.jar;ivivacloud-1.0-tests.jar org.testng.TestNG -testjar ivivacloud-1.0-tests.jar -xmlpathinjar "E:\Eutech\ServiceD
eskv3\Apps\5_QA\HG_QA\Library\Cloud\suite\testng.xml"
Error: Could not find or load main class org.testng.TestNG
You may need to create a fat jar that will include the TestNG and other dependencies in it: https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/ .