Overview
Expand NumSharp's test suite from ~4,300 to 10,000 tests with systematic coverage tracking.
Current State
| Metric |
Value |
| Actual tests |
~4,323 |
| Target |
10,000 |
| Gap |
~5,677 tests needed |
| Test files |
290 |
| Test classes |
178 |
| Source files |
417 |
| Source LOC |
~42K |
| ILKernelGenerator LOC |
~21K (28 partial files) |
| OpenBugs tests |
124 (excluded from CI) |
Problem
- Coverage gaps: Many operations lack dtype/layout coverage (see
KERNEL_API_AUDIT.md)
- Dynamic IL code: ~21K lines in ILKernelGenerator uses
DynamicMethod - standard coverage tools (Coverlet, OpenCover) cannot instrument dynamically generated code
- Type matrix: 12 dtypes × N operations × M layouts = combinatorial explosion not fully tested
Proposal
Phase 1: Coverage Infrastructure
Phase 2: Test Matrix Expansion (~3,000 tests)
Phase 3: Edge Case Batteries (~1,500 tests)
Phase 4: NumPy Parity Tests (~1,000 tests)
Phase 5: IL Kernel Coverage (~500 tests)
Dynamic Code Coverage Strategy
Since DynamicMethod IL can't be instrumented by profilers:
- Kernel Hit Tracking: Add
#if DEBUG counters in ILKernelGenerator to track which kernels execute
- Test Matrix Validation: Ensure all (dtype × layout × operation) combinations are tested
- Behavioral Verification: Tests verify output matches NumPy (implicit coverage)
- Coverage Report: Generate report showing kernel path coverage separate from Coverlet
Test Organization
test/NumSharp.UnitTest/
├── Coverage/ # NEW: Coverage tracking infrastructure
│ ├── KernelCoverageTracker.cs
│ └── CoverageReportTests.cs
├── DtypeMatrix/ # NEW: All dtype combinations
│ ├── BinaryOps/
│ ├── UnaryOps/
│ └── Reductions/
├── LayoutMatrix/ # NEW: Memory layout variations
│ ├── ContiguousTests.cs
│ ├── StridedTests.cs
│ └── BroadcastTests.cs
└── EdgeCases/ # NEW: Systematic edge cases
├── EmptyArrayTests.cs
├── ScalarTests.cs
└── NaNPropagationTests.cs
Coverage Tool Analysis
| Tool |
Dynamic Code Support |
Notes |
| Coverlet |
❌ No |
Standard .NET coverage, instruments assemblies at build time |
| OpenCover |
❌ No |
Already referenced in project, Windows only |
| dotCover |
❌ No |
JetBrains commercial tool |
| AltCover |
❌ No |
Open source alternative |
Reality: "100% coverage" will show ~60-70% in Coverlet reports because ~21K lines of ILKernelGenerator emit code at runtime. Behavioral coverage can reach 100%, but reported coverage won't reflect it.
Definition of Done
Test Multiplication Quick Wins
| Strategy |
Tests Added |
Effort |
| Dtype parameterization |
~3,000+ |
Low (add [Arguments] to existing tests) |
| Layout parameterization |
~1,500+ |
Medium (contiguous/strided/broadcast) |
| Edge case batteries |
~1,000+ |
Medium (empty, scalar, NaN, indices) |
| Missing operation tests |
~500+ |
High (new test files) |
Related
docs/KERNEL_API_AUDIT.md - tracks test gaps per operation
- OpenBugs files - 124 known failing tests to fix
Overview
Expand NumSharp's test suite from ~4,300 to 10,000 tests with systematic coverage tracking.
Current State
Problem
KERNEL_API_AUDIT.md)DynamicMethod- standard coverage tools (Coverlet, OpenCover) cannot instrument dynamically generated codeProposal
Phase 1: Coverage Infrastructure
KernelCoverageTrackerfor IL kernel behavioral coveragePhase 2: Test Matrix Expansion (~3,000 tests)
[Arguments]Phase 3: Edge Case Batteries (~1,500 tests)
Phase 4: NumPy Parity Tests (~1,000 tests)
src/numpy/)[Misaligned]differencesPhase 5: IL Kernel Coverage (~500 tests)
Dynamic Code Coverage Strategy
Since
DynamicMethodIL can't be instrumented by profilers:#if DEBUGcounters in ILKernelGenerator to track which kernels executeTest Organization
Coverage Tool Analysis
Reality: "100% coverage" will show ~60-70% in Coverlet reports because ~21K lines of ILKernelGenerator emit code at runtime. Behavioral coverage can reach 100%, but reported coverage won't reflect it.
Definition of Done
Test Multiplication Quick Wins
[Arguments]to existing tests)Related
docs/KERNEL_API_AUDIT.md- tracks test gaps per operation