0
votes

I have a simple build configuration with Jenkins for a .Net Framework project. The project uses Unit Tests.

When I run the tests using VSTestRunner plugin under Jenkins, it generates test report .trx as well as .coverage file. All the tests are found and run properly but .coverage file generated is always empty (10B in size and no coverage data). I have tried to give the command as a Shell Execution command in Jenkins. But it still gives same result, i.e. empty .coverage file. Command is:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "CompletePathToLibraries.UnitTest.dll" /Enablecodecoverage /InIsolation /Framework:Framework45 /Logger:trx

But if I run the same command from outside Jenkins, i.e. a by manually launmching command prompt, it generates perfect .coverage file with expected data in it.

System config: Windows 10 Pro Jenkins 2.121.2 Visual Studio Enterprise 2017 Jenkins is installed as service and is running under NT AUTHORITY\SYSTEM account.

1

1 Answers

1
votes

I've got the same problem, and I just solve in this way: I found that Jenkins Server will execute the cmd with an user which differ to your built machine user. Therefore, I decide to change the uesr account to make it same as my built machine user account.

  1. Press win + R
  2. Input "services.msc" and press enter
  3. Find "Jenkins" service and double-click it
  4. Drive to "Log On" tab
  5. Check "This Account" radius button
  6. Input your local account and password
  7. Apply the setting
  8. Restart the Jenkins Service

Then, the problem is solved!

Hope this solution is helpful to you^^