Reputation: 808
I have migrated my junit 4 code to junit 5 with the below version dependencies.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.22.0</version>
<scope>test</scope>
</dependency>
One of my scripts uses the command
mvn -B verify -DforkCount=1 -DreuseForks=false
But the issue I am facing is after migrating to junit5 while running it skips the testcase.
I am using maven-surefire-plugin - version 2.22.0.
While running it just print the below line
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
I even tried the below configurations but no help
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<properties>
<configurationParameters>
junit.jupiter.conditions.deactivate = *
junit.jupiter.extensions.autodetection.enabled = true
junit.jupiter.testinstance.lifecycle.default = per_class
junit.jupiter.execution.parallel.enabled = true
</configurationParameters>
</properties>
</configuration>
</plugin>
</plugins>
My maven version is 3.3.9
and does not run the test case. Any specific reason why I am facing this strange issue. The same test case with JUnit 4 earlier worked fine.
After further analysis what I found the command => mvn -B verify -DforkCount=1 -DreuseForks=false
does not run the test case and skips them. But when i replace the same command with => mvn -B verify -DforkCount=1 -DreuseForks=true
, it starts working. I understand that properties forkCount=1/reuseForks=true, which means that maven-surefire-plugin creates one new JVM process to execute all tests in one Maven module but want to know why it does not work with mvn -B verify -DforkCount=1 -DreuseForks=false
command. Is any maven or maven helper version upgrade is required for Junit5 migration?
Upvotes: 1
Views: 1886