NUnit/Mono甚至不使用--debug打印堆栈跟踪行号

thi*_*esi 7 c# mono nunit nunit-console

好的,这就是在OS X上使用Xamarin的事情

(.cs文件是一个非常简单的导致回溯的测试用例)

编译

mcs /debug /lib:~(...)NUnit-2.6.3/bin/framework/:~(...)NUnit-2.6.3/bin/lib/ -r:nunit.framework.dll test.cs 
Run Code Online (Sandbox Code Playgroud)

运行

mono --debug /Users/thiago/qm/nunit/NUnit-2.6.3/bin/nunit-console.exe test.exe
Run Code Online (Sandbox Code Playgroud)

结果

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 
Run Code Online (Sandbox Code Playgroud)

如果我使用Xamarin提供的nunit-console,它可以工作,它不适用于几个库等(例如:Monitor和其他一些)

仅运行mono test.cs(导致堆栈跟踪)显示相应的行号.

thi*_*esi 2

为我解决问题的是选项

-runtime=v4.0
Run Code Online (Sandbox Code Playgroud)

(或与您的情况相对应的)