I have a test command which runs test projects and writes the result to {ProjectFolder}/TestResults/UnitTests.trx
dotnet test --logger "trx;LogFileName=UnitTests.trx"
I do have the MSTest plugin installed which converts from trx to junit format
I've also added a link to the test results using a post/always/step block as follows:
post {
always {
step ([$class: 'MSTestPublisher', testResultsFile:"**/TestResults/UnitTests.trx", failOnError: true, keepLongStdio: true])
}
}
My declarative Jenkinsfile pipeline:
pipeline {
agent any
stages {
stage('Restore') {
steps {
sh 'dotnet restore'
}
}
stage('Test') {
steps {
sh 'dotnet test --logger "trx;LogFileName=UnitTests.trx"'
}
}
stage('Build') {
steps {
sh 'dotnet build'
}
}
stage('Stop') {
steps {
sh 'sudo systemctl stop core-app.service'
}
}
stage('Deploy') {
steps {
sh 'rm -rf /var/www/core-app'
sh 'cp -R . /var/www/core-app'
}
}
stage('Start') {
steps {
sh 'sudo systemctl start core-app.service'
}
}
}
post {
always {
step ([$class: 'MSTestPublisher', testResultsFile:"**/TestResults/UnitTests.trx", failOnError: true, keepLongStdio: true])
}
}
tools {
msbuild '.NET Core 2.2.103'
}
environment {
ASPNETCORE_ENVIRONMENT = 'Production'
}
}