ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregory Gimler <sh...@ll.mit.edu>
Subject RE: Help with JUnit
Date Tue, 15 Jun 2004 17:02:07 GMT
Sure.  Here's the full code snippet:

     <target name="test" description="Run unit tests" depends="start-orb">
         <junit fork="true" printsummary="withOutAndErr"
                haltonerror="false" haltonfailure="false"
                showoutput="true" filtertrace="off"
                errorproperty="test.error" failureproperty="test.error">
             <classpath refid="classpath"/>
             <formatter type="xml" usefile="true"/>
             <test name="${test.suite}" outfile="${log.dir}/${test.suite}" 
filtertrace="off"/>
             <jvmarg value="-Djava.endorsed.dirs=${jaxp-endorsed.dir}"/>
             <jvmarg value="-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB"/>
             <jvmarg 
value="-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton"/>
             <jvmarg value="-Dperseus.dir=${basedir}"/>
             <jvmarg value="-DPerseusLogLevel=FINEST"/>
             <jvmarg value="-Dlogging.dir=${log.dir}"/>
         </junit>
         <!-- fail if we had an error or failure in any of the tests -->
         <fail message="Tests failed" if="test.error"/>
     </target>

What this actually does is call upon my highest level test suite and runs 
all of my tests.  I wrote a custom ant task to autogenerate test suites for 
every package that contains any unit tests
and then does a depth first search on any suites in those packages and 
links them with higher level suites.  This gives me the versatility to 
specify just a subset of my tests by specifying a different test suite 
without the fear that I might have forgotten to add a unit test or two to 
one of the suites (that's guaranteed from my custom task that I don't 
forget any).  So the ${test-suite} variable is the fully qualified
class name of the test suite I want to run.

When this target runs, all of my tests are called and run.  The property, 
test.error gets set and if there was an error or failure in any of my tests 
then that <fail message...  line takes care of returning a failed status to 
ant.  Hope this helped.

                                                                       -Greg



At 12:40 PM 6/15/2004, you wrote:
>Thanks . Very interesting discussion. I am a newbie to ant and want to do
>something similar . Can you share your sample code  and explain it ?
>
>Eager to receive your reply.
>
>srikrishna
>
>-----Original Message-----
>From: Gregory Gimler [mailto:shark@ll.mit.edu]
>Sent: Tuesday, June 15, 2004 6:47 AM
>To: Ant Users List
>Subject: Re: Help with JUnit
>
>Thanks Ivan - works great!
>
>          -Greg
>
>At 09:38 AM 6/15/2004, Ivan Ivanov wrote:
> >Hello Gregory, you can do this:
> >
> ><junit haltonerror="off" haltonfailure="off"
> >errorproperty="test.error"
> >failureproperty="test.error">
> ><!-- Do your tests here -->
> ></junit>
> >
> ><junitreport>
> ><!-- Do your test reports here -->
> ></junitreport>
> >
> ><fail message="Tests failed" if="test.error"/>
> >--- Gregory Gimler <shark@ll.mit.edu> wrote:
> > > I'm trying to do the following with the junit
> > > optional task.  I want to run
> > > a test suite and indicate failure on a test.
> > > However, I'd like to go
> > > through the entire test suite and run every test
> > > even if one fails.  The
> > > problem is I can either enable the halt options and
> > > stop after the first
> > > failure/error and build unsuccessfully or I can set
> > > the halt options to
> > > false and get the output of all failures/errors but
> > > it will return
> > > successfully from the build (something I don't
> > > want).  Is there a way to do
> > > this?  Thanks.
> > >
> > >
> > >                                                       -Greg
> > >
> > >
> > >
> >---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail:
> > > user-help@ant.apache.org
> > >
> > >
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam?  Yahoo! Mail has the best spam protection around
> >http://mail.yahoo.com
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message