common-testing-conventions

Enforces AAA pattern, test naming, and assertion conventions across .NET, TypeScript, and Python test suites.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Teams writing tests across multiple stacks (.NET, TypeScript, Python) often end up with inconsistent test structure, unclear naming, and anti-patterns like control flow inside tests or assertions scattered across phases. This Skill enforces a single mandatory set of testing conventions so every test follows the same Arrange-Act-Assert structure, naming scheme, and isolation rules. ## Core Features & Use Cases - Mandatory AAA Pattern: Every test uses exactly one // Arrange, // Act, // Assert block, with no conditionals, try/catch, or assertions outside the Assert phase. - Standardized Naming and Variables: Enforces the Should_{ExpectedBehavior}_When_{Condition} naming pattern and standard sut, expected, actual variable names. - Stack-Specific Guidance: Dedicated references for .NET (xUnit, AwesomeAssertions, NSubstitute, Bogus, Testcontainers), TypeScript (Vitest, Playwright, Biome), and Python (pytest, Mock/AsyncMock, pytest-snapshot, polyfactory builders). - Use Case: When writing a new unit test for a command handler in C#, a Vitest suite for a CLI command, or a pytest module for a Lambda function, load this Skill to produce tests that pass the project's review checklist on the first attempt. ## Quick Start Write a unit test for the new command handler following the project's testing conventions, using AAA comments and the Should_When naming pattern.

Frequently Asked Questions about common-testing-conventions

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

FAQPage Schema
How do I structure unit tests with the AAA pattern?

Structure each test with exactly one Arrange, Act, and Assert comment block. Arrange sets up data and mocks, Act performs a single invocation on the subject under test, and Assert contains all verifications. Never mix phases or add conditionals inside blocks.

What naming convention should I use for unit tests?

Use the Should_{ExpectedBehavior}_When_{Condition} pattern in PascalCase, such as Should_CreateGroup_When_RequestIsValid. Avoid natural language sentences, vague names like Should_Work, or prefixes like TestCreateGroup.

How do I test exceptions in xUnit, pytest, and Vitest?

In C# use AwesomeAssertions with action.Should().ThrowAsync<T>(), in Python use a lambda with pytest.raises(), and in Vitest use expect(...).rejects.toThrow(). The exception assertion always lives in the Assert phase, never in try/catch inside the test.

Can I use try/finally for cleanup inside a test method?

No, try/catch/finally and control flow are prohibited inside test bodies. Use framework teardown instead: IAsyncLifetime or IDisposable in xUnit, yield fixtures in pytest, and beforeEach/afterEach hooks in Vitest.

When is it acceptable to test test-only code like fixtures or builders?

Only as a narrow diagnostic exception when production-behavior tests or a direct workflow reproduction cannot localize the failure. The focused test must target the smallest stable contract and state why consumer evidence is insufficient; it is never added for coverage.

Which mocking libraries does this convention set support per stack?

.NET uses NSubstitute with Received/DidNotReceive verification, TypeScript uses Vitest's vi.fn() and module mocks, and Python uses unittest.mock Mock and AsyncMock. All stacks require verifying mock interactions in the Assert phase.