首页 文章

竹子失败测试无法解析junit

提问于
浏览
5

我正在使用竹子作为我的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"的测试实际上已经失败了 . 而不是它显示 No failed tests found, a possible compilation error occurred . 在Bamboo的"Tests"标签上,我可以看到 There were no failed tests in this build .

这是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将向我显示所有测试的详细信息,持续时间......我在Bamboo doc上搜索了所有可能的资源,在Bamboo跟踪器上,在这里,看不到任何有这个问题的人 .

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

2 回答

  • 0

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

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

    它现在就像一个魅力 .

  • 9

    可能与这个竹子问题有关,在那里没有找到测试结果,但它给出了你看到的错误

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

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

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

相关问题