# HG changeset patch # User Jiri Vanek # Date 1337700788 -7200 # Node ID fdf094ad9342fe7461dab9179465ed4a3448e390 # Parent c95fe178d33dca1adb848746f8886b6003bbbfb0 Fixed JunitLikeXmlOutputListener.java diff -r c95fe178d33d -r fdf094ad9342 ChangeLog --- 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 + + * /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 * tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java: diff -r c95fe178d33d -r fdf094ad9342 tests/junit-runner/JunitLikeXmlOutputListener.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 classStats = new HashMap(); @@ -94,7 +96,12 @@ attString.append(" "); Set> entries = atts.entrySet(); for (Entry 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 testcaseAtts = new HashMap(3); + private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception { + Map testcaseAtts = new HashMap(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++; } }