Home > Testing > Machine.Specifications (mspec) testing framework support in Unit Test Runner

Machine.Specifications (mspec) testing framework support in Unit Test Runner

July 14th, 2011

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:

CodeRush Unit Test Runner options page

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:

CodeRush MSpec tests sample

(click the image to enlarge)

Clicking an test icon allows you to run or debug tests:

CodeRush MSpec test icons in the code editor

You can also see all tests inside the main Unit Test Runner window:

CodeRush MSpec Unit Test Runner window

Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Oct/29/2012
ID: C113

Similar Posts:

  1. No comments yet. Be the first and leave a comment!