2

我正在使用Play! WebDrive模塊和作業運行正常,但當測試失敗時,Jenkins作業顯示「所有測試已通過」。我試圖在測試結果中連線,但是我一直在遇到麻煩。如何在Jenkins中執行WebDriver測試期間獲得測試結果?

我試過使用Jenkins的SeleniumHQ插件,但是會導致下面顯示的錯誤。我使用Firefox,所以我不得不測試結果位置設置爲{}的應用程序/測試結果/ FirefoxDriver/*。HTML

Publishing Selenium report... 
ERROR: No Test Report Found 
Build step 'Publish Selenium Report' changed build result to FAILURE 
Finished: FAILURE 

所以我想輸出是不是真的硒。我試圖拉動播放!插件,並沒有給出任何好的選擇。我嘗試了Play!自動測試報告構建後步驟,但僅導致顯示應用程序日誌。

最後,我嘗試使用發佈測試工具結果報告生成後步驟。這一個特別令人沮喪,因爲文檔太可怕了,Jenkins也沒有提供我可以找到的任何調試/疑難解答信息。

Custom Tool Pattern: {app}/test-result/FirefoxDriver/*.html 
Custom stylesheet: scripts/webdrive2junit.xsl 

我設置的XSL在下面,然後我始終得到的錯誤是低於該錯誤。有沒有人從webdrive獲得測試結果:測試Jenkins的工作?

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
- Hopefully we won't use this for long. I put it together to get some information 
- out of the webdrive:test results while I look for a better solution. 
--> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="child::body"> 
    <xsl:variable name="test" select="normalize-space(descendant::div/h1)"/> 
    <testsuite> 
     <xsl:attribute name="name"> 
     <xsl:value-of select="$test"/> 
     </xsl:attribute> 
     <testcase> 
     <xsl:attribute name="classname"> 
      <xsl:value-of select="$test"/> 
     </xsl:attribute> 
     <xsl:attribute name="name"> 
      <xsl:value-of select="descendant::div/div/table/thead/tr/th"/> 
     </xsl:attribute> 
     <xsl:if test="descendant::tr[@class=' status_failed']"> 
      <error /> 
     </xsl:if> 
     </testcase> 
    </testsuite> 
    </xsl:template> 
</xsl:stylesheet> 

這是我在作業日誌中得到的錯誤。

[xUnit] [INFO] - [Custom Tool] - 1 test report file(s) were found with the pattern 'src/test-result/FirefoxDriver/*.html' relative to '/opt/ci/hudson/workspace/enterprise_another-play-test' for the testing framework 'Custom Tool'. 
[xUnit] [ERROR] - Conversion error Error to convert - A file not found 
ERROR: Publisher org.jenkinsci.plugins.xunit.XUnitPublisher aborted due to exception 
hudson.util.IOException2: remote file operation failed: /opt/ci/hudson/workspace/enterprise_another-play-test at [email protected]:build-trunk-2 
... 
Caused by: com.thalesgroup.hudson.plugins.xunit.exception.XUnitException: Conversion error Error to convert - A file not found 
    at com.thalesgroup.hudson.plugins.xunit.service.XUnitConversionService.convert(XUnitConversionService.java:89) 
    at com.thalesgroup.hudson.plugins.xunit.service.XUnitTransformer.invoke(XUnitTransformer.java:135) 
    ... 11 more 
Caused by: com.thalesgroup.dtkit.util.converter.ConversionException: Error to convert - A file not found 
    at com.thalesgroup.dtkit.util.converter.ConversionService.convert(ConversionService.java:369) 
    at com.thalesgroup.dtkit.util.converter.ConversionService.convert(ConversionService.java:177) 
    at com.thalesgroup.dtkit.util.converter.ConversionService.convert(ConversionService.java:114) 
    at com.thalesgroup.dtkit.metrics.model.InputMetricXSL.convert(InputMetricXSL.java:196) 
    at com.thalesgroup.dtkit.metrics.model.InputMetricXSL.convert(InputMetricXSL.java:202) 
    at com.thalesgroup.hudson.plugins.xunit.service.XUnitConversionService.convertCustomInputMetric(XUnitConversionService.java:104) 
    at com.thalesgroup.hudson.plugins.xunit.service.XUnitConversionService.convert(XUnitConversionService.java:78) 
    ... 12 more 
Caused by: org.xml.sax.SAXParseException: The element type "meta" must be terminated by the matching end-tag "</meta>". 
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) 
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) 
    at com.thalesgroup.dtkit.util.converter.ConversionService.convert(ConversionService.java:324) 
    ... 18 more 
Finished: FAILURE 

回答

0

我目前的解決方法如下。任何改進將不勝感激。由於Play插件對我來說效果不好(因爲出現了webdrive模塊),我的構建步驟是bash腳本。

# work-around for the XUnit Plugin trouble; feel free to Tidy up 
find src/test-result/FirefoxDriver -name "*.html" -print0 | xargs -r0 -n 1 bash -c ' 
    testname=$(basename ${0%.html.*.html}); 
    xsltproc --html -o src/test-result/FirefoxDriver/TEST-$testname.xml scripts/webdrive2junit.xsl $0 
' 

我看着爲的xUnit插件詹金斯的代碼(我相信是背後的發佈測試工具結果報告後生成步驟),我意識到,這是沒有做什麼,我想。

相關問題