Machine.specifications
Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
Install / Use
/learn @machine/Machine.specificationsREADME
Machine.Specifications
<img src="https://github.com/machine/machine.specifications/raw/master/src/Machine.Specifications/Resources/Machine.png" alt="MSpec logo" title="Machine.Specifications" align="right" height="100" />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();
}
Getting Started
- Create a .NET Framework or .NET Core library project.
- Install Nuget packages as follows:
Install-Package Machine.Specifications
- Install the test SDK and Visual Studio runner:
Install-Package Microsoft.NET.Test.SDK
Install-Package Machine.Specifications.Runner.VisualStudio
- Optionally, install the assert and mocking libraries:
Install-Package Machine.Specifications.Should
Install-Package Machine.Fakes
Documentation
For project documentation, please visit the wiki.
Training
A PluralSight course by @kevinkuebler is available here.
Get in touch
Discuss with us on Discussions, or raise an issue.
Packages
Project | Build | 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 | |
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
