Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit components for version 4.0.30319 of the CLR are not installed

Tags:

nunit

I am trying to implement an automated build process. After the build, the unit tests on nunit-console.exe are run. The following error is displayed:

> c:\nunit_2.5.10\nunit-console.exe c:\builds\Output\bin\TDD.nunit /framework=4.0.30319 /nologo /trace=Off
ProcessModel: Default    DomainUsage: Default
Execution Runtime: v4.0.30319
Unhandled Exception:
System.ArgumentException: NUnit components for version 4.0.30319 of the CLR are not installed
Parameter name: targetRuntime
   at NUnit.Util.TestAgency.LaunchAgentProcess(RuntimeFramework targetRuntime, Boolean enableDebug)
   at NUnit.Util.TestAgency.CreateRemoteAgent(RuntimeFramework framework, Int32 waitTime, Boolean enableDebug)
   at NUnit.Util.TestAgency.GetAgent(RuntimeFramework framework, Int32 waitTime, Boolean enableDebug)
   at NUnit.Util.ProcessRunner.Load(TestPackage package)
   at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
   at NUnit.ConsoleRunner.Runner.Main(String[] args)

There is no nunit-agent.exe on the build machine. However, on my machine it is not even called, so I suppose it is not necessary.

Why is nunit-agent.exe required in some cases but not always required? What conditions should be satisfied so nunit-agent would not need to launch?

Edit: I have found one resource, which kind of describes how it works, but not quite well: http://www.nunit.org/index.php?p=nunit-agent&r=2.5.10. It says that it is launched when program needs to run under a different framework than the one being used by NUnit (which is the case, since NUnit is compiled for 2.0). However, on my machine the nunit-agent.exe does not run although conditions seem to be the same.

like image 281
paulius_l Avatar asked Aug 23 '12 12:08

paulius_l


2 Answers

I ran into this same error and it was definitely solved by including nunit-agent.exe in the folder where nunit-console.exe was launched. The complete list of .exes and .dlls necessary to run a test successfully was:

nunit.core.dll
nunit.core.interfaces.dll
nunit.framework.dll
nunit.util.dll
nunit-agent.exe
nunit-console.exe
nunit-console-runner.dll

All files are packaged in the download available from nunit.org. As of this post, 2.6.3 is the current version. Documentation for the console runner can be found here. And the direct download for the zip file is here.

For a test assembly targeting .NET 4.5.1, the following statement will execute tests:

nunit-console.exe your-assembly.dll /framework=v4.5.1
like image 70
David Peden Avatar answered Oct 05 '22 20:10

David Peden


Adding a "startup/supportedRuntime" configuration tag to nunit-console.exe.config solved it for me.

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319" />
</startup>
like image 21
Jorge Paulo Avatar answered Oct 05 '22 21:10

Jorge Paulo