Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GrafGenerator/mokkit

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

118 Commits
118 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mokkit — write tests that read like a story, in plain C#

NuGet CI License: MIT

Mokkit gives your tests the readability of BDD tools like Cucumber/SpecFlow, but with no DSL: no feature files, no step bindings, no runtime glue. The "steps" are just C# extension methods you author — your project's testing vocabulary — so you keep full IDE support (autocomplete, go-to-definition, refactoring) and a test that doesn't make sense simply won't compile.

It's a thin orchestration layer, not a framework: run it inside xUnit / NUnit / MSTest / TUnit, mock with Moq / NSubstitute / FakeItEasy, and wire with Microsoft DI / Autofac / Castle Windsor (or the dependency-free Bag). The same Arrange / Act / Inspect vocabulary scales from a mocked unit test to a full Testcontainers end-to-end run.

// A Mokkit test reads like the scenario it describes.
[Fact]
public async Task Suspending_a_client_reflects_everywhere()
{
    await Arrange
        .NewClient(out var clientId, WithName("Acme Corporation"))
        .CacheHasClient(clientId);

    await Act(clientId, ClientStatus.Suspended);

    await Inspect
        .ApiClientEventually(clientId, c => c.Status == Suspended)
        .DbClient(clientId, c => c!.Status.ShouldBe(Suspended))
        .EventPublished("clients.updated", clientId);
}

NewClient, CacheHasClient, ApiClientEventually, DbClient, EventPublished aren't Mokkit APIs — they're your verbs. Mokkit provides the Arrange / Act / Inspect shape and the machinery underneath.

Install

Core + a DI adapter + a mock adapter (prerelease for now):

dotnet add package Mokkit --prerelease
dotnet add package Mokkit.Containers.Microsoft.Extensions.DependencyInjection --prerelease
dotnet add package Mokkit.Containers.NSubstitute --prerelease

Packages

Package Purpose
Mokkit Core: Stage, Arrange/Act/Inspect, captures, the [MokkitCapture] source generator
Mokkit.Containers.Microsoft.Extensions.DependencyInjection · .Autofac · .CastleWindsor DI container adapters
Mokkit.Containers.Moq · .NSubstitute · .FakeItEasy Mock library adapters
Mokkit.Containers.Bag Dependency-free "hold a few instances" container

Documentation

Full guides, concepts and API reference: mokkit.net

A worked, three-tier example (unit / integration / e2e) lives in example/Example1.

License

MIT © Nikita Ivanov

About

Framework-agnostic tool to make your tests look like a story, no DSLs, with compile-time checks and full IDE support

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.