Re: Maven ignoring JUnit5 tests when run from command line

2020-11-24 Thread Karl Heinz Marbaise

Hi,

the configuration in your pom file is wrong...

Several parts.. not using the most recent version of JUnit Jupiter
(current 5.7.0) furthermore not the right version of
maven-surefire-pugin as described in the JUnit Jupiter documentation ...

Also mixing assertions in JUnit 4 test vs .JUnit 5 Test...


In your JUnit 5 Tests only imports from:

org.junit.jupiter.api.* should be there...

Assertions.fail(mess);
instead of: Assert.fail(mess);

I have attached the cleaned up pom file which you can take a look ...

Also you should check the names of your test methods ... ... the prefix
"test__" is not needed anymore since JUnit 4 ...

Kind regards
Karl Heinz Marbaise


On 24.11.20 18:15, Alain Désilets wrote:

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


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




Mit freundlichem Gruß
Karl-Heinz Marbaise
--
SoftwareEntwicklung Beratung SchulungTel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl-Heinz MarbaiseUSt.IdNr: DE191347579
Hauptstrasse 177
52146 Würselen   https://www.soebes.de

http://maven.apache.org/POM/4.0.0;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;>
  4.0.0

  ca.nrc.spikes
  spike-junit
  1.0.0-SNAPSHOT

  
1.8
1.8

UTF-8
UTF-8

4.12
  

  

  
org.junit
junit-bom
5.7.0
pom
import
  

  
  

  org.junit.jupiter
  junit-jupiter
  test



  junit
  junit
  ${junit.version}
  test


  

  

  

  maven-surefire-plugin
  3.0.0-M5

  

  


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

Maven ignoring JUnit5 tests when run from command line

2020-11-24 Thread Alain Désilets
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