In my project, I use Nunit 2 framework. In the build server, I use Open Cover 4.6.519 to analyze the code coverage with the following command:
"OpenCover.4.6.519\OpenCover.Console.exe"
-target:"..\..\Packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe"
-targetargs:"/nologo /framework:net-4.0 /process:multiple /domain:multiple /noshadow /nothread <the_list_of_test_assemblies>"
-filter:"+[*]* -[*.Test]* -[*.Stub]* -[Deedle]* -[FSharp]*" -hideskipped:Filter -register -output:Build\OpenCoverResult.xml`
This is the result I get:
Executing: D:\Jenkins\workspace\SC Nightly\Packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe
ProcessModel: Multiple DomainUsage: Multiple
Execution Runtime: net-4.0
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at NUnit.Core.ProxyTestRunner.CountTestCases(ITestFilter filter)
at NUnit.Util.AggregatingTestRunner.CountTestCases(ITestFilter filter)
at NUnit.Util.AggregatingTestRunner.Run(EventListener listener, ITestFilter filter, Boolean tracing, LoggingThreshold logLevel)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
Committing...
Visited Classes 0 of 617 (0)
Visited Methods 0 of 4030 (0)
Visited Points 0 of 11734 (0)
Visited Branches 0 of 6814 (0)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 671 (0)
Alternative Visited Methods 0 of 4663 (0)
I see an null reference exception thrown by Nunit runner, but it seems that OpenCover hangs after Nunit runner stopped.
I am thinking of some potential reasons:
The amount of test assemblies is large (59 dll files)
The assemblies are built in .Net Framework 4.5, but the framework argument of Nunit runner is net-4.0
I am using Nunit 2 which is out of date. (It is very expensive for me to upgrade to Nunit 3)
There might be something wrong with my Jenkins. I use Jenkins to run an .msbuildproj file which containing a task to execute OpenCover. When I run OpenCover command on Windows Command Prompt, it works well.