Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory
You ran into Eclipse bug 525948 which has already been fixed and which will be published in the upcoming release Oxygen.3 (4.7.3), March 21, 2018.
As workaround, put your test code in a separate project and add the project under test to the modulepath, but do not add a module-info.java
to your test project. With your project, class and module naming, it should look something like this:
See also my video that shows Java 9 and JUnit 5 in Eclipse Oxygen.1a in action
Cant run the test class No tests found with test runner 'Junit5'
You only depend on the api, giving you e.g. the annotations, but you are missing the engine to execute your tests. Either add junit-jupiter-engine
as dependency or switch to the convenience dependency junit-jupiter
.
Look at the maven starter sample (https://github.com/junit-team/junit5-samples/tree/r5.7.1/junit5-jupiter-starter-maven), on how to get a minimal functional pom.xml for junit5.
Junit 5 tests don't launch in Eclipse due to NoClassDefFoundError: TestEngine
The problem was that I was missing the dependency to the engine library:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
Then, the tests run like a charm in Eclipse.
Migration blogs like https://dev.to/martinbelev/how-to-enable-junit-5-in-new-spring-boot-project-29a8 do mention this dependency, but I primarily worked with the JUnit 5 documentation, and somehow I must have overlooked this important piece of information there...
Import org.junit.Test throws error as No Test found with Test Runner JUnit 5
This org.junit.Test
is a JUnit 4 annotation. A Junit5 test runner will not discover a test annotated with org.junit.Test
.
A Junit5 test runner will discover a test annotated with org.junit.jupiter.api.Test
.
So, this explains why you get "No Test found with Test Runner JUnit 5" when attempting to run a test context which does not contain any tests annotated with org.junit.jupiter.api.Test
.
It sounds like you might be migrating from Junit4 to Junit5. If so, there are several changes you'll need to come to terms with. The Junit5 docs offer some useful tips including:
Annotations reside in the
org.junit.jupiter.api
package.Assertions reside in
org.junit.jupiter.api.Assertions
.Assumptions reside in
org.junit.jupiter.api.Assumptions
.
@Before
and@After
no longer exist; use@BeforeEach
and@AfterEach
instead.
@BeforeClass
and@AfterClass
no longer exist; use@BeforeAll
and
@AfterAll
instead.
@Ignore
no longer exists: use@Disabled
or one of the other built-in
execution conditions instead
@Category
no longer exists; use@Tag
instead.
@RunWith
no longer exists; superseded by@ExtendWith
.
@Rule
and@ClassRule
no longer exist; superseded by@ExtendWith
and
@RegisterExtension
Related Topics
Deserialization With @Jsonsubtypes for No Value - Missing Property Error
Regular Expression to Match a Backslash Followed by a Quote
Enable Jackson Deserialization of Empty Objects to Null
How to Do Name Validation Allowing Alphabet, Spaces and Dot in Android
How to Scroll to the Bottom of a Recyclerview? Scrolltoposition Doesn't Work
Automatically Convert Style Sheets to Inline Style
Delete Not Working in Hibernate/Spring Data
Use Only One Bufferedreader Object to Read Multiple Files in Java
Splitting a String Containing Special Characters in to Individual Characters
Spring Data JPA Saveall Not Doing Batch Insert
I Want to Get Time Difference Between Two Time in Milisecond
How to Access Variable Outside a Try Catch Block
How to Return a List of Specific Type Instead of List<Object[]> in Hibernate
How to Map an Auto Increment Field in Hibernate
Spring Data JPA Problem With Updating Multiple Entities
How to Do Post Request With Raw Data Via Spring Rest Template