0
votes

Is junit-vintage engine meant to be compatible with versions of junit older than 4.12.x?

In my case there seems to be an issue during test discovery when using junit 4.7 and running within intellij idea.

I am currently running version of idea 2017.3.3, junit-jupiter '5.0.3', junit-vintage-engine '4.12.3' and junit 4.7

When running all tests in a module i see the following exception.

Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/experimental/categories/Category at org.junit.vintage.engine.descriptor.VintageTestDescriptor.addCategoriesAsTags(VintageTestDescriptor.java:86) at org.junit.vintage.engine.descriptor.VintageTestDescriptor.getTags(VintageTestDescriptor.java:77) at org.junit.platform.launcher.TestIdentifier.from(TestIdentifier.java:60) at org.junit.platform.launcher.TestPlan.lambda$from$0(TestPlan.java:80) at org.junit.platform.engine.TestDescriptor.accept(TestDescriptor.java:239) at org.junit.platform.engine.TestDescriptor.lambda$accept$0(TestDescriptor.java:241) at java.lang.Iterable.forEach(Iterable.java:75) at org.junit.platform.engine.TestDescriptor.accept(TestDescriptor.java:241) at org.junit.platform.launcher.TestPlan.lambda$from$1(TestPlan.java:81) at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608) at org.junit.platform.launcher.TestPlan.from(TestPlan.java:81) at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:82) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:48) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: java.lang.ClassNotFoundException: org.junit.experimental.categories.Category at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 16 more

I narrowed down the source of the exception to a few lines in VintageTestDescriptor.java (staring at line 86)

    private void addCategoriesAsTags(Set<TestTag> tags) {
    Category annotation = (Category)this.description.getAnnotation(Category.class);

Category is in the experimental package of junit 4.12 and seems to be missing from junit 4.7. I was not able to find doc on which versions of junit the vintage engine is compatible with.

1

1 Answers

3
votes

The junit-vintage-engine is compatible with JUnit 4.12.

Is there any reason not to update to 4.12?