Hello All!
While trying to get a test suite running under .NET 4 with NUnit 2.5.4
I ran into a few hurdles, and figured it might be helpful for me to
share them and how I got past them here.
So on my first run of a .NET 4 assmebly, I just ran:
nunit-console.exe TestAssembly.dll
like I always have. The result was a BadImageFormat exception. I
noticed that the runtime was 2.0, so I thought maybe passing /
framework would clean things up. When I ran /framework, though, I
received the following exception:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance
of an obj
ect.
Server stack trace:
at NUnit.Util.ProcessRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Util.RemoteTestAgent.AgentRunner.Load(TestPackage package)
at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(
IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInCont
ext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(R
untimeMethodHandle md, Object[] args, Object server, Int32 methodPtr,
Boolean fE
xecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMes
sage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
req
Msg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgDa
ta, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Util.ProcessRunner.Load(TestPackage package)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
That was no good, so I started digging deeper. Tons of folks mentioned
that they had to change the nunit-console.exe.config file, but I
figured that wouldn't be required anymore since the site said there
was 4.0 support. But, after this last exception I thought it was worth
a try, so I tweaked the config file, adding:
<startup>
<requiredRuntime version="v4.0.30319" />
</startup>
to the top of the configuration section. I saved and ran ncover-
console, but without the /framework flag, thinking I wouldn't need it,
and I got the following exception:
Unhandled Exception:
System.ArgumentException: The net-4.0 framework is not available
Parameter name: framework
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)
I know I have .NET 4 installed, so I assumed that net-4.0 referred to
something similar to the net-2.0 folder in the bin folder of NUnit.
Things were starting to feel a bit hopeless. But, as one last ditch
effort, I added the /framework flag back, and:
ProcessModel: Default DomainUsage: Single
Execution Runtime: v4.0.30319
...........
Tests run: 11, Errors: 0, Failures: 0, Inconclusive: 0, Time:
3.8432198 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
Tada! It worked. So, in conclusion, for me to run with .NET 4 I had to
tweak the appropriate .exe.config file and run with the /
framework=4.0.30319 flag. Mileage may vary, but that's what worked for
me.
Alan
--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to
nunit-...@googlegroups.com.
To unsubscribe from this group, send email to
nunit-discus...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/nunit-discuss?hl=en.