MSpec is called a "context/specification" test framework because of the "grammar" that is used in describing and coding the tests or "specs". The 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. Instead it uses custom 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(); }
Install-Package Machine.Specifications
Install-Package Microsoft.NET.Test.SDK Install-Package Machine.Specifications.Runner.VisualStudio
Install-Package Machine.Specifications.Should Install-Package Machine.Fakes
For project documentation, please visit the wiki.
A PluralSight course by @kevinkuebler is available here.
Discuss with us on Discussions, or raise an issue.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4