Running Machine.Spec tests as part of your Xamarin development
Recently I've started to write more and more of my unit tests with Machine.Specs , for more information on Machine.Specs see their Github readme here. I much prefer it over alternatives such as NUnit as it enforces a Arrange-Act-Assert pattern within your tests, forces you to split your tests into logical classes, removes attribute clutter and makes your tests human-ly readable (useful for project managers, testers and onboarding fellow developers).
Integrating Machine.Specs into Xamarin development
So if you the above has made you see the light how do you go about introducing M.Spec tests into your Xamarin project? Xamarin Studio's Test runner is heavily linked in with NUnit so we can't use that, instead I use a combination of grunt, grunt-watch and grunt-shell to watch my dlls and re-run all tests if they ever change.
Watch keeps a watch on all files that have changed. Once a file has changed we can kick off whichever grunt tasks we like.
Shell allows for you to run command line tasks which don't have a corresponding grunt plugin themselves. So in this case we run the
Machine.Specifications.Runner.Console from within the nuget packages directory.
Your grunt file will look something like this:
Don't worry, your task will still error when a test breaks, but your tests never break right?