Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCover generates an empty report

I am using OpenCover to determine code coverage for a simple C# project.

The problem

Although I can see MSTest running the unit tests (and succeeding) the generated report is empty.

Details

This is the command I am using:

opencover.console.exe -register -arch:32 
                      -target:"%VSINSTALLDIR%\Common7\IDE\mstest.exe"
                      -targetargs:"/testcontainer:calculatortest.dll"
                      -filter:+[calculator.dll]* -output:coverage.xml

The output

Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.

Loading calculatortest.dll...
Starting execution...

Results               Top Level Tests
-------               ---------------
Passed                CalculatorTest.StatisticsTest.AddOccurrenceTest
Passed                CalculatorTest.StatisticsTest.AvgTest
2/2 test(s) Passed

Summary
-------
Test Run Completed.
  Passed  2
  ---------
  Total   2
Results file:  e:\Users\erno\Documents\Visual Studio 2010\Projects\CodeStatistics\CalculatorTest\bin\Debug\TestResults\erno_ERNO01 2011-07-01 14_27_06.trx
Test Settings: Default Test Settings
Visited Classes 0 of 0 (NaN)
Visited Methods 0 of 0 (NaN)
Visited Points 0 of 0 (NaN)

The content of the generated report:

<?xml version="1.0" encoding="utf-8"?>
<CoverageSession xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <VisitPoints />
</CoverageSession>

Environment

The code is running on Windows 7 64-bits but is executed in a 32-bit Visual Studio command prompt environment.

EDIT I am running the command in the directory with the debug build of the unit tests and I added the OpenCover directory to the environment path.

What I tried

I searched for similar problems with PartCover (because OpenCover appears to be a sort of branch) but could not find anything that matched the problem and presented a solution.

EDIT I also tested with a broader filter -filter:+[*]* but this did not change the output in any way.

EDIT I also tested with the MSTest /noisolation argument as mentioned here. Still no results.

EDIT I also tested by removing the filter completely and falling back to the default filter. No results.

like image 633
Emond Avatar asked Jul 01 '11 12:07

Emond


1 Answers

You should be able to use the -register:user switch to do per user registration i.e. it registers (and unregisters) without needing full admin rights.

like image 106
Shaun Wilde Avatar answered Nov 10 '22 01:11

Shaun Wilde