问题
I'm trying to get code coverage with mstest tests. I'm using PartCover 2.2.0.36424.
The problem is with real assemblies, I get 0% code coverage (Note: All tests pass).
On demo test for demo source that I created, it worked fine (the report makes sense).
I noticed that in log file:
for demo files, after line "Assembly AAAAAA loaded (MyTestesAssemblyName)", there is line "Class NNNNNN loaded (MyTestesAssemblyName.MyClassname)";
and for the real files ther is no second line (for class) after the line for assembly.
Have any ideas what is different in our assemblies? (Note: they are not signed)
10x.
回答1:
I was having the same problem. I checked fuslogvw.exe because I know mstest.exe can run your test code inside vstesthost.exe. mstest.exe was only loading my code for reflection, which is why it was showing up as 0% in the PartCover report.
To fix this, I specified the /noisolation parameter to mstest.exe through partcover.exe. However, one thing to note, it appear you have to quote all the parameters you specify to pass through to mstest.exe.
Here is the actual command line I know works:
partcover --target \path\to\MSTest.exe --include [*]* --target-args "/noisolation /testcontainer:myut.dll" --target-work-dir \path\to\workingdir --output C:\tmp\PartCoverResults.xml
回答2:
Check you have added --include [*]* commandline argument and check tests process is compiled to run on x86 (if x64 OS is used)
来源:https://stackoverflow.com/questions/1033012/why-partcover-report-shows-0-when-mstest-runs-successfully-and-all-tests-pass