1

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 (
                       ^
Jose
  • 1,333
  • 5
  • 20
  • 38
  • I had to do this a little differently - solution here - https://stackoverflow.com/a/60284044/9423651 – AngryDaz Feb 18 '20 at 15:24

3 Answers3

1

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.

Kristian
  • 467
  • 3
  • 7
0

I had to do it a little differently with the plugin so I'm posting my solution in case it helps -

xunit(
    [MSTest(deleteOutputFiles: true,
            failIfNotNew: true,
            pattern: '*.trx',
            skipNoTestFiles: false,
            stopProcessingIfError: true)
    ])

Note, this expects that your trx files are in the root of your workspace. If they aren't you'll need to copy them into there.

AngryDaz
  • 71
  • 5
0

Is there a reason to use xunit-plugin? I use the mstest-plugin as follows and this seem to work fine

mstest testResultsFile:"**/*.trx", keepLongStdio: true

Test Result Trend

papanito
  • 2,349
  • 2
  • 32
  • 60
  • With this command, i get this error `[MSTEST-PLUGIN] INFO processing test results in file(s) **/*.trx`. I thought perhaps MSTest is looking at wrong location. Then i gave the absolute path to the trx file, now it shows `SEVERE while listing workspace files: Expecting Ant GLOB pattern, but saw '/home/myuser/build/newapp-math/testResult.trx'`. Any iea what might be the issue ? i am using Xunit for unit testing. – Mayur Buragohain Apr 22 '21 at 17:11