竹子测试失败不能解析junit

时间:2014-07-09 15:36:19

标签: python testing junit bamboo

我正在使用竹子作为我的django项目的CI服务器,并且有一个良好的开端,我已经制作了一个简单的脚本来了解Bamboo如何显示成功和失败的测试。 我像这样使用py.test:

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

我的test.py文件包含这样的内容:

def test_that_fails():
    assert 1 == 2

所以它应该失败,竹子应该告诉我名为“test_that_fails”的测试实际上已经失败了。而不是它显示未发现失败的测试,可能发生编译错误。在Bamboo的“测试”选项卡上,我可以看到此版本中没有失败的测试

这是py.test生成的jUnit XML文件:

<?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>

如果构建成功,竹子会告诉我所有测试的详细信息,持续时间...... 我在Bamboo doc上搜索了所有可能的资源,在Bamboo跟踪器上,这里看不到任何有这个问题的人。

如果您有任何想法,请分享!感谢。

2 个答案:

答案 0 :(得分:9)

只是为了分享我发现的东西。 我忽略的是,如果一个失败,Bamboo会停止任务链。 因此,如果python manage.py test由于测试用例中的错误而失败,则竹子停止并且不会解析junit结果。

解决方案是将junit解析器最终作为任务放在“最终任务”部分下。

它现在就像一个魅力。

答案 1 :(得分:0)

可能与此竹问题有关,其中未找到测试结果,但它给出了您看到的错误

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

我遇到了类似的问题,通过将junit任务中的“指定自定义结果目录”框修改为更广泛的搜索模式,它开始为我工作。

我使用了** / test-results.xml