Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit/Mono not printing stack trace line number even with --debug

Ok, here's the thing, using Xamarin on OS X

(the .cs file is a very simple test case that causes a backtrace)

Compiling

mcs /debug /lib:~(...)NUnit-2.6.3/bin/framework/:~(...)NUnit-2.6.3/bin/lib/ -r:nunit.framework.dll test.cs 

Running

mono --debug /Users/thiago/qm/nunit/NUnit-2.6.3/bin/nunit-console.exe test.exe

The result

1) Test Error : TestOne.testFirst
System.NullReferenceException : Object reference not set to an instance of an object
at TestOne.testFirst () [0x00000] in <filename unknown>:0 
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke    (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr,     System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

If I use the provided nunit-console from Xamarin it works however, it does not work with several libs, etc, (for example: Monitor and some other ones)

Running only mono test.cs (causing a stacktrace) shows the corresponding line numbers.

like image 629
thiagogalesi Avatar asked Mar 25 '14 14:03

thiagogalesi


1 Answers

What solved the issue for me was the option

-runtime=v4.0

(or the corresponding one to your case)

like image 76
thiagogalesi Avatar answered Oct 02 '22 02:10

thiagogalesi