views:

580

answers:

1

A team member of mine recently setup some Hudson continuous-integration builds for a number of our development code bases. It uses the built in ant integration configured in simple way.

While, it is very helpful and I recommend it strongly, I was wondering how to get more more concise/informative/useful emails instead of just the tail of the ant build log.

E.G., Don't want this:

> [...truncated 36530 lines...]
>     [junit] Tests run: 32, Failures: 0, Errors: 0, Time elapsed: 0.002 sec
... (hundred of lines omitted) ...
>     [junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.001 sec
>     [junit] Tests FAILED
>
> BUILD FAILED

I assume, that I could skip the build-in ant support and send the build log through a grep script, but I was hoping there was a more integrated or elegant option.

+1  A: 

Hi there.

I don't know if you're already doing this, but I think that the following snippet of the ant testing task can help you

<target name="test" depends="test.compile" description="runs junit tests">

        <taskdef name="junit"
            classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
            classpath="${script.dir}/tools/ant-junit.jar"/>

        <junit haltonfailure="no" printsummary="on" fork="yes">
            <classpath>
                 <path refid="web.classpath.compile"/>
                 <pathelement location="${test.build.dir.classes}"/>
                 <pathelement location="${web.build.dir.classes}"/>
            </classpath>
            <formatter type="brief" usefile="false"/>
            <formatter type="xml"/>
            <batchtest todir="${script.dir}/test-results">
                <fileset dir="${test.build.dir.src}"
                        includes="**/*Test.java"/>
            </batchtest>
        </junit>
    </target>

With this configuration you are creating a "junit" task implemented by the "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" that can be located at the ant-junit.jar package.

Afterwards, directly invoke the target and set an xml formatter.

We are also using Hudson, it simply sends the URL of the recently build failed, and, from there, we can access the tests results generated by the previously described task with the trace of the AssertionFailedError.

Hope it helps.

Carlos

Carlos
I'm doing the same, but I also would like to have the link to the test report sent with the email
neves