junitmigrationjunit4junit5

JUnit 5 - Migration - Custom test annotation no longer detected?


I had the following custom test annotation that worked in JUnit4 that IntelliJ and JUnit no longer wants to recognize:

@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RUNTIME)
public @interface MyTest{}

If I add @Test to the annotation then IntelliJ recognizes it again

enter image description here

but JUnit still don't and returns "No tests were found" when trying to run it.

The only change I've made to the pom is exchanged the dependency spring-test (version 4.3.25.RELEASE) for spring-boot-starter-test (version 2.7.18). I can't find anything in the documentation that indicates that this shouldn't work so I'm at a lost why it's broken


Solution

  • Apparently there was something strange with my generated target files. After deleting them manually and running build pipeline again afterwards it now recognizes the tests again.