Machine.Specifications (mspec) testing framework support in Unit Test Runner
The CodeRush Unit Test Service supports the running and debugging of testing scenarios of the Mashine.Specifications (mspec) framework.
To run or debug mspec tests, do the following steps:
- install the latest version of the MSpec framework;
- specify the path to the framework inside Test Runner options page, if it wasn’t detected automatically;
- add necessary framework assemblies to the project, such as Machine.Specifications.dll.
That’s it.
The path to the installed framework should be detected automatically. If by some reason it wasn’t, please go to the Options Dialog and manually specify it:
As you may know, the most common keywords of the framework are Subject, Establish, Because and It: declare the Subject of your spec, Establish a context of the spec, Because something occurs (the action being tested), It should do something – an assertion, which is usually the extension methods/fluent interfaces based on NUnit/xUnit Assert classes.
There are additional keywords and attributes such as Behaviours and Behaves_like for more complex scenarios. If you need to perform some cleanup, use the Cleanup keyword, which provides teardown for the specification.
Here’s the classical example shipped with MSpec, you can see test icons inside the code editor near each assertion:
(click the image to enlarge)
Clicking an test icon allows you to run or debug tests:
![]()
You can also see all tests inside the main Unit Test Runner window:

This post is a part of a series of posts about the CodeRush Unit Testing Technology. To learn more about unit testing using CodeRush, please refer to the appropriate topics:
- CodeRush Unit Testing Service overview
- Unit testing inside the code editor and the Solution Explorer
- Managing tests using the Unit Test Runner tool window
- Shortcuts and actions for running and debugging unit tests
- Unit testing service configuration and options
- Code templates for generating unit testing code
- MSpec testing framework support in the Unit Testing Service (current post)
- Silverlight testing framework support in the Unit Testing Service
- Support for XUnit, NUnit, MBUnit, and Visual Studio testing frameworks
- Unit Testing Service extensibility and programmatic management

