I am trying to upgrade from JUnit4 to JUnit5 and am experiencing a strange
issuewhereby:

- JUnit4 tests are fine
- JUnit5 tests work when run through intelliJ, but are ignored when run
through the maven command line

I attach a small project (zip file) that illustrates the issue. Also
attached is the output (footest.txt) of running this command:

mvn clean install > footest.txt


If you look in that file, you see a failure message for test__JUnit4Test
which proves that the test was run. But there are no failure message
for test__JUnit5Test which proves that this test was NOT run.

When I run the tests in intelliJ, I see failures for both tests which
proves that they were both run.

>From my reading, I see that several people have reported this issues but
none of the proposed fixes work for me. Any help would be appreciated.

BTW: Here is the info about my maven version

*Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)*

Maven home: /opt/apache-maven

Java version: 1.8.0_102, vendor: Oracle Corporation, runtime:
/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre

Default locale: en_CA, platform encoding: UTF-8

OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"


Thx.

Alain Désilets
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< ca.nrc.spikes:spike-junit >----------------------
[INFO] Building spike-junit 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ spike-junit ---
[INFO] Deleting /Users/desilets/Documents/GitRepositories/SpikeJunit4and5/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ 
spike-junit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ spike-junit ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ 
spike-junit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory 
/Users/desilets/Documents/GitRepositories/SpikeJunit4and5/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ 
spike-junit ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to 
/Users/desilets/Documents/GitRepositories/SpikeJunit4and5/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ spike-junit ---
[INFO] Surefire report directory: 
/Users/desilets/Documents/GitRepositories/SpikeJunit4and5/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running ca.nrc.spikes.JUnit4Test
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.161 sec <<< 
FAILURE!
test__JUnit4Test(ca.nrc.spikes.JUnit4Test)  Time elapsed: 0.009 sec  <<< 
FAILURE!
java.lang.AssertionError: NEVERMIND: This failure prooves that JUnit4 tests are 
run
        at org.junit.Assert.fail(Assert.java:88)
        at ca.nrc.spikes.JUnit4Test.test__JUnit4Test(JUnit4Test.java:10)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at 
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at 
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at 
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at 
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)


Results :

Failed tests:   test__JUnit4Test(ca.nrc.spikes.JUnit4Test): NEVERMIND: This 
failure prooves that JUnit4 tests are run

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.349 s
[INFO] Finished at: 2020-11-24T11:56:22-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on 
project spike-junit: There are test failures.
[ERROR] 
[ERROR] Please refer to 
/Users/desilets/Documents/GitRepositories/SpikeJunit4and5/target/surefire-reports
 for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

<<attachment: SpikeJunit4and5.zip>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to