septagram
septagram

Reputation: 465

Ant to spin up background process for junit tests

I was wondering if it was possible to have Ant spin up a background server daemon so that I can write tests against the client that require comminication with the server. I've tried creating a java task like so:

     <java classpath="${jar.dir}/foo.jar" classname="foo.Server" fork="true"  failonerror="true">
         <arg value="7777"/>
     </java>

Which correctly spins up the server, but blocks indefinitely. If I add spawn="true", I get this:

spawn does not allow attributes related to input, output, error, result
spawn also does not allow timeout
finally, spawn is not compatible with a nested I/O <redirector> 

I assume this is caused by the argument, but it's required by the server and I don't know how to get around it.

Here's what my current junit target looks like:

 <target name="junit" depends="build-jar">
     <mkdir dir="${report.dir}"/>

     <junit printsummary="yes">
         <classpath>
             <path refid="junitcp"/>
         </classpath>
         <formatter type="brief"/>
         <batchtest fork="yes" todir="${report.dir}">
             <fileset dir="${homeDir}" includes="foo/*Test.java"/>
         </batchtest>
     </junit>
 </target>

Upvotes: 1

Views: 951

Answers (1)

ewan.chalmers
ewan.chalmers

Reputation: 16235

Removing the failonerror attribute allows you to create the spawned java process.

Upvotes: 2

Related Questions