ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: junit tests in single jvm
Date Wed, 19 Apr 2006 08:34:45 GMT
P.S.Lokesh wrote:
> hi,
> I have been looking through the docs to run my junit tests in the same 
> jvm where server is started, but i could not achieve it through parallel 
> task,

No, you cant, it doesnt make sense.

> shown below is the sample code:
> <target name="startserver" description="Starting Server">
>      <parallel>
>              <exec dir="/producthome/bin" executable="/bin/sh" os="Linux">
> *                <!-- I expect all the unit tests to happen in this jvm 
> where start server starts a main java class -->*
>                    <arg line=""/>
>              </exec>

This execs a shell script. Ant knows the process ID, but does not know 
or care that it is a server

>              <sequential>
>                  <sleep seconds="30"/>

fairly crude synchronisation. I'd use <wait> with a condition like a 
port or HTTP page being present.

>                        <mkdir dir="${}/html"/>
> *                <!-- But I thik this task starts a separate jvm and 
> hence my results fails -->*
>                         <junit printsummary="withOutAndErr" 
> showoutput="true" forkmode="once">
>                                <classpath path="${clp}"/>
>                                <batchtest todir="${}">
>                                        <fileset dir="${classes.dir}">
>                                             <include 
> name="**/Test*.class"/>
>                                         </fileset>
>                             </batchtest>
>                              <formatter type="xml" />
>                        </junit>

Here's the problem.
1. Ant doesnt know that you started a JVM up above
2. Even if it did, it wouldnt be able to start junit in that JVM, 
because that JVM is off running a service.

> How do i achieve this ? Is there any other way to do this ?

1. Jakarta Cactus,

This hosts Junit tests inside an application server.

2. Smartfrog JUnit deployment
  This is something I have yet to finish, but which will let you deploy 
junit tests just like any other bit of a distributed system. If you 
deploy the junit tests into the same process as the application server, 
then you *may* get what you want. However, it is more complex as you 
need to switch to smartfrog to describe how to deploy something, and to 
declare the test running workflow (i.e. which machine/process to collect 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message