You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eli Tucker <ap...@nerdmonkey.com> on 2003/05/23 20:21:58 UTC

Conditionally using a junit formatter

Is there a way to conditionally use a junit formatter?  I want to avoid
outputting the XML formatted test results unless the user wants to
generate reports. I would like to avoid having mostly duplicate test
targets ("test" and "test-xml-formatter") if possible.

I'm doing this in an effort to keep the time it takes developers to
execute unit tests to a minimum (executing tests on my machine takes
twice as long with the XML formatter on).

Thanks,
 - Eli

http://nerdmonkey.com




Re: Conditionally using a junit formatter

Posted by Mariano Benitez <ma...@fuegolabs.com>.
my workaround is prepared for custom class formatters, I needed this 
since I got to store junit results in a database instead of 
writing/mixing xml files.

I completely agree that in/unless would be usefull in some cases.

extract from my build file

<project name="FDI tests" default="test" basedir="..">

    <property file="${basedir}/ant.properties"/>

    <property name="junit.formatter.classname" 
value="fuego.test.XMLJUnitResultFormatter"/>

        <junit printsummary="yes" fork="yes" maxmemory="256m"  
dir="${build.dir}" showoutput="on"
            haltonfailure="false" failureproperty="test-basic.failure" 
haltonerror="false" errorproperty="test-basic.error">
            <classpath refid="junit.class.path"/>
            <formatter classname="${junit.formatter.classname}" 
extension=".xml"/>
            <!-- tests that will be run -->
            <test name="fuego.directory.test.SchemaCreationTest" 
outfile="${outfile.name}-Creation" todir="${run.dir}" />
        </junit>
</project>

and when I want to use the other formatter I just invoke the target with 
-Djunit.formatter.classname=fuego.test.DBJunitResultFormatter, or with 
<ant> setting the property to the other class.


MAriano
--------------------------------

Erik Hatcher wrote:

> Care to elaborate on how you do that with <junit> formatters?
>
>
> On Monday, May 26, 2003, at 08:13  AM, Mariano Benitez wrote:
>
>> I workaround this problem by using a property, and making use of the 
>> feature that do not overwrite the property once defined.
>>
>>
>>
>> Erik Hatcher wrote:
>>
>>> No, there isn't.  But it'd be trivial to add if/unless clauses to 
>>> the formatters.
>>>
>>> Care to submit a patch for this?  *nudge nudge*  :)
>>>
>>>     Erik
>>>
>>>
>>> On Friday, May 23, 2003, at 02:21  PM, Eli Tucker wrote:
>>>
>>>> Is there a way to conditionally use a junit formatter?  I want to 
>>>> avoid
>>>> outputting the XML formatted test results unless the user wants to
>>>> generate reports. I would like to avoid having mostly duplicate test
>>>> targets ("test" and "test-xml-formatter") if possible.
>>>>
>>>> I'm doing this in an effort to keep the time it takes developers to
>>>> execute unit tests to a minimum (executing tests on my machine takes
>>>> twice as long with the XML formatter on).
>>>>
>>>> Thanks,
>>>>  - Eli
>>>>
>>>> http://nerdmonkey.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
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: Conditionally using a junit formatter

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Care to elaborate on how you do that with <junit> formatters?


On Monday, May 26, 2003, at 08:13  AM, Mariano Benitez wrote:
> I workaround this problem by using a property, and making use of the 
> feature that do not overwrite the property once defined.
>
>
>
> Erik Hatcher wrote:
>
>> No, there isn't.  But it'd be trivial to add if/unless clauses to the 
>> formatters.
>>
>> Care to submit a patch for this?  *nudge nudge*  :)
>>
>>     Erik
>>
>>
>> On Friday, May 23, 2003, at 02:21  PM, Eli Tucker wrote:
>>
>>> Is there a way to conditionally use a junit formatter?  I want to 
>>> avoid
>>> outputting the XML formatted test results unless the user wants to
>>> generate reports. I would like to avoid having mostly duplicate test
>>> targets ("test" and "test-xml-formatter") if possible.
>>>
>>> I'm doing this in an effort to keep the time it takes developers to
>>> execute unit tests to a minimum (executing tests on my machine takes
>>> twice as long with the XML formatter on).
>>>
>>> Thanks,
>>>  - Eli
>>>
>>> http://nerdmonkey.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
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>


Re: Conditionally using a junit formatter

Posted by Mariano Benitez <ma...@fuegolabs.com>.
I workaround this problem by using a property, and making use of the 
feature that do not overwrite the property once defined.



Erik Hatcher wrote:

> No, there isn't.  But it'd be trivial to add if/unless clauses to the 
> formatters.
>
> Care to submit a patch for this?  *nudge nudge*  :)
>
>     Erik
>
>
> On Friday, May 23, 2003, at 02:21  PM, Eli Tucker wrote:
>
>> Is there a way to conditionally use a junit formatter?  I want to avoid
>> outputting the XML formatted test results unless the user wants to
>> generate reports. I would like to avoid having mostly duplicate test
>> targets ("test" and "test-xml-formatter") if possible.
>>
>> I'm doing this in an effort to keep the time it takes developers to
>> execute unit tests to a minimum (executing tests on my machine takes
>> twice as long with the XML formatter on).
>>
>> Thanks,
>>  - Eli
>>
>> http://nerdmonkey.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



Re: Conditionally using a junit formatter

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
No, there isn't.  But it'd be trivial to add if/unless clauses to the 
formatters.

Care to submit a patch for this?  *nudge nudge*  :)

	Erik


On Friday, May 23, 2003, at 02:21  PM, Eli Tucker wrote:
> Is there a way to conditionally use a junit formatter?  I want to avoid
> outputting the XML formatted test results unless the user wants to
> generate reports. I would like to avoid having mostly duplicate test
> targets ("test" and "test-xml-formatter") if possible.
>
> I'm doing this in an effort to keep the time it takes developers to
> execute unit tests to a minimum (executing tests on my machine takes
> twice as long with the XML formatter on).
>
> Thanks,
>  - Eli
>
> http://nerdmonkey.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>