Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bamboo failing test can't parse junit

I'm using bamboo as CI server for my django project and for a good start, I've made a simple script to know how bamboo shows the successful and the failing tests. I use py.test like this :

py.test test.py --junitxml=junitresults/results.xml

my test.py file contains something like this :

def test_that_fails():
    assert 1 == 2

So it's supposed to fail and bamboo is supposed to show me that the test named "test_that_fails" has actually failed. Instead of that it shows No failed tests found, a possible compilation error occurred. On the "Tests" tab of Bamboo I can see There were no failed tests in this build.

This is the jUnit XML file generated by py.test :

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="1" name="pytest" skips="0" tests="12" time="1.317">
    <testcase classname="test" name="test_that_fails" time="0.000378847122192">
        <failure message="test failure">def test_that_fails():
        # fail pour tester bamboo
&gt;       assert 1 == 2
E       assert 1 == 2

test.py:7: AssertionError</failure>
    </testcase>
    <testcase classname="test" name="test_engage_front" time="0.149123907089"/>
    <testcase classname="test" name="test_engage_front_ffm" time="0.444163799286"/>
    <testcase classname="test" name="test_engage_manage" time="0.15494799614"/>
    <testcase classname="test" name="test_engage_organisateur" time="0.1144759655"/>
    <testcase classname="test" name="test_engage_admin" time="0.122771978378"/>
    <testcase classname="test" name="test_engage_adminffm" time="0.0980911254883"/>
    <testcase classname="test" name="test_engage_motoball" time="0.0341689586639"/>
    <testcase classname="test" name="test_engage_api" time="0.0104990005493"/>
    <testcase classname="test" name="test_jira" time="0.0974311828613"/>
    <testcase classname="test" name="test_monitoring" time="0.00897479057312"/>
    <testcase classname="test" name="test_static" time="0.00422883033752"/>
</testsuite>

If the build is successful, bamboo will show me the detail of all tests, the duration... I've searched for all possible resources on Bamboo doc, on the Bamboo tracker, here, can't see anybody with this problem.

If you have some idea, please share ! Thanks.

like image 858
martync Avatar asked Jul 09 '14 15:07

martync


1 Answers

Just for sharing what I've found. The thing I was ignoring is that Bamboo stops the tasks chain if one fails. So if python manage.py test fails due to an error in a testcase, bamboo stops and won't parse the junit results.

The solution was to place the junit parser as a task in the end, under the section 'Final Tasks'.

It works like a charm now.

like image 109
martync Avatar answered Nov 01 '22 00:11

martync