Steve,

Thanks for the response and suggestions. yes, cleanup is problem 
for unit testing executables - so the exe quits at the first failure.
(of course it is not the same as having a test suite
where some tests could fail and yet others can get exercised)
but that is what we could do.

CUnit does generate reports in the same format (XML) and works with
the standard CC XSL. I have modified our XSLs a little to get some
more formatting - e.g: show a summary of tests on the main page)

Here is the sample usage - where you specify a fileset to look for 
.exes (in our project they are named as *Test*)

Regards
-Prasad

        <target name="target-cygwin-runtest" description="Run the tests
for Cygwin build" > <!-- target to run tests -->        
            <echo level="info" message="${line.separator}[CC] Running
Tests using Cygwin...${line.separator}"/>
            
            <property name="test.xml.dir" value="./projects/SushiTest"/>
            <property name="build.test.dir"
value="./checkout/Sushi/Build/Targets/x86-unknown-cygwin/" />
            
                <delete dir="${test.xml.dir}"/>
                <mkdir  dir="${test.xml.dir}"/>         
                
                <echo message="${build.test.dir}" />
                
            <taskdef name="cunit"
classname="org.apache.tools.ant.taskdefs.optional.junit.CUnitTask"/>
                <cunit errorProperty="test.failed"
                           failureProperty="test.failed"
                           dir="${build.test.dir}" debug="true"
printsummary="yes">
        

                        <cbatchtest todir="${test.xml.dir}">
                                <fileset dir="${build.test.dir}"
                                                 includes="**/*Test*" />
                        </cbatchtest>
                                                
                        <formatter type="brief" usefile="false" />
                        <formatter type="xml" />

                </cunit>                
                                
                <fail message="Tests failed! Check test reports.">
                        <condition>
                                <and>
                                        <isset property="test.failed" />
                                        <isset
property="project.failonerror" />
                                </and>                                  
                        </condition>
                </fail>                                                 
        </target>        

-----Original Message-----
From: Steve Loughran [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 16, 2006 2:40 AM
To: Ant Developers List
Subject: Re: AW: CUnit ant task

[EMAIL PROTECTED] wrote:
>> Hello
>>
>> In our project our unit tests are executable files. 
>> I wanted to have something like Ant's JUnit task to be used with 
>> CruiseControl.
>>
>> For this I modified the Ant JUnit task to have a CUnit task (its a 
>> little bit of a hack because I wanted to get something that was 
>> working for us but not spend too much effort)
>>
>> Is this something that might be useful to have in Ant ?
>> The changes to the sources and example usage is enclosed in the .zip 
>> file. Comments, suggestions and feedback is welcome.
> 
> 
> While I'm thinking that a <cunit> would be good as some projects using

> Ant for building their C-projects, Ant is not the right place for 
> holding that, because Ant has no c-related tasks.
> * You could open a bugzilla for AntContrib and post your patch
> * You could maintain it for yourself on a website and we could point 
> to that
> * You could open a RFE for the CUnit-Framework (similar to <junit> and

> the JUnit-Framework in
>   the future)

Prasad,

I am sure this will be a welcome addition to people who use CC for CI
builds of C++ stuff (I did this a few years back with cpp unit and
NUnit). However, the ant core codebase isnt the right place because we
dont do enough C/C++ work in the project to ever maintain or test it. 
Indeed, we are even working with the junit people to implement a junit4
task in their codebase, rather than in ant (it gives them more control
that way)

<cunit> It should go wherever the relevant c/cppunit framework lives (if
possible), or in some separate library (like a sourceforge project). I
think ant-contrib would be a good home if they want it, because it goes
together with the <cc> task.

I didnt know about cunit until today; I have used cppunit. it suffers a
bit from the lack of dynamic test discovery, but the real problem with
CPP testing is (a) lack of finally() to do cleanup on failure and (b)
the fact that if one test fails, it usually leaves the system in a bad
state for all the other tests. So the order you test really, really
matters.

Incidentally, if cunit could generate XML reports in the same format as
junit, <junitreport> would still be able to process them. Does it do
this?

-steve



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to