1
votes

I'm using OpenCover with Visual Studio2010 professional. It works well with NUnit on a command-line.

OpenCover.Console.exe -register:user -target:"C:\bin\NUnit 2.6\bin\nunit-console.exe" -targetargs:"C:\App\Test\ApplicationTest\bin\Debug\ApplicationTest.dll"  -targetdir:"C:\App\bin\Debug" -output:html\result.xml

The result is below.

NUnit-Console version 2.6.0.12051 Copyright (C) 2002-20011 Charlie
Poole. Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two,
Alexei A. Vorontsov. Copyright (C) 2000-2002 Philip Craig. All Rights
Reserved.

Runtime Environment - OS Version: Microsoft Windows NT 6.1.7601
Service Pack 1 CLR Version: 4.0.30319.269 ( Net 4.0 )

ProcessModel: Default DomainUsage: Single Execution Runtime:
net-4.0 .. Tests run: 2, Errors: 0, Failures: 0, Inconclusive: 0,
Time: 42.14 seconds Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

Committing... Visited Classes 59 of 175 (33.7142857142857) Visited
Methods 268 of 4131 (6.48753328491891) Visited Points 15137 of 71763
(21.0930423755975) Visited Branches 196 of 8025 (2.44236760124611)

==== Alternative Results (includes all methods including those without
correspon ding source) ==== Alternative Visited Classes 59 of 207
(28.5024154589372) Alternative Visited Methods 284 of 4371
(6.49736902310684)

However it doesn't work with Microsoft.Moles.

OpenCover.Console.exe -register:user -target:"C:\Program Files\Microsoft Moles\bin\moles.runner.x86.exe" -targetargs:"""C:\App\Test\ApplicationTest\bin\Debug\ApplicationTest.dll""  /r:""C:\bin\NUnit 2.6\bin\nunit-console.exe""" -targetdir:"C:\App\bin\Debug" -output:html\result.xml

This result is below.

Microsoft Moles Runner v0.94.51023.0 --
http://research.microsoft.com/moles -- . NET v4.0.30319 Copyright (c)
Microsoft Corporation 2007-2010. All rights reserved.

instrumenting...started
NUnit-Console version 2.6.0.12051
CLR Version: 4.0.30319.269 ( Net 4.0 )

ProcessModel: Default DomainUsage: Single Execution Runtime:
net-4.0 .. Tests run: 2, Errors: 0, Failures: 0, Inconclusive: 0,
Time: 28.004 seconds Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

Committing... Visited Classes 0 of 2 (0) Visited Methods 0 of 14 (0)
Visited Points 0 of 45 (0) Visited Branches 0 of 2 (0)

==== Alternative Results (includes all methods including those without correspon ding
source) ==== Alternative Visited Classes 0 of 2 (0)
Alternative Visited Methods 0 of 16 (0)

The result of tests are both correct but no coverage is there.

I tried to change the argument of moles, example '/args:"/domain=Multiple"', -oldType etc, but it never works.

Does anyone notice me what I should do? Can OpenCover use moles with Nunit?

1
I solved the problem by myself. At first, adding below. set CLRMONITOR_EXTERNAL_PROFILERS={1542C21D-80C3-45E6-A56C-A9C1E4BEB7B8} s135.codeinspot.com/q/2342744axt_star
And I knew NUnit version is more important. v2.5.2 is worked properly. but v2.6 isn't.axt_star
this has been discussed in previous stackoverflow questions stackoverflow.com/questions/7013990/… - the issue here is that moles is also a rewriting profiler and so the two clash - however you can inform moles that it needs to 'chain' to opencover (or any other profiler) so that the two will work in syncShaun Wilde
I greatly appreciate your comment.axt_star

1 Answers

1
votes

I solved the problem by myself. At first, adding the below code into the batch file or set it as command-line command.

set CLRMONITOR_EXTERNAL_PROFILERS={1542C21D-80C3-45E6-A56C-A9C1E4BEB7B8}

This link may be helpful. http://s135.codeinspot.com/q/2342744