Machine.Specifications is a Context/Specification framework geared towards removing language noise and simplifying tests.
C# XSLT Other
Clone or download
Latest commit 5437790 Oct 11, 2017
ivanz Merge pull request #344 from robertcoltheart/feature/add-behavior-spe…

[Feature] Track behavior field from context in behavior spec

Build status Travis Gitter


The documentation is here:


There is a course made by @kevinkuebler - you can find it here:



MSpec is called a "context/specification" test framework because of the "grammar" that is used in describing and coding the tests or "specs". That grammar reads roughly like this

When the system is in such a state, and a certain action occurs, it should do such-and-such or be in some end state.

You should be able to see the components of the traditional Arrange-Act-Assert model in there. To support readability and remove as much "noise" as possible, MSpec eschews the traditional attribute-on-method model of test construction. It instead uses custom .NET delegates that you assign anonymous methods and asks you to name them following a certain convention.

public class When_authenticating_an_admin_user
    Establish context = () => {
        Subject = new SecurityService();

    Because of = () => {
        Token = Subject.Authenticate("username", "password");

    It should_indicate_the_users_role = () => {

    It should_have_a_unique_session_id = () => {

    static SecurityService Subject;
    static UserToken Token;