title: how to do unit tests to dotnet core web apps in Jenkins pipeline?
body: <p>I'm trying to run a test on built dotnet core web app but I'm unable to perform it, as the method which I tried gives error as shown below </p>
  
  <pre><code>Started by user admin
  Running in Durability level: MAX_SURVIVABILITY
  [Pipeline] node
  Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline
  [Pipeline] {
  [Pipeline] withEnv
  [Pipeline] {
  [Pipeline] stage
  [Pipeline] { (Checkout)
  [Pipeline] git
   &gt; git.exe rev-parse --is-inside-work-tree # timeout=10
  Fetching changes from the remote Git repository
   &gt; git.exe config remote.origin.url https://github.com/myrepository/mywebapp # timeout=10
  Fetching upstream changes from https://github.com/myrepository/mywebapp
   &gt; git.exe --version # timeout=10
   &gt; git.exe fetch --tags --progress https://github.com/myrepository/mywebapp+refs/heads/*:refs/remotes/origin/*
   &gt; git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
   &gt; git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
  Checking out Revision ae1432d0000a0ebsdse63sdd2dc20850dedd2a76c0643e (refs/remotes/origin/master)
   &gt; git.exe config core.sparsecheckout # timeout=10
   &gt; git.exe checkout -f ae1432d0000a0ebsdse63sdd2dc20850dedd2a76c0643e 
   &gt; git.exe branch -a -v --no-abbrev # timeout=10
   &gt; git.exe branch -D master # timeout=10
   &gt; git.exe checkout -b master ae1432d0000a0ebsdse63sdd2dc20850dedd2a76c0643e 
  Commit message: "first commit"
   &gt; git.exe rev-list --no-walk ae1432d0000a0ebsdse63sdd2dc20850dedd2a76c0643e  # timeout=10
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (Restore PACKAGES)
  [Pipeline] bat
  [jenkins Pipeline] Running batch script
  
  C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline&gt;dotnet restore  
    Restoring packages for C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\dotnetapp.csproj...
    Generating MSBuild file C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\obj\dotnetapp.csproj.nuget.g.props.
    Restore completed in 1.18 sec for C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\dotnetapp.csproj.
  [Pipeline] echo
  packages are restored
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (Clean)
  [Pipeline] bat
  [jenkins Pipeline] Running batch script
  
  C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline&gt;dotnet clean 
  Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  Build started 10/18/2018 10:07:12 AM.
       1&gt;Project "C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp.sln" on node 1 (Clean target(s)).
       1&gt;ValidateSolutionConfiguration:
           Building solution configuration "Debug|Any CPU".
       1&gt;Done Building Project "C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp.sln" (Clean target(s)).
  
  Build succeeded.
      0 Warning(s)
      0 Error(s)
  
  Time Elapsed 00:00:01.03
  [Pipeline] echo
  clean is done
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (Build)
  [Pipeline] bat
  [jenkins Pipeline] Running batch script
  
  C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline&gt;dotnet build --configuration Release 
  Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
  Copyright (C) Microsoft Corporation. All rights reserved.
  
    Restore completed in 75.52 ms for C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\dotnetapp.csproj.
    dotnetapp -&gt; C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\bin\Release\netcoreapp2.1\dotnetapp.dll
  
  Build succeeded.
      0 Warning(s)
      0 Error(s)
  
  Time Elapsed 00:00:04.36
  [Pipeline] echo
  build is done
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (Pack)
  [Pipeline] bat
  [jenkins Pipeline] Running batch script
  
  C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline&gt;dotnet pack --no-build --output nupkgs 
  Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  [Pipeline] echo
  nupkgs package is created
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (testing)
  [Pipeline] bat
  [jenkins Pipeline] Running batch script
  
  C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline&gt;"C:/Program Files/dotnet/dotnet.exe" test "C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline/dotnetapp.sln" --logger "trx;LogFileName=unit_tests.xml" --no-build 
  Test run for C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\bin\Debug\netcoreapp2.1\dotnetapp.dll(.NETCoreApp,Version=v2.1)
  Microsoft (R) Test Execution Command Line Tool Version 15.8.0
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Starting test execution, please wait...
  System.IO.FileNotFoundException: Unable to find tests for C:\Program Files (x86)\Jenkins\workspace\jenkins Pipeline\dotnetapp\bin\Debug\netcoreapp2.1\dotnetapp.dll. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate. Rerun with /diag option to diagnose further.
     at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
     at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources)
     at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
  
  Test Run Aborted.
  [Pipeline] step
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (Publish)
  Stage "Publish" skipped due to earlier failure(s)
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  java.lang.UnsupportedOperationException: no known implementation of interface jenkins.tasks.SimpleBuildStep is named MSTestPublisher
      at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:402)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:341)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:282)
      at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)....................
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:264)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:178)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      at sun.reflect.GeneratedMethodAccessor414.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
      at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
  </code></pre>
  
  <p>the script that I used is this </p>
  
  <pre><code>stage ('Restore PACKAGES') {
  steps {
  bat "dotnet restore "
  echo 'packages are restored'
  }
  }
  stage('Clean') {
  steps {
  bat 'dotnet clean'
  echo 'clean is done'
  }
  }
  stage('Build') {
  steps {
  bat 'dotnet build --configuration Release'
  echo 'build is done'
  }
  }
  stage('Pack') {
  steps {
  bat 'dotnet pack --no-build --output nupkgs'
  echo 'nupkgs package is created'
  }
  }
  stage('testing') {
  steps {
    bat returnStatus: true, script: "\"C:/Program Files/dotnet/dotnet.exe\" test \"${workspace}/dotnetapp.sln\" --logger \"trx;LogFileName=unit_tests.xml\" --no-build"
      step([$class: 'MSTestPublisher', testResultsFile:"**/unit_tests.xml", failOnError: true, keepLongStdio: true])
  
  }
    }
  </code></pre>
  
  <p>so how can I do testing for the build app ? are there any other way which I can try than this ?  I refered this solution <a href="https://stackoverflow.com/questions/43284881/jenkins-integration-for-dotnet-test">Jenkins integration for dotnet test</a> any suggestion and articles will be very  helpful thanks.</p>