I tried to implement Junit5 in my Vertx Project.
Just adding junit5 works fine but with adding vertx-junit5 module to the project the TestEngine got problems finding the Tests
build.gradle:
buildscript {
repositories {
mavenCentral()
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.1.0'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
}
}
}
plugins {
id'java'
id'application'
id'eclipse'
}
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'maven'
apply plugin: "org.sonarqube"
def vertxVersion = "3.5.1"
version = 0.4
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
dependencies {
compile "io.vertx:vertx-core:$vertxVersion"
compile "io.vertx:vertx-service-proxy:$vertxVersion"
compile "io.vertx:vertx-sockjs-service-proxy:$vertxVersion"
compile "io.vertx:vertx-hazelcast:$vertxVersion"
compile "io.vertx:vertx-web:$vertxVersion"
compile "io.vertx:vertx-config:$vertxVersion"
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.6'
testCompile group: 'io.vertx', name: 'vertx-unit', version: vertxVersion
testCompile group: 'io.vertx', name: 'vertx-junit5', version: vertxVersion
testCompile 'org.assertj:assertj-core:3.9.0'
//Junit 5
testCompile("org.junit.jupiter:junit-jupiter-api:5.1.0")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.0")
//Junit 5 vintage to run Junit4 Tests
testCompile("junit:junit:4.12")
testRuntime("org.junit.vintage:junit-vintage-engine:5.1.0")
compileOnly 'io.vertx:vertx-codegen:3.4.2'
}
whithout the :
testCompile group: 'io.vertx', name: 'vertx-junit5', version: vertxVersion
the Test Engine finds the Tests and make no Problems
but with this dependency
No tests were found
Feb 22, 2018 2:41:28 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable WARNUNG: TestEngine with ID 'junit-jupiter' failed to discover tests java.lang.NoSuchMethodError: org.junit.platform.engine.support.filter.ClasspathScanningSupport.buildClassFilter(Lorg/junit/platform/engine/EngineDiscoveryRequest;Ljava/util/function/Predicate;)Lorg/junit/platform/commons/util/ClassFilter; at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:49) at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:61) at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130) at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117) 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)
Feb 22, 2018 2:41:28 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable WARNUNG: TestEngine with ID 'junit-jupiter' failed to discover tests java.lang.NoSuchMethodError: org.junit.platform.engine.support.filter.ClasspathScanningSupport.buildClassFilter(Lorg/junit/platform/engine/EngineDiscoveryRequest;Ljava/util/function/Predicate;)Lorg/junit/platform/commons/util/ClassFilter; at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:49) at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:61) at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130) at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:62) 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)
Process finished with exit code 0 Empty test suite.
I dont understand why a dependency affects on the testEngine
Im using IntelliJ 2017.2.6
and I trying my luck with a Test simple as possible
import io.vertx.junit5.VertxTestContext;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class test {
@Test
@DisplayName("woop woooooooop")
void Test(){
VertxTestContext context = new VertxTestContext();
context.succeeding();
}
}