gpt4 book ai didi

java - Vertx ( vertx-Junit5 模块 ) 没有找到测试

转载 作者:行者123 更新时间:2023-11-30 10:19:02 26 4
gpt4 key购买 nike

我尝试在我的 Vertx 项目中实现 Junit5。

只需添加 junit5 就可以正常工作,但是将 vertx-junit5 模块添加到项目后,测试引擎在查找测试时遇到问题

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'
}

没有:

testCompile group: 'io.vertx', name: 'vertx-junit5', version: vertxVersion

测试引擎找到测试并且没有问题

但是有了这个依赖

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.

我不明白为什么依赖会影响测试引擎

我使用的是 IntelliJ 2017.2.6

我用尽可能简单的测试来试试运气

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();
}
}

最佳答案

也许您错过了测试类的 JUnit5 扩展注释:

@ExtendWith(VertxExtension.class)
public class test {
...
}

关于java - Vertx ( vertx-Junit5 模块 ) 没有找到测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48929594/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com