Bamboo failing test can't parse junit
Asked Answered
B

2

7

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.

Baden answered 9/7, 2014 at 15:36 Comment(0)
B
12

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.

Baden answered 22/8, 2014 at 8:28 Comment(2)
So, I have my tasks listed out, and my junit parser is last, but I am having the same issue you are. My list goes - Command -> Checkout -> Command (The actual build, where when it fails, I believe it is not going on to the JUnit parser). Is that how yours is set up when it works? Thanks!Cellulose
So, martync is right. But I was not placing it under 'Final task', but at the end of the normal tasksCellulose
K
0

May be related to this bamboo issue, where test results are not found but it gives the error you are seeing

https://jira.atlassian.com/browse/BAM-2165

I had similar problems, and by modifying the "specify custom results directories" box in the junit task to a broader search pattern, it started working for me.

I used **/test-results.xml

Krakau answered 25/7, 2014 at 3:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.