Tag: junit jupiter

如何更改TestEngine ID以运行JUnit 5?

我有我的Kotlin Android项目的以下依赖项{ dependencies { … testImplementation “org.junit.platform:junit-platform-engine:1.0.2” testImplementation “org.junit.platform:junit-platform-gradle-plugin:1.0.2” testImplementation “org.junit.platform:junit-platform-launcher:1.0.2” testImplementation “org.junit.platform:junit-platform-suite-api:1.0.2” testImplementation “org.junit.jupiter:junit-jupiter-api:5.0.2” testImplementation “org.junit.jupiter:junit-jupiter-engine:5.0.2” testImplementation “org.junit.jupiter:junit-jupiter-params:5.0.2” } 运行我的测试时得到的错误是: org.junit.platform.launcher.core.DefaultLauncher handleThrowable WARNING: TestEngine with ID ‘junit-vintage’ failed to discover tests java.lang.NoClassDefFoundError: org/junit/runner/manipulation/Filter … Caused by: java.lang.ClassNotFoundException: org.junit.runner.manipulation.Filter Exception in thread “main” java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest; 如果我的测试引擎id是junit-vintage ,那么是否可以改变它? 它似乎仍然使用junit 4引擎。 我怎样才能改变这个,所以它使用junit-jupiter? 我从我的依赖中删除了junit-4.12,所以我想知道为什么它使用junit-vintage引擎而不是junit-jupiter。 目前使用: Android Studio 3.0 […]

IntelliJ + JUnit 5(木星)

我的build.gradle有: testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0' 使用http://junit.org/junit5/docs/current/user-guide/中的标准示例 import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; class FirstJUnit5Tests { @Test void myFirstTest() { assertEquals(2, 1 + 1); } } 当我尝试在IntelliJ 2017.2.3中作为JUnit测试运行时,我得到: objc[32347]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x10f5be4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10f6864e0). One of the two will be used. Which one is undefined. Sep 11, 2017 12:39:04 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable WARNING: […]