簡體   English   中英

Jenkins - 顯示失敗測試的名稱 TestNG

[英]Jenkins - Display names of failed tests TestNG

在我的 Jenkinsfile 中,我將所有測試結果計算為

AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
    if (testResultAction != null) {
        def total = testResultAction.totalCount
        def failed = testResultAction.failCount
        def skipped = testResultAction.skipCount
        def passed = total - failed - skipped

但我也想顯示松弛消息的所有失敗測試的名稱。 到目前為止,我已經嘗試使用def failedTests = testResultAction.getResult().getFailedTests()生成它,但它返回的不是像hudson.tasks.junit.CaseResult@37e0fb97這樣的特定名稱。 無論如何要顯示測試的全名嗎? 我正在使用 Selenium + TestNG。

您可以使用.getTitle()方法獲取描述:

def failedTests = testResultAction.getResult().getFailedTests().collect { it.getTitle() }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM