To answer my own question, the problem was with the XML files generated by 
Catch and missing XML attributes. I wrote a post-build shell script that 
modifies the <testsuite> tag to include the name= and package= attributes 
base on path manipulation. The classname attribute is also modified to have 
name= attribute as a prefix (this generates a nicer report in Jenkins to 
avoid all tests having the "(root)" package name). 

The modified XML looks like this:

<testsuites>
  <testsuite name="apps.someapp" package="apps" errors="0" failures="0" 
tests="48" hostname="tbd" time="0.173425" timestamp="tbd">
    <testcase classname="apps.someapp.xxxxxx" name="xxxxxxxxxx" 
time="0.000048"/>
    <!-- more testcase tags... -->
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>

I've attached the script in case anyone needs it. You may have to adapt the 
extraction of the NAME and PACKAGE variables to suit your needs.

Regards,
--
Tarjei

On Wednesday, April 23, 2014 3:31:46 PM UTC+2, Tarjei Knapstad wrote:
>
> We have a project that creates several "testresults.xml" files in JUnit 
> format when built. I've added "trunk/build/**/testresults.xml" under the 
> "Publish JUnit test result report" which seems to work, but when the 
> project is built Jenkins only picks up the first testresults.xml file and 
> seems to ignore the rest. The files in question are generated by Catch (
> https://github.com/philsquared/Catch). I've tried other globs as well 
> like "**/testresults.xml" and "**/*.xml" but they all give the same result.
>
> The generated XML files look like this:
> <testsuites>
>   <testsuite errors="0" failures="0" tests="48" hostname="tbd" 
> time="0.173425" timestamp="tbd">
>     <testcase classname="xxxxxx" name="xxxxxxxxxx" time="0.000048"/>
>     <!-- more testcase tags... -->
>     <system-out/>
>     <system-err/>
>   </testsuite>
> </testsuites>
>
> Any ideas?
>
> Regards,
> --
> Tarjei Knapstad
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/env bash

if (( $# < 1 ))
then
    echo "USAGE: fix_testresults.sh <build_dir>"
    echo "Please specify a build directory"
    exit
fi

RESULTS=$(find $1 -name testresults.xml)

for file in $RESULTS; do
    NAME=${file/\/test*/}
    NAME=${NAME/$PWD/}
    NAME=${NAME:1}
    NAME=${NAME/\//.}
    PACKAGE=${NAME%%.*}

    SEDCMD="sed -i '2 s/<testsuite /<testsuite name=\"$NAME\" package=\"$PACKAGE\" /' $file"
    eval $SEDCMD
    SEDCMD="sed -i 's/classname=\"/classname=\"$NAME./g' $file"
    eval $SEDCMD
done


Reply via email to