diff --git a/.claude/rules/event-patterns.md b/.claude/rules/event-patterns.md index bff0fb6d42..06ddca624c 100644 --- a/.claude/rules/event-patterns.md +++ b/.claude/rules/event-patterns.md @@ -69,13 +69,13 @@ void OnTextChanged (object sender, EventArgs e) { } ## Local Function Naming -**Use camelCase for local functions:** +**Use PascalCase for local functions** (the `.editorconfig` `local_functions_rule` enforces `upper_camel_case_style` at `warning` severity): ```csharp // CORRECT -void textViewDrawContent (object? sender, DrawEventArgs e) { } +void TextViewDrawContent (object? sender, DrawEventArgs e) { } // WRONG void TextView_DrawContent (object? sender, DrawEventArgs e) { } -void TextViewDrawContent (object? sender, DrawEventArgs e) { } +void textViewDrawContent (object? sender, DrawEventArgs e) { } ``` diff --git a/.claude/rules/testing-patterns.md b/.claude/rules/testing-patterns.md index 2afa674159..b9c3b10ec1 100644 --- a/.claude/rules/testing-patterns.md +++ b/.claude/rules/testing-patterns.md @@ -27,7 +27,7 @@ 3. **Follow existing test patterns** - Study tests in respective test projects before writing new ones -4. **Avoid adding new tests to `UnitTests` Project** +4. **Never add new tests to `UnitTests.Legacy`** - Make them parallelizable and add them to `UnitTestsParallelizable` 5. **Avoid static dependencies** @@ -38,7 +38,7 @@ ## Test Projects -### 1. Non-Parallel Tests (`Tests/UnitTests/`) +### 1. Non-Parallel Tests (`Tests/UnitTests.NonParallelizable/`) **When to use:** - Testing functionality that depends on static state @@ -48,11 +48,10 @@ - ~10 min timeout - Uses `Application.Init` and static state - Cannot run in parallel -- Includes `--diagnostic` flag for logging **Command:** ```bash -dotnet test --project Tests/UnitTests --no-build --verbosity normal +dotnet test --project Tests/UnitTests.NonParallelizable --no-build --verbosity normal ``` ### 2. Parallel Tests (`Tests/UnitTestsParallelizable/`) - **PREFERRED** @@ -84,8 +83,9 @@ dotnet test --project Tests/IntegrationTests --no-build --verbosity normal ## Test Configuration Files -- `xunit.runner.json` - xUnit configuration -- `coverlet.runsettings` - Coverage settings (currently unused, pending MTP integration) +- `xunit.runner.json` - Per-project xUnit configuration (parallelization, etc.) +- `Tests/TestEnvironmentSetup.cs` - Compiled into every test project; its `[ModuleInitializer]` sets `DisableRealDriverIO=1` before any test code runs +- Coverage tooling: each test project references the `coverlet.collector` package, but coverage is not actively collected in CI yet (see "Code Coverage" above — pending an MTP-compatible solution). `.runsettings` files are ignored by Microsoft Testing Platform (MTP). ## Example Test Pattern diff --git a/CLAUDE.md b/CLAUDE.md index 4e94524017..4b20ed7067 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -55,6 +55,7 @@ See `.claude/rules/` for detailed guidance: - `event-patterns.md` - Lambdas, closures, handlers - `early-return.md` - **Guard clauses, minimal nesting** (commonly violated!) - `collection-expressions.md` - Use `[...]` syntax +- `unicode-graphemes.md` - **Think in graphemes** - `GetColumns()`, `GraphemeHelper.GetGraphemes()` - `cwp-pattern.md` - Cancellable Workflow Pattern - `code-layout.md` - Backing fields, member ordering - `api-documentation.md` - XML documentation requirements @@ -63,7 +64,6 @@ See `.claude/rules/` for detailed guidance: ## Task-Specific Guides See `.claude/tasks/` for task checklists: -- `scenario-modernization.md` - Upgrading UICatalog scenarios - `clean-code-review.md` - Creating clean git commit histories - `build-app.md` - Building applications with Terminal.Gui @@ -100,8 +100,11 @@ dotnet test --project Tests/UnitTests.NonParallelizable --no-build # Legacy tests — do NOT add new tests here; candidates for rewrite/deletion dotnet test --project Tests/UnitTests.Legacy --no-build -# Run a single test by fully-qualified name -dotnet test --project Tests/UnitTestsParallelizable --no-build --filter "FullyQualifiedName~MyTestClass.MyTestMethod" +# Run a single test by method name (Microsoft Testing Platform) +dotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method "*MyTestMethod" + +# Run all tests in a class +dotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class "*MyTestClass" ``` See `Tests/README.md` for the full list of test projects (including `IntegrationTests`, `StressTests`, `Benchmarks`) and the static-state classification that determines where a new test belongs.