Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

activate logging output in xamarin studio

I write UnitTests (no integration-tests with device and stuff) for monotouch and monodroid in xamarin studio with NUnit.

That works great, besides the problem that I don't see any log output created by Debug.WriteLine.

Does anybody know how to activate that in xamarin studio?

Thx!

like image 852
Ursin Brunner Avatar asked Oct 21 '22 10:10

Ursin Brunner


2 Answers

Someone had posted this answer, but removed it for whatever reason. I'm reposting it for prosperity sake...

Debug.WriteLine does not seem to work in the Xamarin Studio, but Console.WriteLine does. With this in mind, you can do the following:

#if __ANDROID__ || __IOS__
     Debug.WriteLine("My trace statement");
#else
     Console.WriteLine("My trace statement");
#end if
like image 72
Ben Bishop Avatar answered Oct 27 '22 09:10

Ben Bishop


Add this to your unit test SetUp

ConsoleTraceListener c = new ConsoleTraceListener (true);
Trace.Listeners.Add (c);

Debug.Trace() will write messages, but you need the above listener to take those messages and send them to the console.

The output appears in the Test Results, Output panel

like image 20
Dale Avatar answered Oct 27 '22 10:10

Dale