Mercurial > hg > release > icedtea-web-1.2
changeset 348:fdf094ad9342
Fixed JunitLikeXmlOutputListener.java
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Tue, 22 May 2012 17:33:08 +0200 |
parents | c95fe178d33d |
children | 08121ef055a2 |
files | ChangeLog tests/junit-runner/JunitLikeXmlOutputListener.java |
diffstat | 2 files changed, 32 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue May 22 14:52:43 2012 +0200 +++ b/ChangeLog Tue May 22 17:33:08 2012 +0200 @@ -1,3 +1,10 @@ +2012-05-22 Jiri Vanek <jvanek@redhat.com> + + * /tests/junit-runner/JunitLikeXmlOutputListener.java: fixed bug with + null-value when adding attributes, ignored tests handled correctly + (testIgnored) new method to handle ignored tests + (testDone) new method to unify call from (testIgnored) and (testPassed) + 2012-05-22 Jiri Vanek <jvanek@redhat.com> * tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java:
--- a/tests/junit-runner/JunitLikeXmlOutputListener.java Tue May 22 14:52:43 2012 +0200 +++ b/tests/junit-runner/JunitLikeXmlOutputListener.java Tue May 22 17:33:08 2012 +0200 @@ -26,6 +26,7 @@ import org.junit.runner.Result; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunListener; + /** * This class listens for events in junit testsuite and wrote output to xml. * Xml tryes to follow ant-tests schema, and is enriched for by-class statistics @@ -66,6 +67,7 @@ int total; int failed; int passed; + int ignored; long time = 0; } Map<String, ClassCounter> classStats = new HashMap<String, ClassCounter>(); @@ -94,7 +96,12 @@ attString.append(" "); Set<Entry<String, String>> entries = atts.entrySet(); for (Entry<String, String> entry : entries) { - attString.append(entry.getKey()).append("=\"").append(attributize(entry.getValue())).append("\""); + String k = entry.getKey(); + String v = entry.getValue(); + if (v == null) { + v = "null"; + } + attString.append(k).append("=\"").append(attributize(v)).append("\""); attString.append(" "); } } @@ -103,7 +110,7 @@ } private static String attributize(String s) { - return s.replace("&", "&").replace("<", "<").replace("\"","""); + return s.replace("&", "&").replace("<", "<").replace("\"", """); } private void closeElement(String name) throws IOException { @@ -129,7 +136,7 @@ @Override public void testStarted(Description description) throws Exception { testFailed = null; - testStart = System.nanoTime()/1000l/1000l; + testStart = System.nanoTime() / 1000l / 1000l; } @Override @@ -138,11 +145,19 @@ } @Override + public void testIgnored(Description description) throws Exception { + testDone(description, 0, 0, true); + } + + @Override public void testFinished(org.junit.runner.Description description) throws Exception { - long testTime = System.nanoTime()/1000l/1000l - testStart; + long testTime = System.nanoTime() / 1000l / 1000l - testStart; double testTimeSeconds = ((double) testTime) / 1000d; + testDone(description, testTime, testTimeSeconds, false); + } - Map<String, String> testcaseAtts = new HashMap<String, String>(3); + private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception { + Map<String, String> testcaseAtts = new HashMap<String, String>(4); NumberFormat formatter = new DecimalFormat("#0.0000"); String stringedTime = formatter.format(testTimeSeconds); stringedTime.replace(",", "."); @@ -176,9 +191,12 @@ cc.total++; cc.time += testTime; if (testFailed == null) { - cc.passed++; + if (ignored) { + cc.ignored++; + } else { + cc.passed++; + } } else { - cc.failed++; } }