Test Matrix Analysis
A systematic methodology for analyzing test coverage by modeling the test space as an N-dimensional matrix, mapping existing tests, and identifying gaps.
When to Use
- User asks to review test coverage
- User wants to know what tests are missing
- User asks to create a test plan or test strategy
- User wants to understand test gaps before a release
- User asks "what should we test?" or "are we testing enough?"
Methodology
Phase 1: Understand the Codebase
Before creating the matrix, gather deep context. Run both explorations in parallel using Task agents to save time:
Explore architecture: Use the explore agent to understand:
- Main purpose/domain of the project
- Key components, modules, and classes
- Main data structures and relationships
- External integrations/APIs
- Configuration options and feature flags
Explore existing tests: Use the explore agent to catalog:
- All test files and their locations
- What each test file covers
- Testing patterns used (unit, integration, fixtures, mocks)
- Current coverage quality per module
- Test naming conventions and organization
Phase 2: Define the N-Dimensional Matrix
Identify orthogonal dimensions that define the test space. Common dimensions include:
| Dimension Type |
Examples |
| Component Types |
Node types, service types, model types |
| Execution Modes |
sync, async, generator, streaming |
| Data Structures |
Topologies, schemas, relationships |
| Input Variations |
Sources, types, edge cases (None, empty, large) |
| Type System |
Simple types, generics, unions, protocols |
| Configuration |
Feature flags, modes, limits |
| Error Conditions |
Validation errors, runtime errors, edge cases |
| External Integrations |
APIs, databases, file systems |
For each dimension, enumerate all possible values with descriptions.
Phase 3: Calculate Complexity
Show the theoretical test space size:
Total Combinations = dim1_values × dim2_values × ... × dimN_values
This demonstrates why exhaustive testing is intractable and justifies prioritization.
Phase 4: Create Prioritized Test Slices
Instead of testing all combinations, create 2D slices that cover high-value intersections:
- Slice by Risk × Usage: Combinations likely to have bugs AND commonly used
- Slice by Independence: Orthogonal dimensions can be tested separately
- Slice by Complexity: Simple combinations first, then complex
For each slice, create a table showing coverage status:
- Y = Full coverage
- P = Partial coverage
- N = No coverage
- N/A = Not applicable
Example slice format:
| Topology | SyncRunner | AsyncRunner |
|----------|:----------:|:-----------:|
| linear | Y | Y |
| diamond | Y | P |
| cycle | Y | N |
**Status**: GOOD - `test_runners/` covers most combinations
**Gap**: Cycle topology with AsyncRunner needs coverage
Phase 5: Map Existing Tests
Create a matrix mapping test files to dimensions:
| Test File |
Dim1 |
Dim2 |
Dim3 |
... |
| test_foo.py |
Y |
P |
N/A |
... |
This reveals which dimensions have good coverage vs gaps.
Phase 6: Gap Analysis
For each gap, document with concrete test recommendations:
#### GAP-XX: [Descriptive Name]
**Matrix Position**: Dimension1 = value × Dimension2 = value
**Risk**: [Why this gap matters]
**Recommended Tests**:
```python
class TestGapName:
def test_specific_scenario(self): ...
def test_edge_case(self): ...
**Focus on intersections, not individual dimensions** - gaps are most dangerous where multiple dimensions combine in untested ways.
Prioritize gaps as HIGH / MEDIUM / LOW based on:
- **Risk**: Likelihood of bugs in this area
- **Impact**: Severity if bugs exist
- **Usage**: How often this code path is used
### Phase 7: Recommendations
Provide actionable output:
1. **Coverage Score**: X/100 with per-dimension breakdown
2. **Top N Action Items**: Prioritized list of gaps to address
3. **New Test Files**: Suggested file names and estimated test counts
4. **Tests to Add to Existing Files**: Specific additions per file
5. **Test Type Distribution**: Current vs recommended (unit, integration, property-based, performance)
## Output Format
Generate a markdown document with these sections:
```markdown
# [Project Name] Test Matrix Review
## Overview
[Brief description of methodology and findings]
## 1. Conceptual Test Matrix (N-Dimensional)
[Tables defining each dimension and its values]
## 2. Full Matrix Combinations
[Calculation showing test space size]
## 3. Prioritized Test Slices
[2D matrices with coverage status]
## 4. Existing Test Coverage Map
[Test file × dimension matrix]
## 5. Gap Analysis & Recommended Tests
[Prioritized gaps with specific test recommendations]
## 6. Test Type Distribution
[Current vs recommended distribution]
## 7. Summary
[Coverage score, action items, files to create]
## Appendix: Test Matrix Visualization
[ASCII diagram showing test space structure]
Best Practices
- Run Phase 1 explorations in parallel - Use multiple Task agents to gather architecture and test info simultaneously
- Be exhaustive in dimension discovery - Missing a dimension means missing test gaps
- Use domain terminology - Dimensions should match how developers think about the code
- Focus on intersections - Gaps at dimension intersections are more dangerous than single-dimension gaps
- Quantify everything - Scores, counts, and percentages make gaps concrete and trackable over time
- Provide code snippets - Show actual test class/method signatures for recommendations
- Consider test types - Not just what to test, but how (unit, integration, property-based)
- Include edge cases - Empty collections, None values, boundary conditions
- Track error conditions - Both build-time validation and runtime errors
Example Dimensions by Domain
Web API
- HTTP methods, endpoints, auth states, request body types, response codes, error types
Data Pipeline
- Source types, transformations, sinks, data formats, error handling, parallelism modes
State Machine
- States, transitions, events, guards, actions, error recovery
Compiler/Parser
- Token types, AST nodes, semantic rules, optimization passes, target outputs
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: test-matrix-analysis3description: Creates comprehensive N-dimensional test matrices for codebases. Use when asked to analyze test coverage, identify testing gaps, create test plans, or review what tests exist vs what's needed.4---56# Test Matrix Analysis78A systematic methodology for analyzing test coverage by modeling the test space as an N-dimensional matrix, mapping existing tests, and identifying gaps.910## When to Use1112- User asks to review test coverage13- User wants to know what tests are missing14- User asks to create a test plan or test strategy15- User wants to understand test gaps before a release16- User asks "what should we test?" or "are we testing enough?"1718## Methodology1920### Phase 1: Understand the Codebase2122Before creating the matrix, gather deep context. **Run both explorations in parallel** using Task agents to save time:23241. **Explore architecture**: Use the explore agent to understand:25 - Main purpose/domain of the project26 - Key components, modules, and classes27 - Main data structures and relationships28 - External integrations/APIs29 - Configuration options and feature flags30312. **Explore existing tests**: Use the explore agent to catalog:32 - All test files and their locations33 - What each test file covers34 - Testing patterns used (unit, integration, fixtures, mocks)35 - Current coverage quality per module36 - Test naming conventions and organization3738### Phase 2: Define the N-Dimensional Matrix3940Identify **orthogonal dimensions** that define the test space. Common dimensions include:4142| Dimension Type | Examples |43|----------------|----------|44| **Component Types** | Node types, service types, model types |45| **Execution Modes** | sync, async, generator, streaming |46| **Data Structures** | Topologies, schemas, relationships |47| **Input Variations** | Sources, types, edge cases (None, empty, large) |48| **Type System** | Simple types, generics, unions, protocols |49| **Configuration** | Feature flags, modes, limits |50| **Error Conditions** | Validation errors, runtime errors, edge cases |51| **External Integrations** | APIs, databases, file systems |5253For each dimension, enumerate all possible values with descriptions.5455### Phase 3: Calculate Complexity5657Show the theoretical test space size:5859```60Total Combinations = dim1_values × dim2_values × ... × dimN_values61```6263This demonstrates why exhaustive testing is intractable and justifies prioritization.6465### Phase 4: Create Prioritized Test Slices6667Instead of testing all combinations, create **2D slices** that cover high-value intersections:68691. **Slice by Risk × Usage**: Combinations likely to have bugs AND commonly used702. **Slice by Independence**: Orthogonal dimensions can be tested separately713. **Slice by Complexity**: Simple combinations first, then complex7273For each slice, create a table showing coverage status:74- Y = Full coverage75- P = Partial coverage 76- N = No coverage77- N/A = Not applicable7879Example slice format:80```81| Topology | SyncRunner | AsyncRunner |82|----------|:----------:|:-----------:|83| linear | Y | Y |84| diamond | Y | P |85| cycle | Y | N |8687**Status**: GOOD - `test_runners/` covers most combinations88**Gap**: Cycle topology with AsyncRunner needs coverage89```9091### Phase 5: Map Existing Tests9293Create a matrix mapping test files to dimensions:9495| Test File | Dim1 | Dim2 | Dim3 | ... |96|-----------|:----:|:----:|:----:|:---:|97| test_foo.py | Y | P | N/A | ... |9899This reveals which dimensions have good coverage vs gaps.100101### Phase 6: Gap Analysis102103For each gap, document with concrete test recommendations:104105```markdown106#### GAP-XX: [Descriptive Name]107**Matrix Position**: Dimension1 = value × Dimension2 = value108**Risk**: [Why this gap matters]109**Recommended Tests**:110```python111class TestGapName:112 def test_specific_scenario(self): ...113 def test_edge_case(self): ...114```115```116117**Focus on intersections, not individual dimensions** - gaps are most dangerous where multiple dimensions combine in untested ways.118119Prioritize gaps as HIGH / MEDIUM / LOW based on:120- **Risk**: Likelihood of bugs in this area121- **Impact**: Severity if bugs exist122- **Usage**: How often this code path is used123124### Phase 7: Recommendations125126Provide actionable output:1271281. **Coverage Score**: X/100 with per-dimension breakdown1292. **Top N Action Items**: Prioritized list of gaps to address1303. **New Test Files**: Suggested file names and estimated test counts1314. **Tests to Add to Existing Files**: Specific additions per file1325. **Test Type Distribution**: Current vs recommended (unit, integration, property-based, performance)133134## Output Format135136Generate a markdown document with these sections:137138```markdown139# [Project Name] Test Matrix Review140141## Overview142[Brief description of methodology and findings]143144## 1. Conceptual Test Matrix (N-Dimensional)145[Tables defining each dimension and its values]146147## 2. Full Matrix Combinations148[Calculation showing test space size]149150## 3. Prioritized Test Slices151[2D matrices with coverage status]152153## 4. Existing Test Coverage Map154[Test file × dimension matrix]155156## 5. Gap Analysis & Recommended Tests157[Prioritized gaps with specific test recommendations]158159## 6. Test Type Distribution160[Current vs recommended distribution]161162## 7. Summary163[Coverage score, action items, files to create]164165## Appendix: Test Matrix Visualization166[ASCII diagram showing test space structure]167```168169## Best Practices1701711. **Run Phase 1 explorations in parallel** - Use multiple Task agents to gather architecture and test info simultaneously1722. **Be exhaustive in dimension discovery** - Missing a dimension means missing test gaps1733. **Use domain terminology** - Dimensions should match how developers think about the code1744. **Focus on intersections** - Gaps at dimension intersections are more dangerous than single-dimension gaps1755. **Quantify everything** - Scores, counts, and percentages make gaps concrete and trackable over time1766. **Provide code snippets** - Show actual test class/method signatures for recommendations1777. **Consider test types** - Not just what to test, but how (unit, integration, property-based)1788. **Include edge cases** - Empty collections, None values, boundary conditions1799. **Track error conditions** - Both build-time validation and runtime errors180181## Example Dimensions by Domain182183### Web API184- HTTP methods, endpoints, auth states, request body types, response codes, error types185186### Data Pipeline 187- Source types, transformations, sinks, data formats, error handling, parallelism modes188189### State Machine190- States, transitions, events, guards, actions, error recovery191192### Compiler/Parser193- Token types, AST nodes, semantic rules, optimization passes, target outputs194195---196> Converted and distributed by [TomeVault](https://tomevault.io/claim/gilad-rubin) — claim your Tome and manage your conversions.197<!-- tomevault:4.0:skill_md:2026-04-11 -->