开发者

Can't specify Cobertura datafile location for server running under Ant?

开发者 https://www.devze.com 2023-01-19 09:30 出处:网络
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 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\r开发者_开发问答esources\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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消