Let Mighty Moose open failed tests in MonoDevelop
April 23, 2012
Posted by on
A few days ago I blogged about how to use Mighty Moose in Ubuntu, and provided a guide on how you could continuously run your SpecFlow/NUnit tests while working in MonoDevelop. If you have not read that post you may want to check it out first, as it is a prerequisite to this one. You can find it here. While writing that post, there was this one thing that I left out on purpose, as it was not really necessary to get everything working. But, it is a nice feature to have, so I thought I would make a quick post and show you how to configure it.
Take a look at this screenshot. A test failed! I have marked it and I clicked the Test output link. You will notice that Mighty Moose correctly displays the reason as to why our test failed, but there is not much information in the stack trace.
To get Mighty Moose to display more information in the stack trace of a failed test, we need to configure nunit-console to hand out more information while running our tests. To do this, we can edit /usr/bin/nunit-console file and add a debug parameter. It should look something like this:
exec /usr/bin/cli --debug /usr/lib/nunit/nunit-console.exe "$@"
If we restart everything and run the tests again, then click on the Test output link, we will now see that Mighty Moose have more information in the stack trace, and most important, we can see the file and the line number that failed our test.
Now that our stack trace includes a file and a line number, we can tell Mighty Moose to use that information together with MonoDevelop. Just add the following few lines to your AutoTest.config under ~/.local/share/MightyMoose/ and then restart everything.
Now, double-click a failed test in Mighty Moose and it will automatically open the code file in MonoDevelop, and put the cursor on the line that failed the test. Enjoy!