1
votes

I have a TFS 2015 build which builds one of our applications (it's an ASP.NET Web API application). As part of the build process it runs our unit tests.

I have a Visual Studio Test build step which runs these unit tests and they all pass okay.

I then run dotCover from this same build to determine code coverage (no we don't use the built-in code coverage as we don't have enterprise licences). However, when run from dotCover all the same unit tests fail.

I use a script step to run a batch file which invokes dotCover as follows.

E:\JetBrains\Installations\dotCover05\dotCover.exe analyse coverage.xml /LogFile=dotcover.log

The dotCover log file doesn't seem to give any indications as to why the unit tests have failed.

Any ideas why the unit tests pass when run from the Visual Studio Test build step and then fail when run from dotCover?

3
Which build system are you using? XAML or vNext? I'd like to reproduce this issue at my side.Eddie Chen - MSFT
I'm using vNextDomBurf
Can not reproduce the issue, can you check the settings in your coverage.xml?Eddie Chen - MSFT
The settings in my coverage.xml file are used on another build without a problem. It's only this particular build that is causing problems.DomBurf
It seems that the problem is related to the fact that that my build uses an XML file to hold certain values. This XML file is found by VSTest when run under TFS but not by dotCover. When dotCover runs it creates a TestResults folder which it copies all the necessary files required to run the tests. All files are copied except the XML file. I have set the file to "Copy to output folder" so can't understand why this file isn't copied. I tried copying the file manually as a batch file but the folder structure is created by dotCover so it doesn't exist until I actually run the code coverage.DomBurf

3 Answers

2
votes

It seems that the problem is related to the fact that my build uses an XML file to hold certain data values. This XML file is found by VSTest when run under TFS but not by dotCover.

When dotCover runs it creates a TestResults folder which it then copies all the necessary files to required to run the unit tests. All files are copied except the XML file. I have set the file to "Copy always" so can't understand why this file isn't copied. I tried copying the file manually as a batch file but the folder structure is created by dotCover so it doesn't exist until I actually run the code coverage.

The solution is to decorate my test classes with the DeploymentItem() attribute.

[TestClass]
[DeploymentItem("File.xml")]

This has resolved my problem.

1
votes

Make sure your build service account have enough permission to run the dotcove.exe. According to your E:\JetBrains\Installations\dotCover05\dotCover.exe Seems you didn't install for all users on the build agent. Which should installed under %ProgramFiles(x86)% not %LOCALAPPDATA%\JetBrains\Installations.

enter image description here

Try to use CoreInstructionSet parameter in your dotCover as a workaround for your situation. Details see below picture. enter image description here

After doing this try to run the build again.

enter image description here