Unit Test Standards
Purpose
Unit tests verify small pieces of behaviour quickly and deterministically.
AIC Standard
xUnit is the default test framework for new AIC .NET projects.
Tests must be deterministic and isolated.
Tests should run from the command line using
dotnet test.Tests should not depend on external services.
Unit tests must not use production databases, real message brokers or real customer services.
Naming
Use behaviour-based names:
public sealed class AccessDecisionServiceTests
{
[Fact]
public void CanReadCase_WhenUserHasMatchingClearance_ReturnsTrue()
{
}
}Structure
Use Arrange, Act, Assert:
Test Data Builders
Use builders to make intent clear:
Mocking Rules
Mock external dependencies, not value objects.
Prefer real domain objects.
Do not over-mock internal implementation.
Avoid verifying every method call unless behaviour requires it.
Mock time through
IClockorTimeProvider.
Unit Test Gate
Unit tests must:
run quickly
be included in PR pipeline
be named clearly
fail for one understandable reason
use stable data
avoid sleeps and timing assumptions
Was this helpful?

