From 2758c5af6bdc5b58e4769106ceb15c6561475537 Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sun, 29 Jul 2018 21:41:20 +0100
Subject: [PATCH v1 1/2] test targets: add "-hardfail" variants which will
abort with an error code on failure
intended for use when specifying targets from top level rather than as a
dependency. also add a test-unit mode which will only run unit tests.
---
build.xml | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/build.xml b/build.xml
index c732880e8..55989d359 100644
|
a
|
b
|
Build-Date: ${build.tstamp}
|
| 505 | 505 | <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/> |
| 506 | 506 | <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="${jacoco.includes}" |
| 507 | 507 | inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}"> |
| 508 | | <junit printsummary="yes" fork="true" forkmode="once"> |
| | 508 | <junit printsummary="yes" fork="true" forkmode="once" failureproperty="test.@{testfamily}@{testITsuffix}.failed"> |
| 509 | 509 | <jvmarg value="-Dfile.encoding=UTF-8"/> |
| 510 | 510 | <jvmarg value="-javaagent:${test.dir}/lib/jmockit-1.41.jar"/> |
| 511 | 511 | <jvmarg value="--add-modules" if:set="isJava9" unless:set="isJava11" /> |
| … |
… |
Build-Date: ${build.tstamp}
|
| 557 | 557 | <call-junit testfamily="unit"/> |
| 558 | 558 | <call-junit testfamily="functional"/> |
| 559 | 559 | </target> |
| | 560 | <target name="test-hardfail" depends="test" description="Run 'test' target but abort if tests failed"> |
| | 561 | <fail message="'test' failed"> |
| | 562 | <condition> |
| | 563 | <or> |
| | 564 | <isset property="test.unit.failed"/> |
| | 565 | <isset property="test.functional.failed"/> |
| | 566 | </or> |
| | 567 | </condition> |
| | 568 | </fail> |
| | 569 | </target> |
| | 570 | <target name="test-unit" depends="test-compile" unless="test-unit.notRequired" |
| | 571 | description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password"> |
| | 572 | <call-junit testfamily="unit"/> |
| | 573 | </target> |
| | 574 | <target name="test-unit-hardfail" depends="test-unit" description="Run 'test-unit' target but abort if tests failed"> |
| | 575 | <fail message="'test-unit' failed" if="test.unit.failed"/> |
| | 576 | </target> |
| 560 | 577 | <target name="test-it" depends="test-compile" unless="test-it.notRequired" |
| 561 | 578 | description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password"> |
| 562 | 579 | <call-junit testfamily="unit" testITsuffix="IT"/> |
| 563 | 580 | <call-junit testfamily="functional" testITsuffix="IT"/> |
| 564 | 581 | </target> |
| | 582 | <target name="test-it-hardfail" depends="test-it" description="Run 'test-it' target but abort if tests failed"> |
| | 583 | <fail message="'test-it' failed"> |
| | 584 | <condition> |
| | 585 | <or> |
| | 586 | <isset property="test.unitIT.failed"/> |
| | 587 | <isset property="test.functionalIT.failed"/> |
| | 588 | </or> |
| | 589 | </condition> |
| | 590 | </fail> |
| | 591 | </target> |
| 565 | 592 | <target name="test-perf" depends="test-compile" unless="test-perf.notRequired" |
| 566 | 593 | description="Run performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password"> |
| 567 | 594 | <call-junit testfamily="performance" coverage="false"/> |
| 568 | 595 | </target> |
| | 596 | <target name="test-perf-hardfail" depends="test-perf" description="Run 'test-perf' target but abort if tests failed"> |
| | 597 | <fail message="'test-perf' failed" if="test.performance.failed"/> |
| | 598 | </target> |
| 569 | 599 | <target name="test-html" depends="test, test-it, test-perf" description="Generate HTML test reports"> |
| 570 | 600 | <!-- May require additional ant dependencies like ant-trax package --> |
| 571 | 601 | <junitreport todir="${test.dir}/report"> |