I가 내가 ./lib에서의 JUnit-4.7.jar에 놓여있다개미와 주석이 JUnit 테스트
public class CardTest {
@Test
public void testCardCompareWithSameValue() throws Exception {
Card card1 = new Card(Card.COLOR.CLUBS, 4);
Card card2 = new Card(Card.COLOR.SPADES, 4);
Card.MATCH_TYPE match = card1.compareCard(card2);
assertEquals("The returned match must be of enum type Card.MATCH_TYPE.VALUE",
Card.MATCH_TYPE.VALUE, match);
}
}
./src/com.example.package.tests에서 다음 테스트 클래스
및 다음을가집니다. /build.xml
<project name="Project" basedir="." default="main">
<property name="src.dir" value="src" />
<property name="build.dir" value="build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="jar.dir" value="${build.dir}/jar" />
<property name="lib.dir" value="lib" />
<property name="main-class" value="com.example.package.gui.Main" />
<property name="report.dir" value="${build.dir}/junitreport" />
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="compile">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" />
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" excludes="**/*.java" />
</copy>
</target>
<target name="jar" depends="junit">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}" excludes="**/*Test.class">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
</target>
<target name="junit" depends="compile">
<mkdir dir="${report.dir}" />
<junit printsummary="yes" haltonfailure="yes" showoutput="yes">
<classpath>
<path refid="classpath" />
<path location="${classes.dir}" />
<path refid="application" />
</classpath>
<formatter type="xml" />
<batchtest fork="yes">
<fileset dir="${src.dir}" includes="*Test.java" />
</batchtest>
</junit>
</target>
<target name="junitreport" depends="junit">
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}" includes="TEST-*.xml" />
<report todir="${report.dir}" />
</junitreport>
</target>
<target name="run" depends="jar">
<java classname="${main-class}" fork="true" >
<classpath>
<path refid="classpath" />
<path refid="application" />
</classpath>
</java>
</target>
<target name="clean-build" depends="clean,jar" />
<target name="main" depends="clean,run" />
</project>
개미가 내 junit 테스트를 실행하지 않는 이유는 무엇입니까? 보고서를 확인할 때 0 개의 테스트가 있다고합니다.
OS X Yosemite를 사용하고 있고 이진 다운로드를 통해 Ant를 설치했습니다.
편집 : 우분투 테스트도 변경되지 않았습니다.
'todir' att를 넣지 마십시오. libute라면'build.xml' 파일이 들어있는 디렉토리에 보고서를 작성해야합니다. 거기에서 봤어? 이 방법이 효과가 있다면 기쁘게 생각합니다. –
예, 테스트를 발견 한 내용은 includes = ""속성을 제거한 것입니다. – Tebro