You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bo Rasmussen <kr...@hotmail.com> on 2004/02/16 14:18:49 UTC

junit and errorproperty

Hi,

Is the errorproperty in the junit task local for the task calling 
junit? If i have the targets below where the unittest first calls the 
rununittest and then creates a report. It seems that if the 
test.failed property was set in the rununittest, then it has 
been 'forgotten' in the unittest task! Is that correct?

<target name="rununittest" >
   <junit printsummary="yes" haltonfailure="no"  
errorproperty="test.failed" failureproperty="test.failed">

   // do unittest stuff
</target>

<target name="unittest" >
   <antcall target="rununittest">

   // Create report

   <fail if="test.failed">Tests FAILED. see report for details.</fail>
</target>

Regards
Bo




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: junit and errorproperty

Posted by Peter Reilly <pe...@corvil.com>.
Bo Rasmussen wrote:

>OK - I've implemented the global property using a file. 
>
Thats pretty global ! 8-)
Peter

>The targets 
>called by subant writes to the file. Using the <condition> task and 
><available> does more or less what I am looking for....
>
>Bo
>
>--- In apache-ant@yahoogroups.com, Peter Reilly <pe...@c...> 
>wrote:
>  
>
>>Bo Rasmussen wrote:
>>
>>    
>>
>>>I guess the subant (like antcall) creates a different property 
>>>context... Is it possible to create some sort of global undefined 
>>>property, that can be passed to subant/antcall invoked targets?
>>>
>>> 
>>>
>>>      
>>>
>>No, not at the moment.
>>
>>Peter
>>
>>
>>--------------------------------------------------------------------
>>    
>>
>-
>  
>
>>To unsubscribe, e-mail: user-unsubscribe@a...
>>For additional commands, e-mail: user-help@a...
>>    
>>
>
>
>---------------------------------------------------------------------
>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


Re: junit and errorproperty

Posted by Bo Rasmussen <kr...@hotmail.com>.
OK - I've implemented the global property using a file. The targets 
called by subant writes to the file. Using the <condition> task and 
<available> does more or less what I am looking for....

Bo

--- In apache-ant@yahoogroups.com, Peter Reilly <pe...@c...> 
wrote:
> Bo Rasmussen wrote:
> 
> >I guess the subant (like antcall) creates a different property 
> >context... Is it possible to create some sort of global undefined 
> >property, that can be passed to subant/antcall invoked targets?
> >
> >  
> >
> No, not at the moment.
> 
> Peter
> 
> 
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: user-unsubscribe@a...
> For additional commands, e-mail: user-help@a...


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: junit and errorproperty

Posted by Peter Reilly <pe...@corvil.com>.
Bo Rasmussen wrote:

>I guess the subant (like antcall) creates a different property 
>context... Is it possible to create some sort of global undefined 
>property, that can be passed to subant/antcall invoked targets?
>
>  
>
No, not at the moment.

Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: junit and errorproperty

Posted by Bo Rasmussen <kr...@hotmail.com>.
Actually the example was simplified a bit - but here's the full story

I've created a common.xml file which is imported by specific 
projects. Among other targets the common.xml holds 3 targets 
unittest, rununittest and localrununittest as defined below (I've 
removed unimportant stuff). The unittest target first calls 
rununittest which iterates over subprojects and eventually calls the 
localrununittest. Finally the unittest target creates the report and 
should show a message if something went wrong. 

    <target name="localrununittest" description= "junit">
        <junit printsummary="yes" haltonfailure="no" 
errorproperty="test.failed" failureproperty="test.failed">

          <batchtest todir="${outputdir}">
          </batchtest>
        </junit>
    </target>

   <target name="rununittest" depends="make dirs" description= "Build 
project">

        <!-- This is to iterate over any linked projects in 
subprojects-->
        <subant target="rununittest" failonerror="no" >
           <!-- Sets the report directory to that of the initial 
project -->
           <property name="outputdir" value="${basedir}/report"/>
           <filelist refid="LinkedProjects"/>
        </subant>

        <!-- After calling subprojects do my own stuff -->
        <antcall target="localrununittest">
          <param name="outputdir" value="${basedir}/report"/>
        </antcall>

   </target>

   <target name="unittest" depends="createtestdir, build, 
rununittest" description= "Runs all defined unittests and creates a 
test report">
   <!-- Create a report based on output from all linked projects -->
     <junitreport todir="${basedir}/report">
       <fileset dir="${basedir}/report">
         <include name="TEST-*.xml"/>
       </fileset>
       <report format="frames" todir="./report/html"/>
    </junitreport>

     <!-- Show error message in case a test failed -->
     <fail message="Test FAILED - see report for details" 
if="test.failed"/>

  </target>

I guess the subant (like antcall) creates a different property 
context... Is it possible to create some sort of global undefined 
property, that can be passed to subant/antcall invoked targets?

Regards
Bo

Does anybody know a good book (covering 1.6 issues) which explains 
this property stuff? 

--- In apache-ant@yahoogroups.com, Peter Reilly <pe...@c...> 
wrote:
> Bo Rasmussen wrote:
> 
> >Hi,
> >
> >Is the errorproperty in the junit task local for the task calling 
> >junit? If i have the targets below where the unittest first calls 
the 
> >rununittest and then creates a report. It seems that if the 
> >test.failed property was set in the rununittest, then it has 
> >been 'forgotten' in the unittest task! Is that correct?
> >
> ><target name="rununittest" >
> >   <junit printsummary="yes" haltonfailure="no"  
> >errorproperty="test.failed" failureproperty="test.failed">
> >
> >   // do unittest stuff
> ></target>
> >
> ><target name="unittest" >
> >   <antcall target="rununittest">
> >  
> >
> <antcall> sets up a new project/context for properties, properties
> that get set in this context will not get set in the calling 
> project/context.
> 
> This should read:
> <target name="unittest" depends="rununittest">
>    <fail if="test.failed">Tests FAILED. see...</fail>
> </target>
> 
> Peter
> 
> >   // Create report
> >
> >   <fail if="test.failed">Tests FAILED. see report for 
details.</fail>
> ></target>
> >
> >Regards
> >Bo
> >
> >
> >
> >
> >-------------------------------------------------------------------
--
> >To unsubscribe, e-mail: user-unsubscribe@a...
> >For additional commands, e-mail: user-help@a...
> >
> >
> >
> >  
> >
> 
> 
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: user-unsubscribe@a...
> For additional commands, e-mail: user-help@a...


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: junit and errorproperty

Posted by Peter Reilly <pe...@corvil.com>.
Bo Rasmussen wrote:

>Hi,
>
>Is the errorproperty in the junit task local for the task calling 
>junit? If i have the targets below where the unittest first calls the 
>rununittest and then creates a report. It seems that if the 
>test.failed property was set in the rununittest, then it has 
>been 'forgotten' in the unittest task! Is that correct?
>
><target name="rununittest" >
>   <junit printsummary="yes" haltonfailure="no"  
>errorproperty="test.failed" failureproperty="test.failed">
>
>   // do unittest stuff
></target>
>
><target name="unittest" >
>   <antcall target="rununittest">
>  
>
<antcall> sets up a new project/context for properties, properties
that get set in this context will not get set in the calling 
project/context.

This should read:
<target name="unittest" depends="rununittest">
   <fail if="test.failed">Tests FAILED. see...</fail>
</target>

Peter

>   // Create report
>
>   <fail if="test.failed">Tests FAILED. see report for details.</fail>
></target>
>
>Regards
>Bo
>
>
>
>
>---------------------------------------------------------------------
>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