2017-01-28 3 views
2

Когда я пытаюсь запустить тесты Junit, я получаю эту ошибку. Как я могу исправить это для запуска моих тестов? Я включил Junit 4 в папку lib.PreconditionViolationException: Не удалось загрузить класс с именем: testing.ConnectionTest

/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7538 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/tools.jar:/Users/yf/Desktop/sl/419/ece419/BasicStorageServer-stub/gson-1.1.jar:/Users/yf/Desktop/sl/419/ece419/BasicStorageServer-stub/libs/log4j-1.2.17.jar:/Applications/IntelliJ IDEA.app/Contents/lib/junit.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-jupiter-api-5.0.0-M3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/opentest4j-1.0.0-M1.jar:/Applications/IntelliJ IDEA.app/Contents/lib/junit-4.12.jar:/Applications/IntelliJ IDEA.app/Contents/lib/hamcrest-core-1.3.jar:/Users/yf/Desktop/sl/419/ece419/BasicStorageServer-stub/libs/gson-2.8.0.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-platform-launcher-1.0.0-M3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-jupiter-engine-5.0.0-M3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-platform-commons-1.0.0-M3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-platform-engine-1.0.0-M3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-platform-runner-1.0.0-M3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-vintage-engine-4.12.0-M3.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 testing.ConnectionTest 
Jan 28, 2017 1:01:49 AM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines 
INFO: Discovered TestEngines with IDs: [junit-jupiter, junit-vintage] 
Internal Error occurred. 
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: testing.ConnectionTest 
    at org.junit.platform.engine.discovery.ClassSelector.lambda$getJavaClass$0(ClassSelector.java:71) 
    at java.util.Optional.orElseThrow(Optional.java:290) 
    at org.junit.platform.engine.discovery.ClassSelector.getJavaClass(ClassSelector.java:70) 
    at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.lambda$resolveSelectors$2(DiscoverySelectorResolver.java:60) 
    at java.util.ArrayList.forEach(ArrayList.java:1249) 
    at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:59) 
    at org.junit.jupiter.engine.JupiterTestEngine.resolveDiscoveryRequest(JupiterTestEngine.java:50) 
    at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:43) 
    at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:109) 
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:79) 
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:47) 
    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:497) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 
+0

Вы используете 'Junit5'? Я вижу * org.junit.jupiter.engine * и, пожалуйста, поделитесь некоторым кодом, который генерирует это исключение, чтобы выяснить причину. – nullpointer

+0

Укажите «импорт», также используемый в вашем коде. – nullpointer

+1

Является 'test.ConnectionTest' на пути к классам? –

ответ

0

Исключение выбрасывается из ClassSelector class line 71, который будет пытаться загрузить класс с именем, указанным в вашем коде.

Сказанное, имя класса testing.ConnectionTest кажется подозрительным при первом взгляде, и именно поэтому вы получаете это исключение.

Возможно, вы намерены указать ConnectionTest.class.