Jenkins integration for dotnet test

后端 未结 3 1613
南笙
南笙 2020-12-31 11:32

I\'m running a unit test of a dotnet core library using dotnet test. I run the test on my Jenkins slave like this.

dotnet test test/Turbine.Domain.UnitTest -         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 12:06

    You can use the following Pipeline code to run and publish the dotnet core test results:

    node {
    stage 'Checkout'
        cleanWs()
        checkout scm
    
    stage 'Build'
        bat "\"C:/Program Files/dotnet/dotnet.exe\" restore \"${workspace}/YourProject.sln\""
        bat "\"C:/Program Files/dotnet/dotnet.exe\" build \"${workspace}/YourProject.sln\""
    
    stage 'UnitTests'
        bat returnStatus: true, script: "\"C:/Program Files/dotnet/dotnet.exe\" test \"${workspace}/YourProject.sln\" --logger \"trx;LogFileName=unit_tests.xml\" --no-build"
        step([$class: 'MSTestPublisher', testResultsFile:"**/unit_tests.xml", failOnError: true, keepLongStdio: true])
    }
    

    I have uploaded some examples that I made to my GitHub for everyone to use and contribute, feel free to take a look:

    https://github.com/avrum/JenkinsFileFor.NETCore

    Those pipline jenkinsfile will add this pipline template to your build:

提交回复
热议问题