A comprehensive suite of scenario-based testing libraries for .NET that makes your tests more expressive, readable, and maintainable. Perfect for .NET applications including Godot projects.
| Package | Description | Documentation |
|---|---|---|
| Mach.Testing | Strongly-typed scenario testing with contracts | 📖 Documentation |
| Mach.Testing.Dynamic | Dynamic scenario testing with flexible contexts | 📖 Documentation |
| Mach.Testing.Core | Core foundation library (dependency) | 📖 Documentation |
Choose the approach that best fits your testing needs:
For tests that benefit from IntelliSense and compile-time safety:
dotnet add package Mach.TestingScenarioFor<MyContract>
.Feature("Calculator can add two numbers")
.Given(contract => contract.Subject = new Calculator())
.And(contract => contract.A = 5)
.And(contract => contract.B = 3)
.When(contract => contract.Result = contract.Subject.Add(contract.A, contract.B))
.Then(contract => contract.Result.ShouldBe(8))
.Verify();For maximum flexibility and rapid prototyping:
dotnet add package Mach.Testing.DynamicScenario
.Feature("Simple math calculation")
.Given(ctx => ctx.a = 5)
.And(ctx => ctx.b = 3)
.When(ctx => ctx.result = ctx.a + ctx.b)
.Then(ctx => Assert.That(ctx.result, Is.EqualTo(8)))
.Verify();- Readable BDD-style syntax: Write tests that read like specifications
- Flexible contexts: Choose between strongly-typed contracts or dynamic objects
- Automatic dependency injection: Powered by AutoFixture
- Framework agnostic: Works with NUnit, xUnit, MSTest, and others
- Cross-platform: Supports .NET Standard, .NET 6.0, and .NET 8.0
- Godot compatible: Perfect for game development testing scenarios
All libraries support .NET Standard and .NET 8.0, making them fully compatible with Godot projects. The dynamic testing approach is particularly useful for game scenarios where test data structures can vary significantly.
Each package has its own detailed documentation:
- Mach.Testing - Learn about strongly-typed scenario testing
- Mach.Testing.Dynamic - Explore dynamic context testing
- Mach.Testing.Core - Understand the foundation library
- .NET Standard 2.0 (for maximum compatibility including Godot)
- .NET 6.0
- .NET 8.0
MIT