开发者

OpenCover generates an empty report

开发者 https://www.devze.com 2023-03-17 03:59 出处:网络
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.

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 t开发者_运维技巧est(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.


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.


After taking a break my mind cleared and I suspected the COM registration that is done by OpenCover so I checked the eventlog.

Indeed the COM registration was failing. So I decided to try and run the command prompt as administrator suspecting I was being hindered by UAC

Running the command including the /noisolation flag hangs the process.

Without this flag the report is generated and correctly filled.

I think I will register the COM dll permanently so I can run OpenCover using any credentials that I prefer.

Another thing I might do is add an issue on the OpenCover site stating that it is swallowing an exception. (Unless Shaun Wilde reads this and beats me to it)


I had a similar issue using NUnit 2.6 on Windows XP. Every report was blank until I added the magical register:user flag. @Shaun-Wilde, what does this flag exactly do?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号