diff options
authorAlex Clayton <>2018-07-19 12:40:16 (GMT)
committerAlex Clayton <>2018-08-09 12:46:43 (GMT)
commite906d1c46a854de703017cbb05e1adde5babe417 (patch)
parent17a1e7662102eea20ddc104133e2e30a70fefdc1 (diff)
Update stroke's junit testsHEADmaster
Update stroke junit tests so it can cope with the latest version of Junit 4 (4.12) which no requires both Junit and Hamcrest to be on the classpath. This is done using a method similar to how JUNIT is currently set. The make file passes a new HAMCREST enviroment variable to the ant script as HAMCREST_JAR which ant then adds to the tests classpath. So to run the tests with the new JUNIT will need to set JUNIT to point to junit.jar and HAMCREST to the hamcrest jar, then run Make test. Also make use of ant's junitreport task to create a html version of the junit test's results, which makes diagnosing failures easier. Test-information: After setting HAMCREST and JUNIT then running Make Test on OSX and Unix all tests pass and HTML output is generated. If HAMCREST is not set but JUNIT points to latest junit.jar (i.e one that requires hamcrest on class path) tests fail with error about not being able to find hamcrest classes. If HAMCREST not set but JUNIT points to an older junit.jar then tests run correctly. On Windows got the unit tests to run by calling ant directly, again with HAMCREST and JUNIT set tests run correctly. Change-Id: I272b1dbe1bde05593df15f22814b7882a494f2c8
2 files changed, 15 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index e642806..b9c4d82 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ FINDBUGS_VERSION=3.0.1
.PHONY : test
test: dist/lib/stroke.jar third-party/cobertura/cobertura.jar third-party/findbugs-$(FINDBUGS_VERSION)/lib/findbugs.jar third-party/pmd/lib/pmd-5.0.0.jar
- ant ${DEFINES} -DJUNIT_JAR=${JUNIT} -Dcobertura-jar=third-party/cobertura/cobertura.jar -Djakarta-oro-jar=third-party/cobertura/lib/jakarta-oro-2.0.8.jar -Dlog4j-jar=third-party/cobertura/lib/log4j-1.2.9.jar -Dasm-jar=third-party/cobertura/lib/asm-3.0.jar -Dasm-tree-jar=third-party/cobertura/lib/asm-tree-3.0.jar -Dicu4j-jar=third-party/icu4j.jar -Dfindbugs.home=third-party/findbugs-$(FINDBUGS_VERSION) -Dpmd.home=third-party/pmd test
+ ant ${DEFINES} -DJUNIT_JAR=${JUNIT} -DHAMCREST_JAR=${HAMCREST} -Dcobertura-jar=third-party/cobertura/cobertura.jar -Djakarta-oro-jar=third-party/cobertura/lib/jakarta-oro-2.0.8.jar -Dlog4j-jar=third-party/cobertura/lib/log4j-1.2.9.jar -Dasm-jar=third-party/cobertura/lib/asm-3.0.jar -Dasm-tree-jar=third-party/cobertura/lib/asm-tree-3.0.jar -Dicu4j-jar=third-party/icu4j.jar -Dfindbugs.home=third-party/findbugs-$(FINDBUGS_VERSION) -Dpmd.home=third-party/pmd test
mkdir -p third-party/aalto
diff --git a/build.xml b/build.xml
index fe123bb..00f098e 100644
--- a/build.xml
+++ b/build.xml
@@ -117,6 +117,7 @@
<pathelement location="${jar}"/>
<pathelement location="${JUNIT_JAR}"/>
+ <pathelement location="${HAMCREST_JAR}"/>
<fileset dir="${icu4j-dir}" includes="icu4j.jar"/>
@@ -143,6 +144,7 @@
<pathelement location="${JUNIT_JAR}"/>
+ <pathelement location="${HAMCREST_JAR}"/>
<pathelement location="${jar}"/>
<pathelement location="${src.tests}"/>
<path refid="classpath"/>
@@ -201,7 +203,7 @@
- <target name="test" depends="compile-tests, instrument, run-tests, coverage, findbugs, pmd">
+ <target name="test" depends="compile-tests, instrument, run-tests, coverage, findbugs, pmd, report-junit-tests">
<target name="clean"
@@ -243,4 +245,15 @@
+ <target name="report-junit-tests" depends="run-tests">
+ <mkdir dir="${test.results}/html"/>
+ <junitreport todir="${test.results}">
+ <fileset dir="${test.results}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report todir="${test.results}/html"/>
+ </junitreport>
+ </target>