Closed ComptonAlvaro closed 7 years ago
@ComptonAlvaro
1) are you producing PDB files for your main assembly? This is required for instrumentation.
2) are you tests calling anything in your main assembly at the moment? If the code is not loaded it cannot be instrumented and covered.
3) MSTest will copy files about but not their PDBs so you may want to try the /noisolation
switch when executing MSTest
@ComptonAlvaro I didn't get a response - is this issue still outstanding?
I suspect resolved in #721
First off, thanks for making and maintaining this! 💯
I am getting this problem. I am using visual studio 2019 (.net framework 4.7.2) in windows 10 with MSTest package.
I have two projects, one for my application (called Project) and another one for test (called tests). I am using a batch a file in the root fo the solution to run the OpenCover. To get this to work, I followed Allen Conway's blog post.
The following is my bat
file function to generate the outputs
:RunOpenCoverUnitTestMetrics
"%~dp0packages\OpenCover.4.7.922\tools\OpenCover.Console.exe" ^
-register:user ^
-target:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\mstest.exe" ^
-targetargs:"/testcontainer:\"%~dp0tests\bin\Debug\tests.dll\" /resultsfile:\"%~dp0Project.trx\"" ^
-searchdirs:"%~dp0Project\bin\Debug" ^
-filter:"+[Project*]* -[tests]*" ^
-mergebyhash ^
-skipautoprops ^
-output:"%~dp0\GeneratedReports\ProjectReport.xml"
exit /b %errorlevel%
As you can see I tried using the searchdirs
keyword to include my Project bin folder. I also tried using the /noshadow
and /noisolation
option in targetargs
; that did not work. With the above settings, my report consists of a list of system modules which are skipped. If I remove the filter
keyword from the call to OpenCover, I only get the test classes in my Report.
Without seeing the output nor the test structure it is hard to diagnose these things
Hi i am facing same issue mentioned here, any work around for this.
I have a solution with two projects, one is the main application and the other project is for test the main project. It is because I want to have one assembly for the application and other assembly for the tests, in this way I avoid to include the tests classes in the main assembly because the final assembly that i will release to the clients doesn't need to include the tests classes.
Well, I am trying this command to test my C# application, and the tests are using MSTest. This two commands are in a .bat file:
The problem is that in the report that I get I have only the coverage of the assembly MyAssemblyTest.dll, not the MainAssembly.dll that has the methods that MyAssemblyTests.dll is testing. So the coverage is of the test methods, no the main methods.
How I could get the coverage of the methods in my MainAssembly.dll?
Thanks.