zencd
@zencd

Как прогнать Ant'ом все junit-тесты и одновременно получить правильный код завершения?

[junit haltonfailure = false] — в коце Ant пишет типа «BUILD SUCCESSFUL» — врёт, по сути.

[junit haltonfailure = true] — уже не пишет что «успешно», но процесс останавливается на первом упавшем тесте.

Как и правильный статус получить, и все тесты прогнать?

// Ant 1.8
  • Вопрос задан
  • 2778 просмотров
Пригласить эксперта
Ответы на вопрос 2
@pyatigil
ну вообще можно из таска джюнита получить результат в аттрибут: [junit… failureproperty=testsfailed]

ну и дальше [fail message=«Tests failed.» unless=«testsfailed»/]

хотя это и странно, что приходится так сложно делать =(
Ответ написан
<target name="run-test" depends="init-test, compile-test" unless="option.skiptest">
		<mkdir dir="${test.xml}" />

		<junit 
			haltonfailure="off"
			haltonerror="off"
			errorproperty="test.failed"
			failureproperty="test.failed"
			showoutput="no"
			printsummary="yes"
			includeantruntime="yes"
			dir="${test.build}"
			fork="true">
			<classpath>
				<path refid="test.classpath" />
			</classpath>
			<formatter type="xml"/>
			<batchtest todir="${test.xml}">
				<fileset refid="test.fileset" />
			</batchtest>
		</junit>
	</target>

	<target name="test" depends="run-test" unless="option.skiptest" description="Run unit tests">
		<fail if="test.failed"
			message="At least one test has failed. See logs (in ${test.xml}) for details (use the target test-report to run the test with a report)" />
	</target>

	<target name="test-report" depends="run-test" unless="option.skiptest" description="Run the test with report">
		<junitreport todir="${test.xml}">
			<fileset dir="${test.xml}">
				<include name="TEST-*.xml"/>
			</fileset>
			<report format="noframes" todir="${reports}">
			</report>
		</junitreport>
		<fail if="test.failed"
			message="At least one test has failed. See logs (in ${test.xml}) or report (in ${reports})" />
	</target>
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы