macalbert/envilder/common-testing-conventions

Claude Code and agent skill by macalbert/envilder

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Mandatory testing conventions including the narrow diagnostic exception for testing test-only code, AAA pattern, test naming, and assertions across all stacks (.NET, TypeScript, Python). Use when writing tests or changing test infrastructure.

Install

npx vskill@latest install macalbert/envilder/common-testing-conventions

SKILL.md

Testing Conventions Skill

Mandatory testing conventions across all stacks. Stack-specific libraries and examples are documented in dedicated supporting files.

Code Style Rules

NEVER write unnecessary comments or XML summaries. Exception: // Arrange, // Act, // Assert comments are REQUIRED in tests.

RuleExample
Use class not recordpublic class OrderMother { ... }
Always use {} bracketsif (x) { return; } never if (x) return;
Aligned wrapped parametersAlign parameters with opening parenthesis

When to Use

  • Writing unit tests for handlers, services, or components
  • Writing integration tests with WebApplicationFactory
  • Writing E2E tests with Playwright
  • Setting up test class structure
  • Verifying mock interactions

Supporting Files

FileDescription
dotnet.md.NET testing stack (xUnit, AwesomeAssertions, NSubstitute, Bogus, Verify.Xunit, WireMock, Testcontainers)
typescript.mdTypeScript testing stack: CLI, SDK, CDK, Website (Vitest, Playwright, Biome)
python.mdPython testing stack (pytest, Mock/AsyncMock, pytest-snapshot, black, mypy, Pydantic)
examples.mdFull test examples for C# and TypeScript
reference.mdNaming rules, anti-patterns, checklist

Core Principles

1. Test Production Behavior; Diagnose Test Support Only When Necessary

Tests specify production behavior. Do not create tests whose subject is test-only code by default, including fixtures, mothers, builders, mocks, stubs, seeders, test containers, data loaders, or runner configuration. Shared, reusable, independently versioned, or public test-support code is still test-only code; those traits do not justify testing it directly.

Start by validating test-infrastructure changes through the production-behavior tests that consume them or a direct reproduction of the affected workflow. A focused test of support code is allowed only when those paths cannot identify a failure with enough diagnostic precision. It must target the smallest stable contract needed to localize the fault and state why consumer or workflow evidence is insufficient.

This is diagnostic instrumentation, not default behavioral verification. Never add it for coverage or to mirror implementation details.

2. AAA Pattern (Mandatory)

All tests MUST follow Arrange-Act-Assert with clear comments:

csharp
[Fact(Timeout = CancellationTokenForTest.ShortTimeout)]
public async Task Should_CreateGroup_When_RequestIsValid()
{
// Arrange
var request = new CreateGroupRequest { Name = "Test Group" };
var command = new CreateGroupCommand(request);
// Act
var actual = await _sut.Handle(command, CancellationToken.None);
// Assert
actual.Should().NotBeNull();
actual.GroupId.Should().NotBeEmpty();
_repository.Received(1).AddGroup(Arg.Any<Group>());
}

Rules:

  • Each comment (`// Arrange`, `// Act`, `// Assert`) appears AT MOST ONCE per test: if you need two actions,

write two tests

  • Act = one single invocation on the SUT. Multiple statements in Act only if they are genuinely

part of the same logical action (rare and exceptional). Two independent operations = two tests.

  • AAA markers are mandatory in ALL tests: including structural guards,

static completeness checks, and data validation tests. No exceptions.

  • Each section clearly separated by comments
  • Never mix phases
  • All assertions belong in Assert only. No expect(), .Should(), assert, or any verification

statement in Arrange or Act. If you feel tempted to assert in Arrange (precondition check), extract it to a separate test or use a guard clause that throws: not an assertion.

  • No `if`, `switch`, or conditional logic inside Arrange, Act, or Assert blocks
  • No `try/catch/finally` inside tests: use framework teardown (IAsyncLifetime, [ClassCleanup], pytest yield fixtures)
  • No `// Act & Assert` combined blocks: Act and Assert are ALWAYS separate phases
  • For exceptions: C# → AwesomeAssertions .Should().ThrowAsync<T>() | Python → lambda + pytest.raises() | Vitest

→ expect(...).rejects.toThrow()

  • Omit comment if section is empty
  • If a test needs branching, split it into separate test methods (one per scenario)
3. Test Naming Convention
txt
Should_{ExpectedBehavior}_When_{Condition}
✓ Good✗ Bad
Should_CreateGroup_When_RequestIsValidTestCreateGroup
Should_ThrowNotFound_When_UserDoesNotExist"should login"
Should_ReturnEmptyList_When_NoRecordsFoundShould_Work
4. Standard Variables
PurposeName
Subject under testsut
Expected valueexpected
Actual resultactual
csharp
var expected = GroupMother.Create(id: groupId);
var actual = await _sut.Handle(query, CancellationToken.None);
actual.Id.Should().Be(expected.Id);
5. Isolation During Concurrent Development

Tests must run safely in parallel while a development environment is active on the same machine.

  • Use isolated ephemeral infrastructure where mutable state or external

resources are required.

  • Never share mutable state with development, another test, or another CI

worker.

  • Never rely on fixed ports, resource names, or execution order when isolation

is required.

  • If deterministic isolation is not practical, select a different verification

mechanism or report the limitation explicitly.

Test Class Structure (C#)

csharp
public class CreateGroupCommandHandlerTests
{
private readonly Fixture _fixture;
private readonly CreateGroupCommandHandler _sut;
private readonly IEnvilderRepository _repository;
public CreateGroupCommandHandlerTests()
{
_fixture = new();
_repository = Substitute.For<IEnvilderRepository>();
_sut = new(_repository);
}
[Fact(Timeout = CancellationTokenForTest.ShortTimeout)]
public async Task Should_CreateGroup_When_RequestIsValid()
{
// Test implementation
}
}

Libraries by Stack

See the dedicated supporting file for each stack:

  • .NET Backend: dotnet.md: xUnit, AwesomeAssertions, NSubstitute,

AutoFixture, Bogus, Verify.Xunit, WireMock.Net, Testcontainers (PostgreSQL, LocalStack)

(CLI/SDK/CDK/Website), Playwright, Biome

  • Python: python.md: pytest, pytest-asyncio, pytest-snapshot,

unittest.mock, black, mypy, Pydantic

Related Skills

StackConventionsTest Doubles
.NETdotnet-testingdotnet-test-doubles
TypeScripttypescript-testingtypescript-test-doubles
Pythonpython-testingpython-test-doubles

Cross-stack:

  • sdk-acceptance-testing: TestContainers, LocalStack for AWS and Azure (all SDKs)
  • typescript-cdk-testing: CDK snapshot + fine-grained assertions (Vitest)
  • core-testing: Envilder CLI/Core specific testing procedure (Vitest)

Security

  • Security scanPassed, 93 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
135
Repository forks
4
7-day trend score
25

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/macalbert/envilder/common-testing-conventions/badge)](https://verified-skill.com/skills/macalbert/envilder/common-testing-conventions)

Something wrong with this skill or its page? Tell us.