Attached are the code modifications I've made to the JUnit task in order to
get the Ant properties captured for each test suite run.

I've never submitted a patch before, so let me know if the format of the two
attached files is acceptable or not.

Note: The change to XMLJUnitResultFormatter.java was made to the 1.3 release
version from CVS, but there has been one change made to it since then (this
should not be a factor when applying the patch, but I just wanted to note
it).

    Erik

cvs -q diff XMLJUnitResultFormatter.java (in directory 
C:\ant\cvs\jakarta-ant\src\main\org\apache\tools\ant\taskdefs\optional\junit\)
Index: XMLJUnitResultFormatter.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java,v
retrieving revision 1.6
diff -r1.6 XMLJUnitResultFormatter.java
126a127,141
> 
>         // Output properties
>         Element propsElement = doc.createElement("Properties");
>         rootElement.appendChild(propsElement);
>         Properties props = suite.getProperties();
>         if (props != null) {
>             Enumeration e = props.propertyNames();
>             while (e.hasMoreElements()) {
>               String name = (String) e.nextElement();
>               Element propElement = doc.createElement("Property");
>               propElement.setAttribute("name", name);
>               propElement.setAttribute("value", props.getProperty(name));
>               propsElement.appendChild(propElement);
>             }
>         }
cvs -q diff JUnitTest.java (in directory 
C:\ant\cvs\jakarta-ant\src\main\org\apache\tools\ant\taskdefs\optional\junit\)
Index: JUnitTest.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java,v
retrieving revision 1.5
diff -r1.5 JUnitTest.java
60a61
> import java.util.Properties;
82a84,86
>     // Snapshot of the system properties
>     private Properties props = null;
> 
128a133
>     public Properties getProperties() { return props;}
136a142,146
> 
>         // grabbing properties from the project is hacked here since this 
> method is only called once from JUnitTask
>         props = new Properties();
>         props.putAll(p.getProperties());
> 

Reply via email to