dotnet-testing

Enforces mandatory xUnit and AwesomeAssertions testing conventions for .NET projects.

138|5|Updated Sep 19, 2024
One-click install
npx skills add https://github.com/macalbert/envilder --skill dotnet-testing-macalbert
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-testing
Source: https://github.com/macalbert/envilder/tree/main/.github/skills/dotnet-testing
Command: npx skills add https://github.com/macalbert/envilder --skill dotnet-testing-macalbert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? .NET test suites often become inconsistent and hard to maintain when developers mix assertion styles, skip the Arrange-Act-Assert structure, or write vague test names. This Skill enforces a single, mandatory set of testing conventions so every unit, integration, and acceptance test follows the same structure. ## Core Features & Use Cases - AAA Pattern Enforcement: Requires Arrange, Act, and Assert markers in every test, with each marker appearing at most once and no control flow inside test bodies. - Naming and Variable Standards: Mandates the Should_{ExpectedBehavior}When{Condition} naming pattern and standard variables like _sut, actual, and expected. - Library Stack Guidance: Prescribes xUnit, AwesomeAssertions, NSubstitute, Verify.Xunit, WireMock.Net, Bogus, AutoFixture, and Testcontainers for specific testing needs. - Use Case: When writing a new handler test, the Skill ensures you structure it with AAA comments, name it correctly, verify mock interactions with .Received(), and clean up via IAsyncLifetime instead of try/finally. ## Quick Start Write a unit test for the CreateGroupCommandHandler following the dotnet testing conventions.

Frequently Asked Questions about dotnet-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure unit tests in .NET with xUnit?▼

Structure every test with the Arrange-Act-Assert pattern, separating each phase with // Arrange, // Act, and // Assert comments. Each marker appears at most once per test, and Act must contain a single invocation on the system under test.

What naming convention should xUnit test methods follow?▼

Use the Should_{ExpectedBehavior}_When_{Condition} pattern in PascalCase, such as Should_CreateGroup_When_RequestIsValid. Avoid vague names like Should_Work and never omit the When clause.

AwesomeAssertions vs Assert.ThrowsAsync for exception testing?▼

Use AwesomeAssertions with act.Should().ThrowAsync<T>() so Act and Assert stay separate. Combining them with Assert.ThrowsAsync in a single Act & Assert block is forbidden under these conventions.

How do I clean up resources in xUnit tests without try/finally?▼

Implement IAsyncLifetime with InitializeAsync and DisposeAsync for async setup and teardown, or IDisposable for synchronous cleanup. Never use try/catch/finally inside test bodies.

Which mocking library works with these .NET test conventions?▼

NSubstitute is the prescribed mocking library for spies, stubs, and mocks, with all interactions verified via .Received(). WireMock.Net handles HTTP service mocking and Testcontainers manages Docker containers in tests.