Skip to content

Nunit support?

sawilde edited this page Nov 28, 2010 · 11 revisions

There also appears to be a timing issue with later versions of nunit which cause reporting to fail see the link here: http://stackoverflow.com/questions/3346954/nunit-2-5-6-partcover-2-0-4-0-my-classes-not-shown

Since Nunit version 2.5.3 it is not possible to use partcover to check the coverage of an Nunit Test,
because NUnit creates for each test a new “nunit-agent.exe” process.

NUnit 2.5.3

Would it be possible by design to attach to a running process?


It seems to work for me, with 2.5.6, using this command line (line-broken and indented for clarity; project name anonymized):

"C:\Program Files (x86)\PartCover\PartCover .NET 4.0\PartCover.exe"
      --target build\tools\nunit\nunit-console-x86.exe
      --target-args "SomeSolution.sln /noshadow"
      --include "[SomeSolution*]*"
      --output build\results\coverage.xml

—steinjak


because the profiler instruments a build it is not possible to attach to a running process as it is not possible to force a reJIT of already JIT’d methods.

I however also have no problem using partcover with the latest nunit 2.5.7

—sawilde


Did you test it with a .NET 4.0 assembly? I did some tests with the latest nunit (2.5.7) and partcover.net4 version.
If I build my assembly with .NET 4.0, only the coverage of the nunit console itself is captured. With a .NET 3.5 assembly everything is ok.
I assume that the reason is the “nunit-agent” process witch is spawned by nunit to run a test in a .NET 4.0 assembly.
Can you see this “nunit-agent” process as well?

My test settings:

"<PartCoverSettings>
  <Target>D:\Projects\ADC\Software\GeneralUtilities\NUnit\bin\nunit-console-x86.exe</Target>
  <TargetWorkDir>D:\Projects\ADC\Software\GeneralUtilities\NUnit\bin</TargetWorkDir>
  <TargetArgs>D:\Progis\VS2010Sandkasten\PartCoverTest\bin\Debug\PartCoverTest.dll /noshadow</TargetArgs>
  <Rule>+[*]*</Rule>
</PartCoverSettings>"

thanks
—amberg


Why do you use the x86 version rather then nunit-console.exe? Have you tried the /framework switch? What OS are you running?

—sawilde


Also, you could experiment with the /process=X switch; possible values for X are Single, Separate, Multiple.

—steinjak


I have found the solution.

Our assemblies are mixed mode (C++/CLI) assemblies. Such assemblies cannot be loaded into the CLR 4.0 without additional configuration settings. Nunit handles this with forcing the “process=Separate” switch.

But with some additional settings in the “nunit-console.exe.config” it is possible to load mixed mode assemblies into the CLR 4.0.

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Thanks for your support and your work on this great tool

—amberg

Clone this wiki locally