简体   繁体   中英

Exception error when I try to run testng file from the command line

I've created a simple testng project that prints out "Hello world". I can run the test from testng.xml successfully. I've tried to run the same test from command line but it fails. I've tried following all the tips given on this post. How to run TestNG from command line and multiple other posts but I'm still getting the same error. All my jar files are under lib and .class is under bin library. I've done everything most of the online help have suggested, for example create a script, testng.xml is there, make sure your jar files are under lib, and give a path to your bin folder. so what am I missing? Listed below is the command, image of my lib folder, image of the testng.xml and image of the error. Please help, I've been reading different posts since Friday.

java -cp C:\\Eclipse\\WorkSpace\\TestingPractice\\lib*;C:\\Eclipse\\WorkSpace\\TestingPractice\\bin org.testng.TestNG C:\\Eclipse\\WorkSpace\\TestingPractice\\testng.xml

在此处输入图片说明

My testng.xml file

在此处输入图片说明

在此处输入图片说明

I was finally able to fix this by downloading the guice-4.2.2.jar and adding it to lib folder. Once I did that, it worked.

C:\\Eclipse\\WorkSpace\\TestingPractice>set classpath=C:\\Eclipse\\WorkSpace\\TestingPractice\\bin;C:\\Eclipse\\WorkSpace\\TestingPractice\\lib* C:\\Eclipse\\WorkSpace\\TestingPractice>java org.testng.TestNG C:\\Eclipse\\WorkSpace\\TestingPractice\\testng.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM