Re: NUnit Behavior

17 views
Skip to first unread message

Charlie Poole

unread,
Oct 20, 2011, 12:20:33 PM10/20/11
to Dale Ragan, nunit-...@googlegroups.com
Hi Dale,

Using the --runtime option should bypass the problem.

However, what you are doing is intended to work. Specifically, nunit-console.exe
should run under the 2.0 CLR and then launch an nunit-agent.exe process under
the 4.0 CLR. You can force this behavior with the -framework option
but that should
not be necessary provided that the test assembly has been created targetting
.NET/Mono 4.0 and also provided that the compiler has put this information into
the assembly in the first place.

As you can see, there are several points where this could go wrong and it would
be helpful to figure out just why it's happening. I'm copying this reply to the
nunit-discuss list in case others have run into the same problem.

Charlie

On Thu, Oct 20, 2011 at 8:24 AM, Dale Ragan <dale....@moncai.com> wrote:
> Hey Charlie,
>
> I just want to understand NUnit's behavior a little better and run a
> scenario by you.  I have a Test dll that is compiled for .NET/Mono 4.0 and
> I'm using the latest NUnit 2.5.10 from the website.  I'm encountering a
> TypeLoadException when running the test under Mono with the following
> command:
>
> mono --debug nunit-console.exe -nodots /path/to/tests.dll
>
> I think I know what is causing the issue, more than likely the runner isn't
> using the 4.0 runtime to run the tests, because NUnit is still outputting
> that it's using the 2.0 CLR.  My assumption, based on this page[1], was that
> NUnit would run the test under the 4.0 runtime automatically for you or do
> you still need to pass the framework option?  Also, does it help to force
> Mono to run under the 4.0 runtime by using the --runtime option, since NUnit
> is compiled to use 2.0 version of the CLR?  Here's what I plan on trying
> tonight, but I wanted to understand the underlying behavior also and whether
> I need to provide the framework option.
>
> mono --debug --runtime=v4.0.30319 nunit-console.exe  -nodots
> /path/to/tests.dll
>
> Thanks,
>
> Dale
>
> [1]:  http://nunit.org/index.php?p=runtimeSelection&r=2.5.10
>

Dale Ragan

unread,
Oct 20, 2011, 1:55:51 PM10/20/11
to nunit-...@googlegroups.com, Charlie Poole
Thanks Charlie, that's what I thought. I will give it a test again
tonight and I will let you know if it works with the --runtime or with
the -framework option. If they do, I'll give you the test case to
figure out why it's not picking up the correct CLR version from the
assembly.

Dale

Dale Ragan

unread,
Oct 20, 2011, 9:45:51 PM10/20/11
to nunit-...@googlegroups.com, Charlie Poole
The only way I can get the test to run without throwing a TypeLoadException is by providing --runtime=v4.0 to Mono.



Dale Ragan
October 20, 2011 1:55 PM

Thanks Charlie, that's what I thought.  I will give it a test again tonight and I will let you know if it works with the --runtime or with the -framework option.  If they do, I'll give you the test case to figure out why it's not picking up the correct CLR version from the assembly.

Dale



Charlie Poole
October 20, 2011 12:20 PM

Dale Ragan

unread,
Oct 20, 2011, 10:17:30 PM10/20/11
to nunit-...@googlegroups.com
Here[1] is the test that I wrote testing whether an endpoint is returning HttpStatusCode.OK using Nancy that gives this behavior.

[1]:  https://gist.github.com/1300437



Dale Ragan
October 20, 2011 9:45 PM

The only way I can get the test to run without throwing a TypeLoadException is by providing --runtime=v4.0 to Mono.

--
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.


Charlie Poole

unread,
Oct 20, 2011, 10:36:09 PM10/20/11
to nunit-...@googlegroups.com
Hi Dale,

Does the problem only show up with this particular test present or can you make it happen with a simple test that doesn't pull in any other references?

Charlie
compose-unknown-contact.jpg

Dale Ragan

unread,
Oct 20, 2011, 11:05:33 PM10/20/11
to nunit-...@googlegroups.com
Charlie Poole wrote:
> Does the problem only show up with this particular test present or can
> you make it happen with a simple test that doesn't pull in any other
> references?

I haven't tried any other way.

Charlie Poole

unread,
Oct 20, 2011, 11:30:17 PM10/20/11
to nunit-...@googlegroups.com
If it works with a simple (i.e. 2 + 2 == 4) test, that would mean
there's something
about this particular test. Could the library you're using require x86
mode, for example?

Charlie

Dale Ragan

unread,
Oct 21, 2011, 8:17:00 AM10/21/11
to nunit-...@googlegroups.com
No, I compiled it myself for all platforms.  I'm wondering now though, because I'm running on a Mac if that could be a problem.  Last I heard, only 32bit is available in Mono on a Mac.  The 64bit is experimental still.  I'll give it a try this evening using the nunitx86 console and running the tests with the command I had before and see if that works.

Dale



Charlie Poole
Thursday, October 20, 2011 11:30 PM

If it works with a simple (i.e. 2 + 2 == 4) test, that would mean
there's something
about this particular test. Could the library you're using require x86
mode, for example?

Charlie



Dale Ragan
Thursday, October 20, 2011 11:05 PM



I haven't tried any other way.



Charlie Poole
Thursday, October 20, 2011 10:36 PM

Hi Dale,


Does the problem only show up with this particular test present or can you make it happen with a simple test that doesn't pull in any other references?

Charlie



--
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.


Dale Ragan
Thursday, October 20, 2011 1:55 PM

Thanks Charlie, that's what I thought.  I will give it a test again tonight and I will let you know if it works with the --runtime or with the -framework option.  If they do, I'll give you the test case to figure out why it's not picking up the correct CLR version from the assembly.

Dale



Charlie Poole
Thursday, October 20, 2011 12:20 PM

Dale Ragan

unread,
Oct 21, 2011, 8:23:28 PM10/21/11
to nunit-...@googlegroups.com
Hey Charlie,

I tried with nunit-console-x86.exe with the original command without the
--runtime option and same results, TypeLoadException. Anything else
you'd like me to try?

Charlie Poole

unread,
Oct 21, 2011, 8:26:18 PM10/21/11
to nunit-...@googlegroups.com
Nope... I'll try a few tests of my own next.

Charlie

Dale Ragan

unread,
Oct 21, 2011, 8:33:52 PM10/21/11
to nunit-...@googlegroups.com
K, just let me know if you need anything else from me.  I'll keep looking into it myself and let you know if I find anything.

Dale

Reply all
Reply to author
Forward
0 new messages