Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 3.22 KB

File metadata and controls

88 lines (62 loc) · 3.22 KB

Mach.Testing

Build Status codecov

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.

📦 Available Packages

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

🚀 Quick Start

Choose the approach that best fits your testing needs:

Strongly-Typed Approach (Recommended)

For tests that benefit from IntelliSense and compile-time safety:

dotnet add package Mach.Testing
ScenarioFor<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();

Dynamic Approach

For maximum flexibility and rapid prototyping:

dotnet add package Mach.Testing.Dynamic
Scenario
    .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();

🎯 Key Features

  • 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

🎮 Godot Support

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.

📚 Documentation

Each package has its own detailed documentation:

🔧 Target Frameworks

  • .NET Standard 2.0 (for maximum compatibility including Godot)
  • .NET 6.0
  • .NET 8.0

📄 License

MIT