Maven ignoring JUnit5 tests when run from command line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Maven ignoring JUnit5 tests when run from command line

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

footest.txt (7K) Download Attachment
SpikeJunit4and5.zip (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Maven ignoring JUnit5 tests when run from command line

Karl Heinz Marbaise-3
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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

pom.xml (1K) Download Attachment