Source: CONTRIBUTING.md - Testing Requirements
- Never decrease code coverage - PRs must maintain or increase coverage
- Target: 70%+ coverage for new code
- Coverage collection:
- Temporarily disabled in CI during xUnit v3 / MTP migration
- Will be re-enabled once an MTP-compatible coverage solution is integrated
-
Add a comment indicating the test was AI generated
- Either of these forms is acceptable; both are well-established in the codebase:
// Claude - <model>(e.g.// Claude - Opus 4.7)// CoPilot - <model>(e.g.// CoPilot - ChatGPT v4)
- Use whichever matches the agent that produced the test, with the model identifier.
- Reviewers (human or automated) should not flag inconsistency between these two forms — both have been used widely; consistency of a marker matters, not which one.
- Either of these forms is acceptable; both are well-established in the codebase:
-
Make tests granular
- Each test should cover smallest area possible
-
Follow existing test patterns
- Study tests in respective test projects before writing new ones
-
Never add new tests to
UnitTests.Legacy- Make them parallelizable and add them to
UnitTestsParallelizable
- Make them parallelizable and add them to
-
Avoid static dependencies
- DO NOT use the legacy/static
ApplicationAPI orConfigurationManagerin tests unless the tests explicitly test related functionality
- DO NOT use the legacy/static
-
Don't use
[AutoInitShutdown]or[SetupFakeApplication]- Legacy pattern, being phased out
When to use:
- Testing functionality that depends on static state
- Testing
Application.InitandApplication.Shutdown
Characteristics:
- ~10 min timeout
- Uses
Application.Initand static state - Cannot run in parallel
Command:
dotnet test --project Tests/UnitTests.NonParallelizable --no-build --verbosity normalWhen to use:
- All new tests should go here unless they explicitly need static state
Characteristics:
- ~10 min timeout
- No dependencies on static state
- Can run concurrently
- Faster execution
Command:
dotnet test --project Tests/UnitTestsParallelizable --no-build --verbosity normalWhen to use:
- Testing cross-component interactions
- End-to-end scenarios
Command:
dotnet test --project Tests/IntegrationTests --no-build --verbosity normalxunit.runner.json- Per-project xUnit configuration (parallelization, etc.)Tests/TestEnvironmentSetup.cs- Compiled into every test project; its[ModuleInitializer]setsDisableRealDriverIO=1before any test code runs- Coverage tooling: each test project references the
coverlet.collectorpackage, but coverage is not actively collected in CI yet (see "Code Coverage" above — pending an MTP-compatible solution)..runsettingsfiles are ignored by Microsoft Testing Platform (MTP).
// CoPilot - ChatGPT v4
[Fact]
public void MyFeature_ShouldBehaveProperly_WhenConditionMet ()
{
// Arrange
View view = new () { Width = 10, Height = 5 };
// Act
view.Draw ();
// Assert
Assert.Equal (10, view.Width);
}