Debugging xUnit tests in Xamarin Studio and Mono Develop using The Debugging Trick™

Update: This post has been completely revamped, as it turns out there is much easier way, kudos to Michael for pointing this out. I will lament my image editing skills for a small second :-)

As I mentioned in my recent post on the Splunk blog, we’ve been developing a new awesome portable C# SDK that will support Xamarin/Mono.  We ran into a bunch of issues running on Linux with tests failing due to file paths and supporting pct-encoded URIs, so I decided to try to debug in Xamarin Studio.

I had really hoped this would be easy. It wasn’t as easy I hoped, but it turns out after a bunch of trial and error that there is a pretty simple path.  Xamarin Studio does have a “Debug Application” option, but running that all I could do was run the xUnit console runner, but I couldn’t pass it any parameters. I tried various things for a while and came up empty.

And then I decided to tweet the always helpful Michael Hutchinson to see if he had any ideas, and he did!


Update: It turns out you don’t need to do what is suggested above, and which the first version of this post recommended. 

Read on my friends to find out what you can do…..

First open Xamarin Studio to your test project. You can see I’ve done this below and I’ve added a breakpoint on the completely ridiculous, ficticious test we want to debug.

test project1

Now right click on the project, then select Options->Run->Custom Commands. Next a select Execute in the drop down. And put the following into the Command box.

“/Users/glennblock/xunit/xunit.console.clr4.exe ${TargetFile}”


The first part points to the location of the xunit console runner. The second is an expansion which will get replaced with the test dll.

Now all you have to do is run!



And that my friends is “The Debugging Trick™“!

Side note, I don’t think anyone should have to do this, though this version is far less painful than my first post. I just found out from Michael great news, that there is proper IDE support for xUnit in the works.

Screen Shot 2014-05-14 at 11.29.01 PM

This is very good news! In the meanwhile you have the trick :-).

As a side note this technique is general useful for beyond unit tests, you can use it to debug any managed exe where you need to pass arguments.

Thank you Michael Hutchinson for the help!

This entry was posted in mono, xamarin. Bookmark the permalink. Follow any comments here with the RSS feed for this post.