2
votes

I have an Ant build script that instruments some jar files, starts some servers using those jars files and then runs an integration test suite of junit tests against them.

I want to capture the cobertura.ser file from each server in a separate file.

The servers need to have their working directory set so they can pick up config files. It's a requirement of the system that the classpath must not be used to pick up these files.

Setting the net.sourceforge.cobertura.datafile system property allows the datafile to be set, and this works ok, until the "dir" property is set on the ant java task. Once dir is set, the server starts correctly, the test suite runs OK, but when the server shuts down no data file is written.

Here's a fragment of the build.xml:

<parallel>
    <daemons>
        <java fork="true" dir="src\main\resources\conf\my.server" classname="my.Server">
            <sysproperty key="net.sourceforge.cobertura.datafile" file="target\cobertura.ser" />
            <classpath>
            ...
            </classpath>
            <arg value="-server" />
        </java>

        ...more servers...

        ...run junit tests...

    </daemons>
</parallel>
1
Does the 'target' directory exist under the 'my.server' directory?martin clayton

1 Answers

0
votes

The answer is to not run the servers as daemons. We were doing this so that the servers were automatically shut down when the junit task had completed, but in reality, the Cobertura instrumentation wasn't picking up the fact that the servers were shutting down and so never wrote out the various cobertura.ser files.

The solution was to remove the daemons task, and to add an explicit server shutdown mechanism which we could call from Ant once the tests were complete.