https://github.com/machine/machine.specifications
Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
https://github.com/machine/machine.specifications
dotnet mspec unit-testing
Last synced: 3 months ago
JSON representation
Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
- Host: GitHub
- URL: https://github.com/machine/machine.specifications
- Owner: machine
- License: mit
- Created: 2009-02-05T03:04:48.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2024-07-09T22:02:04.000Z (11 months ago)
- Last Synced: 2024-10-01T02:49:47.025Z (8 months ago)
- Topics: dotnet, mspec, unit-testing
- Language: C#
- Homepage:
- Size: 161 MB
- Stars: 886
- Watchers: 47
- Forks: 178
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Machine.Specifications
[](https://github.com/machine/machine.specifications/wiki) [](https://www.nuget.org/packages/Machine.Specifications) [](https://github.com/machine/machine.specifications/discussions) [](https://github.com/machine/machine.specifications/blob/master/LICENSE)
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.```csharp
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
1. Create a .NET Framework or .NET Core library project.
2. Install Nuget packages as follows:```powershell
Install-Package Machine.Specifications
```3. Install the test SDK and Visual Studio runner:
```powershell
Install-Package Microsoft.NET.Test.SDK
Install-Package Machine.Specifications.Runner.VisualStudio
```4. Optionally, install the assert and mocking libraries:
```powershell
Install-Package Machine.Specifications.Should
Install-Package Machine.Fakes
```## Documentation
For project documentation, please visit the [wiki](https://github.com/machine/machine.specifications/wiki).
## Training
A PluralSight course by [@kevinkuebler](https://github.com/kevinkuebler) is available [here](https://www.pluralsight.com/courses/expressive-testing-dotnet-mspec).## Get in touch
Discuss with us on [Discussions](https://github.com/machine/machine.specifications/discussions), or raise an [issue](https://github.com/machine/machine.specifications/issues).[](https://github.com/machine/machine.specifications/discussions)
## Packages
Project | Build | NuGet
-- | -- | --
`Machine.Specifications` | [](https://github.com/machine/machine.specifications/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications)
`Machine.Specifications.Reporting` | [](https://github.com/machine/machine.specifications/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications.reporting)
`Machine.Specifications.Runner.Console` | [](https://github.com/machine/machine.specifications/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications.runner.console)
`Machine.Specifications.Runner.ReSharper` | [](https://github.com/machine/machine.specifications.runner.resharper/actions?query=workflow:build) | [](https://plugins.jetbrains.com/plugin/11639-machine-specifications-for-resharper)
`Machine.Specifications.Runner.Rider` | [](https://github.com/machine/machine.specifications.runner.resharper/actions?query=workflow:build) | [](https://plugins.jetbrains.com/plugin/11528-machine-specifications-for-rider)
`Machine.Specifications.Runner.TDNet` | [](https://github.com/machine/machine.specifications/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications.runner.tdnet)
`Machine.Specifications.Runner.Utility` | [](https://github.com/machine/machine.specifications/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications.runner.utility)
`Machine.Specifications.Runner.VisualStudio` | [](https://github.com/machine/machine.specifications.runner.visualstudio/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications.runner.visualstudio)
`Machine.Specifications.Should` | [](https://github.com/machine/machine.specifications/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.specifications.should)
`Machine.Fakes` | [](https://github.com/machine/machine.specifications.fakes/actions?query=workflow:build) | [](https://www.nuget.org/packages/machine.fakes)