Search code examples
mavenjunitcucumber

Run both Cucumber and JUnit tests fom Maven cli


I use JUnit5 and try run both JUnit and Cucumber tests from maven-3.6.3 cli with command

mvn clean verify

but in console I get output that only one kind of test or only JUnit tests or only Cucumber tests. After some investigation I found that it's relate to this dependency

<dependency>
   <groupId>io.cucumber</groupId>
   <artifactId>cucumber-testng</artifactId>
   <version>6.6.0</version>
</dependency>

With that dependency there are Cucumber tests runs and without JUnit tests. Can't find a way to run both kinds of tests.


Solution

  • Surefire can not execute both JUnit and TestNG tests. You could create two executions of Surefire. One for JUnit and one for TestNG. See SUREFIRE-377. Alternatively, since you are using JUnit 5, consider using the the cucumber-junit-platform-engine. It is Cucumbers integration with JUnit 5.