I have a normal project in Eclipse using Selenium and TestNG (Not Maven or Gradle). I want to start testing running the tests via Jenkins and I realized that I can do it with an XML file that TestNG provides.
So I did it, I exported it and when running it via Eclipse, everything works. Search online on how to run it via CMD\PowerShell and saw that the command suppose to be: java -cp "location on the bin of the project and the location of the selenium and TestNG jars" org.testng.TestNG testng.xml
I have a bin folder of course that Eclipse builds and I created a folder named lib to put the jar files there. So this is my command: java -cp "C:\Git\WebTesting\Bin;C:\Git\WebTesting\lib*" org.testng.TestNG testng.xml
Right away it gave me that error:
Then I realized that I didn't put the TestNG jar there, so I put it there. Again, the same error.
Then searched online and realized that I also need to put the shellbean and Jcommander jars, so what I did is that: java -cp "C:\git\webtesting\bin;C:\Users\User1.p2\pool\plugins\org.testng_7.3.0.r202008060316.jar;C:\Users\User1.p2\pool\plugins\com.beust.jcommander_1.78.0.jar;C:\Users\User1.p2\pool\plugins\org.apache-extras.beanshell.bsh_2.0.0.b6.jar;C:\Users\User1.p2\pool\plugins\org.yaml.snakeyaml_1.21.0.jar;" org.testng.testng testng.xml
and it still gives me the same error of not finding the Testng class!
I am already frustrated, don't know what to do.
Any help? ideas?
Thanks
I fixed the issue!
All I have to do is to put the location on the Project in $env:ProjectPath or %ProjectPath depends if you are using PowerShell or CMD. And then put the the link folder with * and also the bin folder of the project in $env:Classpath/%ClassPath%. And finally typing $env:ProjectPath\testng.xml in the end of the command. So:
$env:ProjectPath = the path of the project (not the bin folder)
$env:ClassPath = the lib folder/*;the bin folder of the project
Java org.testng.testng $env:ProjectPath\testng.xml