Tuesday, 7 May 2019

No tests found with test runner 'Junit 5'

When I execute a junit 5 test case, I get this error.









This is part of my pom.xml that is relevant.

<!-- Allows the legacy unit tests code under JUnit 4 still to run -->
<dependency>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
    <version>5.4.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.4.2</version>
    <scope>test</scope>
</dependency>
<dependency> 
    <groupId>org.junit.platform</groupId> 
    <artifactId>junit-platform-launcher</artifactId> 
    <version>1.5.0-M1</version> 
    <scope>test</scope>
</dependency>

I try various suggestions on https://stackoverflow.com/questions/46717693/eclipse-no-tests-found-using-junit-5-caused-by-noclassdeffounderror, and the solution that works for me is adding another dependency of junit-jupiter-engine.

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.4.2</version>
    <scope>test</scope>
</dependency>

It is this article that gives me the decisive hint.

No comments:

Post a Comment