While running selenium automation using a bat file, it is showing this error
No test suite found. Nothing to run
But TestNG is running properly from Eclipse.
While running selenium automation using a bat file, it is showing this error
No test suite found. Nothing to run
But TestNG is running properly from Eclipse.
The command used to invoke TestNG is incorrect. Also you can specify classpath with option -cp. So the renewed sample command for you would be
java -cp <classpath> org.testng.TestNG <location of testng.xml>
A batch file is nothing but collections of commands. Try to run it from CMD first and then make a batch file. For running TestNG from Command-Line, you might wanna follow these steps.
After adding TestNG to your project library create one folder in your Project names as lib ( name can be anything ) :
Go to "C:\Program Files\Eclipse\your_eclipse_name\eclipse\plugins" location and copy com.beust.jcommander_1.72.0.jar and org.testng_6.14.2.r20180216145.jar file to created folder (lib).
Note : Files are testng.jar and jcommander.jar
Now Launch CMD, and navigate to your project directory and then type :
Java -cp C:\Users\User123\TestNG\lib*;C:\Users\User123\TestNG\bin org.testng.TestNG testng.xml
I was using maven for this. I simply changed to java project only and got bin folder created as well. And then convert it to maven project. Now everything is fine. Thanks to all.
I saw someone mentioning a cannot find classpath problem, had the same issue. I think TestNG changes the classpath variable and moves all class files to /target/classes directory. But if we try to point this path in cmd, it doesnt work. For bat file to run all class files HAVE to be in bin folder. Do the following
Goto Eclipse -> right click on Project ->Properties -> Source tab
Here, change the output folder to bin. Now run the testng xml from eclipse to make sure everything still works.
Then goto bin folder, your class files should now be here. Then run your testng command, should start working.