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: