jenkinsjenkins-pluginsjenkins-pipelinexunitjenkins-mstest

MSTest .trx file display using Xunit Plugin and Jenkins Piepline


I'm trying to display MStest, Nunit3, Nunit2 results using Xunit Plugin and using Jenkins pipeline and have not been successful with the same. I can't find proper documentation for the Xunit Plugin and all the various required parameters for the same.

I got the following links but they don't help much https://www.cloudbees.com/blog/xunit-and-pipeline https://wiki.jenkins.io/display/JENKINS/xUnit+Plugin

Does anyone know how to use the Xunit Plugin for displaying mstest, nunit3 and nunit2 results in jenkins pipeline?

Following is the code I used for MStest report parsing and got errors. I'm pretty new to pipelines in Jenkins and any help / pointers are greatly appreciated! Thanks in advance!!

Following is my pipeline code

pipeline {
    agent any
    stages {
        stage('Copy Test Reports') {
            agent {
                node {
                    label 'test'
                    customWorkspace "C:\\jenkins\\workspace\\tests"
                }
            }
            steps {
                echo 'Hello world!'
                bat '''copy \\\\Precheck.xml .
                copy \\\\*.trx .'''
            }
            post {
                always {
                    xunit (
                        thresholds: [$class: 'FailedThreshold', unstableThreshold: '1'],
                        tools: [$class: 'MSTest', pattern: '*.trx']
                    )
                }
            }
        }        
    }
}


Error:
Missing required parameter: "thresholdMode" @ line 19, column 21.
                       xunit (
                       ^

WorkflowScript: 19: Missing required parameter: "testTimeMargin" @ line 19, column 21.
                       xunit (
                       ^

Solution

  • I ran into the same issue, though with GoogleTest reports. Adding the missing parameters to your xunit() call should do the trick:

                    xunit (
                        testTimeMargin: '3000',
                        thresholdMode: 1,
                        thresholds: [$class: 'FailedThreshold', unstableThreshold: '1'],
                        tools: [$class: 'MSTest', pattern: '*.trx']
                    )
    

    '3000' and '1' being the defaults the xunit-plugin has set internally.