0

I'm using JUnit 5.3.1 and running tests using maven. There is a parametrised test which is not running. I am using maven-surefire-plugin and this is from my pom.xml

<build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.19</version> <configuration> <includes> <include>**/*Tests.java,**/*Test.java</include> </includes> </configuration> </plugin> ... </build> 

When I run mvn test command, this is a part of the output:

Running com.growthintel.elastic_plugin.cid_suppressions.CheckCompanyTest Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec - in com.growthintel.elastic_plugin.cid_suppressions.CheckCompanyTest

There are no tests being detected from CheckCompanyTest file! Maven is detecting the file but not detecting any tests within the file. Is there a naming convention for parametrised tests that I am not following? Here is the test file:

public class CheckCompanyTest { private static Stream<Arguments> getListOfSuppressedFilePaths() { ... } @ParameterizedTest(name = "run #{index} with args: {arguments}") @MethodSource("getListOfSuppressedFilePaths") public void test_HasSuppressedCid(List<String> cidSuppressionFilePaths) { ... } 
3
  • Upgrade Surefire to 2.22.0 and use JUnit Jupiter 5.2.0 for now. Commented Sep 28, 2018 at 11:23
  • @Sormuras I tried a combination of JUnit 5.2.0 and maven-surefire-plugin v2.22.0 and it did not work. Thanks for the suggestion though!. Commented Sep 28, 2018 at 14:07
  • Remove the include cause it's default in maven-surefire-plugin... Commented Sep 29, 2018 at 13:47

2 Answers 2

3

You could use the junit-platform-surefire-engine, like @Niby suggested, or upgrade your maven-surefire-plugin to 2.22.0, and use the built-in support for JUnit Jupiter:

<plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.0</version> <!-- Here --> <configuration> <includes> <include>**/*Tests.java,**/*Test.java</include> </includes> </configuration> </plugin> 
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this, my test is still not being detected. I'm on JUnit 5.3.1. Also tried combination of JUnit 5.2.0 and maven-surefire-plugin v2.22.0 and that did not work either.
-1

JUnit 5 is not supported by the maven.surefire plugin version 2.19, so you have to add a custom provider and engine to the plugin, if you need to use that version.

Like this:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.3.1</version> </dependency> </dependencies> <configuration> <includes> <include>**/*Tests.java,**/*Test.java</include> </includes> </configuration> </plugin> 

Your exact version of JUnit 5 may of course be different, so pay attention to the version numbers.

3 Comments

Surefire 2.22.0 supports JUnit 5.2.0 natively. For JUnit 5.3.x you'll have to wait for Surefire 2.22.1.
The junit-platform-surefire-provider is discontinued. It won't ship with JUnit Platform 1.4.0 anymore.
Okay, thanks, I didn't know that. Unfortunately I don't have the possibility to use a newer version of Surefire, hence me suggesting this solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.