Skip to content

garora/machine.specifications

 
 

Repository files navigation

Documentation

For project documentation, please visit the wiki.

Training

A PluralSight course by @kevinkuebler is available here.

Overview

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.

using Machine.Specifications;

[Subject("Authentication")]
class When_authenticating_an_admin_user
{
    static SecurityService subject;
    static UserToken user_token;

    Establish context = () => 
        subject = new SecurityService();

    Because of = () =>
        user_token = subject.Authenticate("username", "password");

    It should_indicate_the_users_role = () =>
        user_token.Role.ShouldEqual(Roles.Admin);

    It should_have_a_unique_session_id = () =>
        user_token.SessionId.ShouldNotBeNull();
}

Build status

Project CI NuGet
Machine.Specifications
Machine.Specifications.Reporting
Machine.Specifications.Runner.Console
Machine.Specifications.Runner.ReSharper
Machine.Specifications.Runner.Rider
Machine.Specifications.Runner.TDNet
Machine.Specifications.Runner.Utility
Machine.Specifications.Runner.VisualStudio
Machine.Specifications.Should
Machine.Fakes

About

Machine.Specifications is a Context/Specification framework geared towards removing language noise and simplifying tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 98.6%
  • PowerShell 1.2%
  • Batchfile 0.2%