MSpec n Testing

A rough guide of unit and integration testing

Created by Henrik Feldt / @henrikfeldt


  1. Now - Presentation
  2. 15:30-16:30 - Programming Kata
  3. 16:30 - Summary
  4. End

How do you test?

What is Unit Testing?

What is Unit Testing?

Continuous Testing?

Continuous running of tests?

What is Unit Testing?

Testing Everything?

High Code-Coverage?

Aims of unit testing

Show that code is correct (fuzzy)

Be 'sure enough' about your code

What is integration testing?

  • Takes longer to run
  • Does not test single responsibility
  • Does not test only one class/object

What is Test Driven Development?

How does it differ from Unit Testing and Integration Testing

Which one to pick?

What about our infrastructure?

MSpec - Wat?


Machine.Specifications is a Context/Specification framework geared towards removing language noise and simplifying tests. All it asks is that you accept the =()=>.



Write a library that intercepts method calls and prints test fixtures with the calls (in C# with output in C#)

Bootstrapping code

Installing MSpec

Tools > Package Manager Console

Install-Package machine.specifications


Installing Deps

Install-Package Castle.Windsor

Hints to get you started

  • Your aim is to record calls to methods to an object
  • I have included Windsor and a factory that attaches interceptors if [RecordInteraction] is found on the registered component
  • You will probably want to register a service interface + component type in Windsor and use your debugger to see the code running when calling a method


  • What did we start with?
  • What problems surfaced along the way?


BY Henrik Feldt /