2011-01-09 67 views
1

我試圖使用xUnit插件將我的PHPUnit測試集成到Hudson中。一個全成之後建立與螞蟻在哈德森,控制檯輸出顯示:Hudson CI和PHPUnit:沒有任何測試報告包含任何結果

記錄測試結果
無的測試報告包含的任何結果

我使用junit.xml測試輸出PHPUnit的--log-的JUnit看起來如下:

<testsuites> 
    <testsuite name="Unit Tests" tests="1" assertions="1" failures="0" errors="0" time="0.005112"> 
    <testsuite name="DbTest" file="src/tests/unit/DbTest.php" tests="1" assertions="1" failures="0" errors="0" time="0.005112"> 
    <testcase name="testConnection" class="DbTest" file="src/tests/unit/DbTest.php" line="4" assertions="1" time="0.005112"/> 
    </testsuite> 
    </testsuite> 
</testsuites> 

任何幫助理解

編輯: 我剛創建包含測試junit.xml:

<testsuites> 
    <testsuite name="DbTest" file="src/tests/unit/DbTest.php" tests="1" assertions="1" failures="0" errors="0" time="0.005112"> 
    <testcase name="testConnection" class="DbTest" file="src/tests/unit/DbTest.php" line="4" assertions="1" time="0.005112"/> 
    </testsuite> 
</testsuites> 

有了這個,構建成功了。問題似乎是嵌套標籤。任何想法如何防止PHPUnit創建這些嵌套標籤?

回答

3

我終於在How might I integrate phpunit with Hudson CI?找到了解決方案,使用了xslt解決方法。

如果任何人有同樣的問題:創建一個新的.xsl文件下的項目根的任何地方:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/"> 
    <xsl:element name="testsuites"> 
     <xsl:for-each select="//testsuite[@file]"> 
       <xsl:copy-of select="." /> 
     </xsl:for-each> 
    </xsl:element> 
</xsl:template> 
</xsl:stylesheet> 

然後添加到您的build.xml(不要忘了在構建目標包括):

<target name="phpunit_to_xunit"> 
    <xslt in="build/logs/phpunit.xml" out="build/logs/junit.xml" style="phpunit_to_xunit.xsl"/> 
</target> 

無論如何,這是某種麻煩。因此我已經爲xUnit項目創建了一個改進建議。

+0

感謝您分享您的解決方案! +1 – edorian 2011-01-10 15:51:09