I’ve just kicked off a new MVC Framework application today. I’ve been considering moving to more behaviour based testing for a while now and I’ve been intrigued by Aaron Jensen’s descriptions of his MSpec (Machine Specifications) framework. So this afternoon I downloaded the build from here and got coding (just click ‘login as guest’ at the bottom).
It’s very nice. Here’s some tests for my container setup:
public class when_container_is_created
Because of = () =>
container = ContainerManager.CreateContainer();
It should_register_HomeController = () =>
It should_register_SparkViewFactory = () =>
It should_register_an_IControllerFactory = () =>
private static IWindsorContainer container;
I love the readability of the test code. Sure you have to learn to love the ‘=()=>’, but come on people, lambda syntax is hardly new any more.
When I run this using TestDriven.NET, my test runner of choice for many years now, I get this output:
when container is created
» should register HomeController
» should register SparkViewFactory
» should register an IControllerFactory
The only thing I don’t like is that the ‘It’ has gone missing which is a shame, otherwise this is just what I want from behaviour based testing framework; very low friction and easy to read output.
Well done Aaron, I’m very impressed.