2011-12-10 2 views
1

Eclipse와 Ant 태스크에서 동일한 테스트를 실행합니다. 일식에서 달릴 때 모든 시험은 통과한다. 개미 junit 작업을 실행할 때 하나의 단일 테스트가 다음과 같은 이상한 오류와 함께 실패합니다.Ant 태스크에서 실행 중일 때만 유닛 테스트가 실패 함

junit.framework.AssertionFailedError at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137) at unitests.mypackage.MyTestClass.myTestCase(Unknown Source)

원인은 무엇입니까?

나는 eclipse와 Ant가 서로 다른 버전의 junit을 사용하기 때문에 약간의 내용을 읽었습니다. 내 프로젝트에서 junit은 libs/junit-4.10.jar에 있으며 Eclipse의 .classpath 파일과 junit 작업 클래스 경로에서 모두 참조됩니다. 현재 개미의 작업을 볼 수 있습니다

<path id="classpath"> 
    <fileset dir="${lib.dir}" includes="**/*.jar"/> 
    <fileset dir="${src.dir}" includes="**/*.jar"/> 
</path> 
... 
<target name="run-unit-tests" depends="compile,compile-unit-tests"> 
    <mkdir dir="${junit.output.dir}"/> 
    <junit fork="yes" printsummary="yes" haltonfailure="no">   
     <classpath> 
      <path refid="classpath"/> 
      <fileset dir="${unit.tests.classes.dir}" includes="**/*.class"/> 
     </classpath> 

     <formatter type="xml"/> 
     <batchtest todir="${junit.output.dir}"> 
      <fileset dir="${unit.tests.dir}"> 
       <include name="**/*Test*.java"/> 
      </fileset> 
     </batchtest> 
    </junit> 

    <mkdir dir="${junit.report.dir}"/> 
    <junitreport todir="${junit.report.dir}"> 
     <fileset dir="${junit.output.dir}"> 
     <include name="TEST-*.xml"/> 
     </fileset> 
     <report format="frames" todir="${junit.report.dir}/html"/> 
    </junitreport> 
</target> 

개미의 버전은 1.7.1이며 이클립스와 함께. 편집

:

는 결국 JUnit을의 작업에 fork="yes "를 추가하여 그것을 해결하지 생성 된 파일 및 광산의 차이점을보고 다음 일식의 내보내기 옵션을 사용하여 파일을 빌드 생성 및하여 발견 왜 생각을.. 포크 (fork)는 비록 문제를 해결한다.

가능성이 원인 같은 개미 소리의

답변

2

스택 추적으로 org.eclipse 항목이 표시되므로 Eclipse를 통해 개미를 실행하고 있다고 생각됩니다. 콘솔에서 ant를 실행하면이 문제가 발생하지 않을 가능성이 큽니다.

따라서 Eclipse의 버그입니다. 이것은 놀랄 일이 아니어야한다. Eclipse는 버그로 가득하다.

fork="true"은 개미가 실행을위한 새로운 프로세스를 생성하기 때문에 도움이됩니다. 이 새로운 프로세스에는 클래스 경로에 Eclipse 클래스가 없습니다.

3

다른 버전 ., 이클립스 사용할 set which Ant version을 그을 테스트합니다.

은 또한 아마 같은 버전을 설정하는 것이 좋습니다 JUnit과 IDE 외부에서 테스트를 실행하는 데 사용하는 same JDK을 사용하십시오.

+0

나는 이해하지 못한다. 독립형 Ant를 설치하여 대신 사용 하시겠습니까? – Artium

+0

커맨드 라인에서 빌드를 실행하고 classpath에있는 Ant jar를 참조하고 있다고 가정합니다 (독립형 Ant의 의미가 확실하지 않습니다). JUnit 버전이 같다고 확신하기 때문에 이클립스가 클래스 패스 참조와 같은 버전의 Ant를 사용하고 있는지 확인하고 싶다. 위의 링크는 Eclipse의 ant 환경 설정을 가리켜 야합니다. 문제가 JUnit 버전에 있다고 주장하는 유사한 오류를 참조하는 게시물을 발견했습니다. 따라서 두 가지 모두 동일한 JUnit을 사용하고 있는지 확인하는 것이 좋습니다. http://www.coderanch.com/t/96244/Testing/junit-exception –

관련 문제