2014-07-09 133 views
3

我使用竹作为CI服务器为我的django项目和一个好的开始,我做了一个简单的脚本,以了解如何显示成功和失败的测试竹。 我使用py.test这样的:竹失败测试不能解析junit

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

我test.py文件包含了这样的事情:

def test_that_fails(): 
    assert 1 == 2 

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

这是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跟踪器上)都无法看到任何人遇到此问题。

如果你有一些想法,请分享!谢谢。

回答

0

可能与此有关竹的问题,其中的测试结果都没有找到,但它给你看到

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

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

我用** /测试results.xml

7

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

解决的办法是将junit解析器作为最终任务放置在“最终任务”一节下。

它现在就像一个魅力。

+0

所以,我列出了我的任务,并且我的junit解析器是最后一个,但我遇到了同样的问题。我的清单是 - 命令 - >签出 - >命令(实际的构建,当它失败时,我相信它不会进入JUnit解析器)。你的工作方式是如何设置的?谢谢! – PolarisUser

+1

所以,martync是对的。但是我没有把它放在'最终任务'下,但是在正常任务 – PolarisUser

+0

的最后,martync是正确的。为我工作。谢谢 –