2017-05-23 51 views
1

我想使用聚合物-cli將我們的聚合物測試構建過程整合到Jenkins CI/CD管道中。我想自動執行這些步驟來構建我們的Web組件測試用例。目前,我正在通過在終端上執行「聚合物測試」手動執行此操作。我還希望自動化過程提供指示失敗測試用例的報告。如果您在CI/CD管道中實施了此步驟,請提供步驟。將聚合物測試構建過程集成到Jenkins CI/CD管道中

回答

0

我們有以下工作設置這種情況下,使用Jenkins2管道:

node{   
.... 
    stage('build'){ 
    testresult = bat returnStatus: true, script: 'polymer test --plugin xunit-reporter -l chrome' 
    step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '5', failureThreshold: '10', unstableNewThreshold: '2', unstableThreshold: '5'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'XUnitDotNetTestType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'TEST-wct.xml', skipNoTestFiles: false, stopProcessingIfError: true]]]) 

    if (testresult != 0) { 
     currentBuild.result = "UNSTABLE" 
     echo "ALERT: Some Unittests failed, see log above." 
    } 
    } 
.... 
} 

的TestResult中由WCT-插件https://github.com/garcus/wct-xunit-reporter爲 「/TEST-wct.xml」 寫的。 XUnit Builder步驟是這樣配置的,即它選擇該文件並創建testresult頁面。你可以在Jenkins Pipeline語法幫助頁面查找它的語法。

又見How to display the XUnit test output on JenkinsJUnit formatted test output