python - Bamboo 失败测试无法解析 junit

标签 python testing junit bamboo

我正在使用 bamboo 作为我的 django 项目的 CI 服务器,为了一个好的开始,我制作了一个简单的脚本来了解 bamboo 如何显示成功和失败的测试。 我像这样使用 py.test :

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

我的 test.py 文件包含如下内容:

def test_that_fails():
    assert 1 == 2

所以它应该会失败,而 bamboo 应该会告诉我名为“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 将向我显示所有测试的详细信息、持续时间... 我已经在 Bamboo doc 和 Bamboo tracker 上搜索了所有可能的资源,在这里,看不到任何人有这个问题。

如果你有什么想法,请分享!谢谢。

最佳答案

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

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

它现在就像一个魅力。

关于python - Bamboo 失败测试无法解析 junit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24657958/

相关文章:

javascript - 结果呈指数增长的测试场景

java - 递归期间堆栈溢出

testing - 是否可以通过 Yandex 测试使用 Gemini 的滚动?

javascript - 需要帮助在 Protractor 中使用 for 循环和 getText()

python - 展开 python pandas 数据框中的行

python - 列表有问题?

java - 初学者 ADT 和 JUnit 4

java - 仅验证少数元素的单元测试

python - 你如何检查传递给函数的任何参数是否为 None?

java - 使用 .toPandas() 函数时如何修复 Py4JJavaError?