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

17,454

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.

Share:
17,454
codereviewanskquestions
Author by

codereviewanskquestions

Updated on June 26, 2022

Comments

  • codereviewanskquestions
    codereviewanskquestions almost 2 years

    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?