Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

maven

testng

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?

like image 455
codereviewanskquestions Avatar asked Mar 22 '13 23:03

codereviewanskquestions


1 Answers

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.

like image 140
niharika_neo Avatar answered Oct 06 '22 02:10

niharika_neo