Vin*_*ati 5 java junit unit-testing intellij-idea junit5
Junit-5测试用例成功地从命令行运行.我正在使用Maven,当我运行使用mvn clean install测试用例成功运行但是当使用IntelliJ运行单个测试用例时,它失败并出现以下错误.
Feb 15, 2018 11:33:41 PM org.junit.jupiter.engine.discovery.JavaElementsResolver resolveMethod
WARNING: Method 'public static java.util.Collection com.softiventure.dtos.junit.parametrized.NestedParametrizedTest$sumTest.parameters()' could not be resolved.
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;)V
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:59)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Run Code Online (Sandbox Code Playgroud)
我的示例测试类是:
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@DisplayName("Pass paramters ")
public class ParametrizedJunit5Test {
@DisplayName("Should pass a non-null message to our test method")
@ParameterizedTest
@ValueSource(strings = {"Hello", "World"})
void shouldPassNonNullMessageAsMethodParameter(String message) {
assertNotNull(message);
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.
| 归档时间: |
|
| 查看次数: |
3331 次 |
| 最近记录: |