2.2 KiB
2.2 KiB
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 allruns both sequentially.--sourceoverride works for either type.
Changes Required
AuditCommand.cs
- Add
--typeoption with valuesfeatures,tests,all. - Thread an
AuditTarget(table name + default source + default output + display label) throughRunAuditandApplyUpdates. --type allcallsRunAudittwice with different targets.ApplyUpdatesuses 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:
sqlite3 porting.db "UPDATE unit_tests SET status = 'unknown' WHERE status = 'deferred';"
Execution Sequence
- Reset deferred tests:
sqlite3 porting.db "UPDATE unit_tests SET status = 'unknown' WHERE status = 'deferred';" - Run audit:
dotnet run -- audit --type tests --db porting.db --execute - Verify results and generate report.
Classification Behavior for Tests
Same priority as features:
- N/A: Go method matches logging/signal patterns →
n_a - Method found: Test class + method exists in test project →
verifiedorstub - Class exists, method missing: →
deferred("method not found") - Class not found: →
deferred("class not found")