docs: add unit test audit extension design
This commit is contained in:
63
docs/plans/2026-02-27-unit-test-audit-design.md
Normal file
63
docs/plans/2026-02-27-unit-test-audit-design.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Unit Test Audit Extension Design
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Extend the PortTracker `audit` command to classify unit tests (not just features) by inspecting .NET test source code with Roslyn.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
Parameterize the existing audit pipeline (`AuditCommand` + `SourceIndexer` + `FeatureClassifier`) to support both `features` and `unit_tests` tables. No new files — the same indexer and classifier logic applies to test methods.
|
||||||
|
|
||||||
|
## CLI Interface
|
||||||
|
|
||||||
|
```
|
||||||
|
dotnet run -- audit --type features|tests|all [--source <path>] [--module <id>] [--execute]
|
||||||
|
```
|
||||||
|
|
||||||
|
| Flag | Default (features) | Default (tests) |
|
||||||
|
|------|-------------------|-----------------|
|
||||||
|
| `--type` | `features` | — |
|
||||||
|
| `--source` | `dotnet/src/ZB.MOM.NatsNet.Server` | `dotnet/tests/ZB.MOM.NatsNet.Server.Tests` |
|
||||||
|
| `--output` | `reports/audit-results.csv` | `reports/audit-results-tests.csv` |
|
||||||
|
|
||||||
|
- `--type all` runs both sequentially.
|
||||||
|
- `--source` override works for either type.
|
||||||
|
|
||||||
|
## Changes Required
|
||||||
|
|
||||||
|
### AuditCommand.cs
|
||||||
|
|
||||||
|
1. Add `--type` option with values `features`, `tests`, `all`.
|
||||||
|
2. Thread an `AuditTarget` (table name + default source + default output + display label) through `RunAudit` and `ApplyUpdates`.
|
||||||
|
3. `--type all` calls `RunAudit` twice with different targets.
|
||||||
|
4. `ApplyUpdates` uses the target's table name in UPDATE SQL.
|
||||||
|
|
||||||
|
### FeatureClassifier.cs
|
||||||
|
|
||||||
|
No changes. Same N/A lookup and classification logic applies to unit tests.
|
||||||
|
|
||||||
|
### SourceIndexer.cs
|
||||||
|
|
||||||
|
No changes. Already generic — just pass a different directory path.
|
||||||
|
|
||||||
|
## Pre-audit DB Reset
|
||||||
|
|
||||||
|
Before running the test audit, manually reset deferred tests to `unknown`:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
sqlite3 porting.db "UPDATE unit_tests SET status = 'unknown' WHERE status = 'deferred';"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Execution Sequence
|
||||||
|
|
||||||
|
1. Reset deferred tests: `sqlite3 porting.db "UPDATE unit_tests SET status = 'unknown' WHERE status = 'deferred';"`
|
||||||
|
2. Run audit: `dotnet run -- audit --type tests --db porting.db --execute`
|
||||||
|
3. Verify results and generate report.
|
||||||
|
|
||||||
|
## Classification Behavior for Tests
|
||||||
|
|
||||||
|
Same priority as features:
|
||||||
|
1. **N/A**: Go method matches logging/signal patterns → `n_a`
|
||||||
|
2. **Method found**: Test class + method exists in test project → `verified` or `stub`
|
||||||
|
3. **Class exists, method missing**: → `deferred` ("method not found")
|
||||||
|
4. **Class not found**: → `deferred` ("class not found")
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# NATS .NET Porting Status Report
|
# NATS .NET Porting Status Report
|
||||||
|
|
||||||
Generated: 2026-02-27 10:27:48 UTC
|
Generated: 2026-02-27 10:34:31 UTC
|
||||||
|
|
||||||
## Modules (12 total)
|
## Modules (12 total)
|
||||||
|
|
||||||
|
|||||||
37
reports/report_9e2d763.md
Normal file
37
reports/report_9e2d763.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# NATS .NET Porting Status Report
|
||||||
|
|
||||||
|
Generated: 2026-02-27 10:34:31 UTC
|
||||||
|
|
||||||
|
## Modules (12 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| verified | 12 |
|
||||||
|
|
||||||
|
## Features (3673 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| deferred | 2500 |
|
||||||
|
| n_a | 18 |
|
||||||
|
| stub | 168 |
|
||||||
|
| verified | 987 |
|
||||||
|
|
||||||
|
## Unit Tests (3257 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| deferred | 2680 |
|
||||||
|
| n_a | 187 |
|
||||||
|
| verified | 390 |
|
||||||
|
|
||||||
|
## Library Mappings (36 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| mapped | 36 |
|
||||||
|
|
||||||
|
|
||||||
|
## Overall Progress
|
||||||
|
|
||||||
|
**1594/6942 items complete (23.0%)**
|
||||||
Reference in New Issue
Block a user