How to execute JUnit and TestNG tests in same project using maven-surefire-plugin?

前端 未结 12 2007
花落未央
花落未央 2020-12-13 06:04

Right now I have both type of tests but when I say \"mvn test\" it only executes TestNG tests and not Junit. I want to execute both one after another. Any Idea ?

12条回答
  •  遥遥无期
    2020-12-13 06:41

    There is an open issue for this, so there's no elegant way to do this.

    It would be far simpler for you to pick a framework and stick with it.

    Edit: My previous answer doesn't work because you can't specify dependencies in the execution. I've tried a few approaches, but the best I can manage is to create a profile for the TestNG dependency so you can toggle between TestNG and JUnit testing, there doesn't seem to be a means to run both TestNG and Junit 4 tests.

    One other point to note: You can launch your JUnit tests from TestNG, but I think this only works for JUnit 3 tests.

提交回复
热议问题