Przygotowałem projekt Ant, który obejmuje test jednostkowy z wykorzystaniem JUnit.JUnit i Ant: Jak wyświetlić szczegółowy komunikat o błędzie na ekranie?
Celem testu jest jako:
<target name="test">
<mkdir dir="target/test/reports"/>
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement location="${test.classes.dir}"/>
<pathelement location="${test.junit.jar}" />
<pathelement path="${classes.dir}"/>
<pathelement path="${java.class.path}"/>
</classpath>
<formatter type="plain"/>
<batchtest fork="yes" todir="${test.reports.dir}">
<fileset dir="${test.src.dir}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
Kiedy uruchomić ten test, to pokazać na ekranie tylko podsumowanie testu jak:
Buildfile: F:\test\build.xml
test:
[junit] Running com.mycompany.myproject.myTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.013 sec
[junit] Running com.mycompany.myproject.myTest1
[junit] Tests run: 3, Failures: 1, Errors: 0, Time elapsed: 0.018 sec
BUILD FAILED
F:\test\build.xml:30: Test com.mycompany.myproject.myTest1 failed
Total time: 1 second
Czy mimo to mogę powiedzieć JUnit lub Ant, aby wyświetlić szczegółowy wynik na ekranie?
Ponadto, jeśli chcę napisać coś w teście Jednostki na ekranie, jak mogę to zrobić? Próbowałem wstawić System.out.println() do testu, ale nie wyświetla nic na ekranie.
Wielkie dzięki.