2017-05-04 1 views
0

IntelliJ IDE에서 Java 응용 프로그램을 개발 중입니다. 내 저장소를 Travis CI에 연결할 수있게하려면 IDE를 사용하여 ant build.xml을 생성해야했습니다. 그러나 IntelliJ는 빌드 파일에서 테스트 대상을 만들지 않았습니다. 나는 수동으로 추가하여 편집 한 다음Ant JUnit throw ClassNotFoundException

<target name="test" depends="compile.module.pearplanner.tests"> 
    <junit> 
     <classpath> 
      <pathelement location="lib/junit-4.12.jar"/> 
     </classpath> 
     <batchtest> 
      <fileset dir="./Test/"> 
       <include name="**/*Test*" /> 
      </fileset> 
     </batchtest> 
     <formatter type="brief" usefile="false"/> 
    </junit> 
</target> 

나는 다음과 같은 오류가 점점 오전

ant test 

실행하면 : 나는 복수를 테스트 한

test: 
[junit] Testsuite: Model.AccountTest 
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec 
[junit] 
[junit] Null Test: Caused an ERROR 
[junit] Model.AccountTest 
[junit] java.lang.ClassNotFoundException: Model.AccountTest 
[junit]  at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
[junit]  at java.lang.Class.forName0(Native Method) 
[junit]  at java.lang.Class.forName(Class.java:348) 
[junit] 
[junit] 
[junit] Test Model.AccountTest FAILED 
[junit] Testsuite: Model.PersonTest 
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec 
[junit] 
[junit] Null Test: Caused an ERROR 
[junit] Model.PersonTest 
[junit] java.lang.ClassNotFoundException: Model.PersonTest 
[junit]  at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
[junit]  at java.lang.Class.forName0(Native Method) 
[junit]  at java.lang.Class.forName(Class.java:348) 
[junit] 
[junit] 
[junit] Test Model.PersonTest FAILED 
BUILD SUCCESSFUL 
Total time: 0 seconds 

My project structure

을 웹에서 찾을 수있는 접근 방식이지만, 모두 나에게 동일한 결과물을 제공했습니다. 여기서 내가 뭘 잘못하고 있니?

+0

테스트 할 클래스는 어디에 있습니까? 클래스 패스에 추가하십시오. – Rao

답변

0

나는 그것을 고칠 수 있었다. classpath에 클래스 출력 디렉토리와 테스트 클래스 출력 디렉토리를 지정해야한다는 것을 알게되었습니다. 또한 hamcrest-core-1.3.jar도 없었습니다. 올바른 버전 :

<target name="test" depends="build.modules" > 
    <junit haltonerror="yes" haltonfailure="yes"> 
     <classpath> 
      <pathelement location="${basedir}/lib/junit-4.12.jar"/> 
      <pathelement location="${basedir}/lib/hamcrest-core-1.3.jar"/> 
      <pathelement location="${pearplanner.output.dir}/"/> 
      <pathelement location="${pearplanner.testoutput.dir}/"/> 
     </classpath> 
     <batchtest> 
      <fileset dir="${pearplanner.testoutput.dir}"> 
       <include name="**/*Test*" /> 
      </fileset> 
     </batchtest> 
     <formatter type="brief" usefile="false"/> 
    </junit> 
</target> 
관련 문제