1

I have run the my unit tests written with the google test 1.6.0 framework with the --gtest_output="xml:test-results.xml" flag and get a test result file like this:

<?xml version="1.0" encoding="UTF-8"?><testsuites tests="8" failures="0" disabled="0" errors="0" time="81.396" name="AllTests">  <testsuite name="TestSuite1" tests="8" failures="0" disabled="0" errors="0" time="81.396">    <testcase name="Test1" status="run" time="6.391" classname="Class1" />    <testcase name="Test2" status="run" time="6.1" classname="Class1" />    <testcase name="Test3" status="run" time="7.146" classname="Class1" />    <testcase name="Test4" status="run" time="16.164" classname="Class1" />    <testcase name="Test5" status="run" time="25.145" classname="Class1" />    <testcase name="Test6" status="run" time="6.099" classname="Class1" />    <testcase name="Test7" status="run" time="6.162" classname="Class1" />    <testcase name="Test8" status="run" time="8.187" classname="Class1" />  </testsuite></testsuites>

Based on what I have read in other posts the gtest xml output is supposed to be compatible with junit parsers. Related Post:Unable to get hudson to parse JUnit test output XML

The other possibility of error is in my bitten script. Running on Trac 0.12.2. Here is my bitten recipe for parsing the XML file using the java:junit parser:

<build xmlns:java="http://bitten.edgewall.org/tools/java">   <step description="Gather Results" onerror="fail">       <java:junit file="/home/user/temp/test-results.xml" />   </step></build>

In trac, it says that the build was successful, but the test results are blank. 0 run, 0 failed, 0 ignored, 0 errors

Thanks.

askedOct 23, 2012 at 22:27
Axe's user avatar

1 Answer1

1

I was able to solve the problem. It turns out that Trac's JUnit parser has a bug. It doesn't like the testsuites tag and it doesn't like having multiple testsuite sections. PHP allows the testsuites tag, but will not do multiple files. I chose to create a parser in Python that creates multiple XML files from the Gtest output file.

def move_results(results, results_dir):    # Moves all results into a temp folder to be consumed by Bitten    # Files with multiple test suite sections, split into individual files    for files in results:        fin = open(files)        test_id = 0        split_line = files.split('/')        file_name = split_line[len(split_line)-1].split('.xml')        for line in fin:            if not 'testsuites' in line:                if '<testsuite ' in line:                    output_file = results_dir + file_name[0] + '-' + str(test_id) + '.xml'                    test_id = test_id + 1                    fout = open(output_file, 'w')                    fout.write('<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n')                    fout.write(line)                elif '<testsuite\\>' in line:                    fout.write(line)                    fout.close()                elif not '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n' in line:                    fout.write(line)        fin.close()        os.remove(files)

Alternatively, you could use Bitten to do convert using an XSLT. Also you could combine the output files into a single output (with something like nose's XUnit output) and usephp:phpunit to parse the file.

Lii's user avatar
Lii
12.2k9 gold badges69 silver badges92 bronze badges
answeredOct 24, 2012 at 18:40
Axe's user avatar
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.