Junit XML report has empty `<properties/>`


(Ketan Padegaonkar) #1

The JUnit XML report (generated by JUnitXmlResultWriter seems to contain an empty <properties/> element. However a similear report generated by maven or ant’s junit runner contains all system properties as returned by System.getProperties(). These properties are useful in diagnosing test failures that may be caused because of system properties that may or may not be set on remote CI machines.

The fix seems to be to add the following lines to org.gradle.api.internal.tasks.testing.junit.result.JUnitXmlResultWriter, however for some reason I’m unable to master gradle to compile on my machine.

            writer.startElement("properties");
            Map<Object, Object> systemProperties = System.getProperties();

            for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
                writer.startElement("property")
                    .attribute("name", (String) entry.getKey())
                    .attribute("value", (String) entry.getValue());
                writer.endElement();
            }
            writer.endElement();

I’m happy to submit a pull request if someone can confirm that this is the right place to apply a fix.


(Lance Java) #2

That code could throw a ClassCastException.
I’d probably use String.valueOf(x) instead of (String) x


(Ketan Padegaonkar) #3

Thank you for that catch, I’ll fix it.