Skip to content

Testably

Open-source testing libraries for .NET

Tests that read like the sentence you had in mind.
Documentation · Sponsor

Mock the file system and the clock, fake any dependency without reflection, and get failure messages that explain themselves. Three libraries, each useful on its own, better together.

What makes your code hard to test?

“It reads files, checks the date or rolls a dice.”

Mock the unmockable. Inject IFileSystem, ITimeSystem and IRandomSystem. Swap in in-memory mocks for tests.

NuGet

Get started →

“When it fails, I can't tell why.”

Readable, AOT-ready assertions. Every expectation is awaited, for values, tasks, streams and exceptions alike.

NuGet

Get started →

“It needs a collaborator I don't want in the test.”

AOT-ready mocking for .NET. Source-generated mocks, set up with regular method calls. No reflection, no proxies.

NuGet

Get started →

One test, three libraries

A service that exports a report to disk and notifies the team. No temp folder, no hand-written fake, no guessing what failed.

[Test]
public async Task Export_WritesReportAndNotifiesTeam()
{
    MockFileSystem fileSystem = new();                    // Testably.Abstractions
    INotifier notifier = INotifier.CreateMock();          // Mockolate
    ReportService sut = new(fileSystem, notifier);

    await sut.ExportAsync("Q3");

    await That(fileSystem).HasFile("reports/Q3.json");    // aweXpect.Testably
    await That(notifier.Mock.Verify.Send("Report Q3 exported")).Once(); // aweXpect.Mockolate
}

aweXpect extensions

Package Verifies
aweXpect.Json JSON by its structure, ignoring whitespace and property order
aweXpect.Logging what your code logged with Microsoft.Extensions.Logging
aweXpect.Mockolate the interactions with a Mockolate mock
aweXpect.Reflection architecture and naming conventions
aweXpect.Snapshots large or generated output and the public API of an assembly
aweXpect.Testably the state of a MockFileSystem and MockTimeSystem
aweXpect.Web HTTP requests and responses
aweXpect.Xml XML by its content, ignoring attribute order and whitespace

Use aweXpect.Chronology to write 5.Seconds() or 24.December(2024) instead of TimeSpan.FromSeconds(5) or new DateTime(2024, 12, 24). It works on its own, also without aweXpect.


Free and open source under the MIT license.

Pinned Loading

  1. Testably.Abstractions Testably.Abstractions Public

    Depend on IFileSystem, ITimeSystem and IRandomSystem in production. Swap in the in-memory mocks for tests - deterministic, cross-platform, no temp folders or Thread.Sleep.

    C# 96 19

  2. aweXpect aweXpect Public

    Assert unit tests in natural language using awesome expectations.

    C# 10 4

  3. Mockolate Mockolate Public

    A modern, strongly-typed, AOT-compatible mocking library for .NET, powered by source generators.

    C# 17 3

  4. aweXpect.Chronology aweXpect.Chronology Public

    Extension methods for creating chronology objects like `TimeSpan` or `DateTime` that read more natural.

    C# 2 1

Repositories

Showing 10 of 21 repositories

Top languages

Loading…

Most used topics

Loading…