2016-07-15 5 views
-3

intellij 아이디어로 실행되는 프로젝트에 대한 단위 테스트가 있습니다. Java 7을 사용하면 테스트가 제대로 작동하지만 Java를 7에서 8로 변경하면 모든 단위 테스트에서이 오류 스택 추적이 발생합니다.JUNIT4가 Java 8에서 작동하지 않습니다.

java.lang.IllegalArgumentException 
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) 
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) 
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) 
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 

이 문제점의 근본 원인은 무엇입니까?

업데이트 - 테스트 클래스 및 헤더의 가져 오기를 추가하십시오.

import junit.framework.TestCase; 
import mockit.Expectations; 
import mockit.NonStrictExpectations; 
import mockit.Mocked; 

public class PrepareModule extends TestCase { 
+1

문제가 JUNIT에없는 것처럼 보입니다. intellij에 있습니다. – Jens

+0

몇 가지 코드를 추가하십시오. – cssGEEK

+0

IntelliJ의 최신 버전을 사용합니까? – Tom

답변

0

당신은 당신이 의 JUnit 4을 사용하는 말을하지만 코드는 다음과 같습니다

import junit.framework.TestCase; 

public class PrepareModule extends TestCase { 
} 

이 테스트의 JUnit을 3 스타일을 사용

이이 방법을 시도해보십시오

import org.junit.Test; 

public class PrepareModule { 
    @Test 
    public void someTest() { 
    } 
} 
+0

오류가 계속 발생합니다. –

+1

JUnit 3 종속성을 확인하고 제거 할 수 있습니까? 이 대답의 접근법은 정확합니다. – vikingsteve

0

OK, 위트 당신의 스택 트레이스보고 시간 신선한 눈 :

  • java.lang
  • sun.reflect
  • com.intellij

이 :

java.lang.IllegalArgumentException 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 

이, 나는 단지에서 패키지를 전체 스택을 참조한다 가정하면 JUnit은 (는) 할 수있는 일이 없습니다. 문제가있다. 아마도 문제는 맨 위의 클래스에있다 스택 (또는 하단 중) : com.intellij.junit4.JUnit4IdeaTestRunner

할 수 있다면, 다른 의 JUnit 러너을 시도 같은 from command line 등 :

java org.junit.runner.JUnitCore <test class name> 
0

어떤 버전 JMock 당신이 사용하고 있습니까? 일부 이전 버전의 JMockIt은 Java 8과 호환되지 않습니다.

내 테스트가 TestCase를 확장하지 않았다는 것을 제외하고는 거의 동일한 문제가 발생했습니다. JMockIt 1.0 -> 1.14를 업그레이드하여 문제를 해결했습니다.

0

이 문제는 IDEA에서 소개 한 것 같습니다.

+0

이 질문에 대한 답을 제공하지 않습니다. 충분한 [평판] (http://stackoverflow.com/help/whats-reputation)이 있으면 어떤 글에도 [comment] (http://stackoverflow.com/help/privileges/comment) 할 수 있습니다. 또한 이것을 확인하십시오. [대신 할 수있는 방법] (https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reference-to-comment-what-can-i-do-instead). – thewaywewere

관련 문제