3

My tests work just fine when executed directly with NUnit, but when executed through OpenCover (still with NUnit as the test runner), I get following errors:

ProcessModel: Default    DomainUsage: Single
Execution Runtime: Default

.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F
.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F. F.F.F.F.F.F.F.F.F.F.F.F.F.F.F
.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F
.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F.F
Tests run: 200, Errors: 0, Failures: 200, Inconclusive: 0, Time: 0,5410309 seconds
   Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

Errors and Failures:
1) SetUp Error : GeoGen.Studio.PlugInLoader.LoaderTests
   SetUp : System.MissingMethodException : Method not found: 'VoidSystem.CannotUnloadAppDomainException.SafeVisited(Int32)'.
       at GeoGen.Studio.PlugInLoader.LoaderTests..ctor()

2) Parent Failure : GeoGen.Studio.PlugInLoader.LoaderTests.AddPlugIn_ValidPlugIn_CreatesInstance
   TestFixtureSetUp failed in LoaderTests

The error 2 is repeated for every test. All the tests are supposed to pass (and they pass in NUnit). Coverage was working correctly with NCover, but its trial expired and I can't afford the license.

Thanks for your help!

Matěj Zábský
  • 16,909
  • 15
  • 69
  • 114
  • This looks like a bug with OpenCover - it can't find it's injected methods that it uses for instrumentation - please raise the issue on [github-opencover](https://github.com/sawilde/opencover) and if possible a simple repeatable test. – Shaun Wilde Mar 07 '12 at 22:33
  • I found code on Google code but no tests - is this project available for me to experiment on? – Shaun Wilde Mar 08 '12 at 22:17

2 Answers2

4

I was having the same problem - it seems you posted an issue to github that helped me solve it, so I'm posting it here for anyone else who has the same problem:

I solved the problem by upgrading to the latest OpenCover (at this time, 4.0.804) and adding the -oldStyle switch when I called OpenCover. It also seems the latest OpenCover was outputting something that ReportGenerator didn't like so I had to upgrade that too.

I have no idea what caused this failure, it seemed to come from nowhere on our CI server. Hope that helps anyone stumbling upon this issue in future.

Grokys
  • 16,228
  • 14
  • 69
  • 101
  • 1
    Yes I added the `-oldStyle` switch in response to this persons issue. For most people there will be no noticible difference unless you have some AllowPartiallyTrustedCallersAttribute. If anyone can help me replicate the issue (even in a VM) that would be a great help. – Shaun Wilde Sep 20 '12 at 01:02
  • @ShaunWilde: I will look into whether there is some sort of VM that I could get hold of for you. Not sure I will be able to though, as it's all work stuff unfortunately... – Grokys Sep 20 '12 at 11:29
  • I understand I've never been able to replicate the issue you are all seeing and unfortunately I don't have the travel budget - OSS doesn't pay well :) – Shaun Wilde Sep 20 '12 at 11:54
0

I can't tell if you are using NUnit as the test runner or not for OpenCover. Below is the batch file I use to run OpenCover with NUnit as the test runner. I use ReportGenerator to get a nice web page with all the coverage stats. You may find this useful since you said your tests run fine with the NUnit runner:

set buildOutputFolder=.\build-output
set testDllFolder=\projects\YourProject.Test\bin\Debug
set testDllName=YourProject.Test
set targetDllFilters=+[YourProject*]* -[YourProject.Test*]*

del %buildOutputFolder%\*.*
REM I use a symbolic link to point to a single folder for these tools.
REM Create the link by:
REM mklink /D OClib c:\packages\OpenCover.1.0.719
REM mklink /D RptGen c:\packages\ReportGenerator.1.2.1.0
REM mklink /D NUnitLib c:\packages\NUnit-2.5.10.11092\bin\net-2.0

OClib\OpenCover\OpenCover.Console.exe -register:user -target:"NUnitLib\nunit-console.exe" -targetargs:"/noshadow %testDllFolder%\%testDllName%.dll" -filter:"%targetDllFilters%" -output:"%buildOutputFolder%\CoverageResult.xml"
del TestResult.xml

RptGen\ReportGenerator\ReportGenerator %buildOutputFolder%\CoverageResult.xml %buildOutputFolder%
%buildOutputFolder%\index.htm
Sixto Saez
  • 12,610
  • 5
  • 43
  • 51
  • Yes, I'm using NUnit as test runner within OpenCover. I don't see any real difference between your code and mine (though I didn't get to the report phase quite yet). – Matěj Zábský Mar 07 '12 at 23:15