2014-07-09 134 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是正確的。爲我工作。謝謝 –