GravionLabs/elysion / .agents/skills/dotnet-test
dotnet-test
Verified.NET / C# test rules using NUnit with NSubstitute and Shouldly (structure, mocking, assertions, coverage). Use when writing or running tests in a .NET project.
Prerequisites
- .NET SDK
- Test project with NUnit, NSubstitute, Shouldly NuGet packages
Test Runner
- Framework: NUnit · Mocking: NSubstitute · Assertions: Shouldly
- Run all:
dotnet test - Run single:
dotnet test --filter "FullyQualifiedName~Namespace.Tests.ClassName" - Targeted run (per commit):
dotnet test --filter "FullyQualifiedName~<Name>"for the test classes of the changed code (--no-buildafter an own build); unknown mapping: the unit group (--filter "TestCategory=UnitTest") - Coverage:
dotnet test --collect:"XPlat Code Coverage"writescoverage.cobertura.xmltoTestResults/; convert withreportgenerator
Conventions
- File naming:
{ClassName}Tests.csin thetest/<Project>.Testsproject, mirroringsrc/ - Namespace matches the source project with
.Testssuffix - Test method naming:
Should_<expected>_when_<condition> - Categories:
[Category("UnitTest")]for unit,[Category("IntegrationTest")]for integration,[Category("ManualTest")]+[Explicit]for manual - One test class per source class; one test method per scenario; AAA structure
Test structure
[Test]
[Category("UnitTest")]
public async Task Should_return_user_when_valid_id()
{
repo.GetByIdAsync("123", Arg.Any<CancellationToken>()).Returns(new User { Id = "123" });
var result = await sut.GetUserAsync("123");
result.ShouldNotBeNull();
result.Id.ShouldBe("123");
}
Gotchas
- Always set a
[Category(...)]so test filtering stays consistent - Put the test project under
test/<ProjectName>.Tests, not alongside the source project
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |