You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TESTING_GUIDE.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ If you change test code, test helpers, test execution flow, or testing conventio
11
11
```bash
12
12
dotnet test
13
13
dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj
14
+
dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj --settings tests/CodeIndex.Tests/CodeIndex.Tests.runsettings --blame-crash --blame-hang --blame-hang-timeout 5m
14
15
dotnet test --filter "FullyQualifiedName~GitHelperTests"
15
16
```
16
17
@@ -25,6 +26,7 @@ Use the full suite by default. Use targeted filters only while iterating locally
25
26
- These test-only packages are separate from the production dependency rule in `src/CodeIndex`, which still allows only `Microsoft.Data.Sqlite` at runtime.
26
27
-`FsCheck.Xunit` is reserved for property-based tests that assert universal invariants (never-throws contracts, idempotence, "output is parseable by downstream consumer") across randomly generated inputs. Use it to complement, not replace, the example-based `[Fact]` / `[Theory]` tests — pick FsCheck when the property is a universally quantified claim, and an example test when a specific concrete case is the contract.
27
28
- Test parallelism: enabled by default across independent test classes. Tests that touch process-global state such as SQLite pool resets, environment variables, or current-directory overrides must use an explicit non-parallel collection, and tests that swap `Console.Out` / `Console.Error` must lock on `TestConsoleLock.Gate`.
29
+
- CI runs the test project through `tests/CodeIndex.Tests/CodeIndex.Tests.runsettings`, enables VSTest blame crash and hang collection, applies a 30-minute session timeout plus 60-second xUnit long-running diagnostics, and reruns the suite once after an initial failure. If the retry passes, CI uploads `TestResults/flaky-retry.txt` with the TRX and blame artifacts so the run is treated as suspect instead of silently trusted.
28
30
29
31
## Test Layout
30
32
@@ -85,6 +87,16 @@ The test project mirrors the production areas closely.
85
87
- When a production comment or error string is bilingual, preserve that expectation in tests where it matters.
86
88
- If a behavior change is user-visible, update tests, `CHANGELOG.md`, and any affected docs together.
87
89
90
+
### Shared state and parallelism audit
91
+
92
+
Use the inventory below before adding or moving a test class:
93
+
94
+
- SQLite pool resets, direct `SqliteConnection.ClearAllPools()` calls, process current-directory changes, or process-global environment variable mutation: put the class in the `SQLite pool sensitive` non-parallel collection.
95
+
- Environment variables: use `EnvironmentVariableScope.Capture(...)` so setup failures and assertion failures restore the original values through one cleanup path.
96
+
-`Console.Out` or `Console.Error` replacement: lock `TestConsoleLock.Gate` around the whole capture/swap window.
97
+
- Temporary repositories and files: create them through `TestProjectHelper` when practical, and do not depend on user-level git config.
98
+
- Long-running or performance-oriented tests: keep them skipped by default or give them broad deterministic budgets; if CI reports them in xUnit long-running diagnostics, first check runner load before tightening thresholds.
99
+
88
100
## Shared Helpers
89
101
90
102
### `TestProjectHelper`
@@ -198,6 +210,7 @@ Check the following:
198
210
```bash
199
211
dotnet test
200
212
dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj
213
+
dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj --settings tests/CodeIndex.Tests/CodeIndex.Tests.runsettings --blame-crash --blame-hang --blame-hang-timeout 5m
201
214
dotnet test --filter "FullyQualifiedName~GitHelperTests"
202
215
```
203
216
@@ -212,6 +225,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"
-**CI flaky-test classification (#1610)** — Added a bounded one-time test retry in CI and a `flaky-retry.txt` artifact marker when the retry passes after an initial failure.
14
+
15
+
## 日本語
16
+
17
+
-**CI の flaky test 分類 (#1610)** — CI テストに1回限りの bounded retry を追加し、初回失敗後の再実行で成功した場合に `flaky-retry.txt` artifact marker を残すようにしました。
-**Test parallelism audit guidance (#1612)** — Documented the shared-state inventory for test classes that need serialized execution or explicit cleanup guards.
-**CI test timeout and blame diagnostics (#1821)** — Added test runsettings with a session timeout and xUnit long-running diagnostics, enabled VSTest crash/hang blame capture in CI, and uploaded blame artifacts with TRX results.
0 commit comments