简体   繁体   中英

How to run Maven unit test (testng) on Eclipse?

I have a Maven project and I have included some unit tests. I can run those unit tests from command line using

mvn test -Dtest=AppTest

It will run the unit test (AppTest class) without any problems. But if I tried to run the test on Eclipse as JUnitTest, I got an error saying

"No Tests found with test runner 'JUnit 3'"

I know the test (AppTest) is not a JUnit test but I didn't see "maven" option if I right clicked on the test class.

Do you know how I could run the tests on Eclipse?

If those are testng tests, then you can download the eclipse plugin for TestNG and right click and run them as test class. Testng plugin here

If you want to run the command line way of maven, you would need the maven plugin for eclipse from here Then you can right click your project and you should see an option of Run As -> Maven Test. You would need to set relevant arguments in the surefire plugin of pom or use run configuration to specify parameters like you did in -Dtest

I would suggest the testng plugin which would be simpler to just select the class and run the class or a single case or a package even.

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