This can be achieved using options such as using different profiles for both and another is by setting JUnit property true for surefire plug in.
Run "mvn test". Only the TestNG test will run since as soon as the maven founds the TestNG dependency in main profile it executes TestNG tests only. If you modify the pom to set the property "junit=true", only the JUnit test will run.
But personally my experience is it wont works with JUnit4.
Since it is the TestNG dependency that triggers surefire to use the TestNG runner to execute tests, We've to move this dependency out of the main project scope. In order to compile and run all JUnit tests, and needs to exclude the TestNG tests from the compiler and surefire plugins.
Then in a profile, add TestNG dependency and adjust the compiler and surefire plugins to include the TestNG tests but don't forget and override exclude if you are inheriting from main profile.
0 comments: