Skip to content

Commit c1840c4

Browse files
author
LittleCoinCoin
committed
Merge branch 'feat/enhanced_discovery_display' into dev
2 parents b998f4d + b151542 commit c1840c4

19 files changed

+1911
-121
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,9 @@ yarn-error.log*
215215

216216
# Semantic-release
217217
.semantic-release/final_test.json
218+
219+
# Test artifacts and temporary files
220+
test_*.json
221+
discovery*.json
222+
discovery*.txt
223+
*.tmp

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ wobble --log-file test_results.json
3737
# CI/CD integration with file output
3838
wobble --format json --log-file ci_results.json --log-verbosity 3
3939

40+
# Enhanced test discovery
41+
wobble --discover-only # Show test counts by category
42+
wobble --discover-only --discover-verbosity 2 # Show uncategorized test details
43+
wobble --discover-only --discover-verbosity 3 # Show all tests with decorators
44+
45+
# Test execution with decorator display
46+
wobble --verbose # Shows [@decorator_name] for each test
47+
4048
# Get help
4149
wobble --help
4250
```
@@ -73,6 +81,27 @@ wobble --verbose
7381
python -m unittest discover tests
7482
```
7583

84+
### Enhanced Discovery Features
85+
86+
Wobble provides enhanced test discovery with multiple verbosity levels and decorator display:
87+
88+
```bash
89+
# Discovery verbosity levels
90+
wobble --discover-only --discover-verbosity 1 # Test counts by category (default)
91+
wobble --discover-only --discover-verbosity 2 # + Uncategorized test details
92+
wobble --discover-only --discover-verbosity 3 # + All tests with decorator info
93+
94+
# Test execution with decorator display
95+
wobble --verbose # Shows [@decorator_name] for tests
96+
wobble --category regression --verbose # Regression tests with decorators
97+
```
98+
99+
**Decorator Display Examples:**
100+
- `[@regression_test]` - Regression test
101+
- `[@integration_test]` - Integration test
102+
- `[@slow_test]` - Slow-running test
103+
- `[@regression_test, @slow_test]` - Multiple decorators
104+
76105
### Making Commits
77106

78107
We use [Conventional Commits](https://www.conventionalcommits.org/) for automated versioning:

docs/articles/devs/architecture/Overview.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,91 @@ wobble/
2727

2828
### Test Discovery Engine (`discovery.py`)
2929

30-
**Responsibility**: Locate and categorize tests across different repository structures.
30+
**Responsibility**: Locate and categorize tests across different repository structures with enhanced logging and file output capabilities.
3131

3232
**Key Classes**:
33-
- `TestDiscoveryEngine`: Main discovery coordinator
33+
- `TestDiscoveryEngine`: Main discovery coordinator with progressive verbosity support
3434
- Supports hierarchical (`tests/regression/`) and flat (decorator-based) structures
3535
- Provides filtering capabilities by category, performance, and environment
36+
- Implements structured data output for JSON serialization and file integration
3637

3738
**Design Patterns**:
3839
- **Strategy Pattern**: Different discovery strategies for hierarchical vs. flat structures
3940
- **Factory Pattern**: Test suite creation from discovered test information
4041
- **Filter Pattern**: Composable test filtering by multiple criteria
42+
- **Observer Pattern**: Integration with file output system for dual console/file logging
43+
44+
**Enhanced Discovery Features**:
45+
- **Progressive Verbosity**: Three levels of detail with distinct JSON structures:
46+
- Level 1: Basic counts only (`categories` field)
47+
- Level 2: Level 1 + `uncategorized` field with test details
48+
- Level 3: Level 1 + `tests_by_category` field with complete test listings
49+
- **File Path Detection**: Automatic detection and formatting of test file locations
50+
- **JSON Serialization**: Structured data output compatible with programmatic analysis
51+
- **Decorator Information**: Complete decorator metadata in detailed discovery output
4152

4253
**Key Methods**:
4354
```python
4455
def discover_tests(pattern: str) -> Dict[str, List]
4556
def filter_tests(categories: List[str], exclude_slow: bool, exclude_ci: bool) -> List[Dict]
57+
def get_discovery_summary(verbosity: int = 1) -> str
58+
def get_discovery_data(verbosity: int = 1) -> Dict[str, Any]
59+
def get_test_summary() -> str
4660
def supports_hierarchical_structure() -> bool
4761
def supports_decorator_structure() -> bool
4862
```
4963

64+
**Discovery Data Structure**:
65+
```python
66+
{
67+
"discovery_summary": {
68+
"timestamp": "2025-09-15T10:30:00.123456",
69+
"total_tests": 42,
70+
"categories": {
71+
"regression": 15,
72+
"integration": 12,
73+
"development": 8,
74+
"uncategorized": 7
75+
},
76+
# Verbosity level 2: uncategorized test details
77+
"uncategorized": [ # Only present at verbosity level 2
78+
{
79+
"name": "test_example",
80+
"class": "TestExample",
81+
"module": "test_example",
82+
"file": "tests/test_example.py",
83+
"full_name": "test_example.TestExample.test_example",
84+
"decorators": ["@slow_test"]
85+
}
86+
],
87+
88+
# Verbosity level 3: complete test listings by category
89+
"tests_by_category": { # Only present at verbosity level 3
90+
"regression": [
91+
{
92+
"name": "TestRegression.test_feature",
93+
"class": "TestRegression",
94+
"module": "test_regression",
95+
"file": "tests/test_regression.py",
96+
"full_name": "test_regression.TestRegression.test_feature",
97+
"decorators": ["@regression_test"]
98+
}
99+
],
100+
"uncategorized": [
101+
{
102+
"name": "test_example",
103+
"class": "TestExample",
104+
"module": "test_example",
105+
"file": "tests/test_example.py",
106+
"full_name": "test_example.TestExample.test_example",
107+
"decorators": ["@slow_test"]
108+
}
109+
]
110+
}
111+
}
112+
}
113+
```
114+
50115
### Decorator System (`decorators.py`)
51116

52117
**Responsibility**: Provide test categorization and metadata attachment.
@@ -149,6 +214,14 @@ def supports_decorator_structure() -> bool
149214
- Multiple output destinations (console + file simultaneously)
150215
- Format-specific strategies with auto-detection
151216
- Graceful error handling and resource cleanup
217+
- Discovery mode integration with independent verbosity control
218+
219+
**Discovery Integration**:
220+
- Discovery results support both console and file output simultaneously
221+
- Independent verbosity control: `--discover-verbosity` for console, `--log-verbosity` for file
222+
- JSON format support for structured discovery data with complete test metadata
223+
- File path detection and serialization for programmatic analysis
224+
- Event-driven architecture enables discovery output through observer pattern
152225

153226
**Threading Architecture**:
154227
```python

docs/articles/users/CLIReference.md

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,49 @@ wobble --quiet
179179
Analyze tests without executing them:
180180

181181
```bash
182-
--discover-only # Only discover tests, do not run them
183-
--list-categories # List available test categories and exit
182+
--discover-only # Only discover tests, do not run them
183+
--discover-verbosity {1,2,3} # Control discovery output detail level
184+
--list-categories # List available test categories and exit
184185
```
185186

187+
### Discovery Verbosity Levels
188+
189+
Control the amount of detail in discovery output:
190+
191+
- **Level 1 (Default)**: Test counts by category
192+
- **Level 2**: Level 1 + detailed uncategorized test listings
193+
- **Level 3**: Level 2 + complete test listings with file paths and decorators
194+
186195
**Examples:**
187196
```bash
188-
# See what tests would be discovered
197+
# Basic discovery (counts only)
189198
wobble --discover-only
190199

191-
# Get JSON summary of discovered tests
192-
wobble --discover-only --format json
200+
# Show uncategorized test details
201+
wobble --discover-only --discover-verbosity 2
202+
203+
# Complete discovery report with all details
204+
wobble --discover-only --discover-verbosity 3
193205

194206
# List available categories
195207
wobble --list-categories
196208
```
197209

210+
### Discovery Output Formats
211+
212+
Discovery results can be output in different formats:
213+
214+
```bash
215+
# Console output with file logging
216+
wobble --discover-only --log-file discovery.txt
217+
218+
# JSON format for programmatic use
219+
wobble --discover-only --log-file discovery.json --log-file-format json
220+
221+
# Different verbosity for console vs file
222+
wobble --discover-only --discover-verbosity 1 --log-file detailed.txt --log-verbosity 3
223+
```
224+
198225
## Repository Options
199226

200227
### Path Specification
@@ -302,6 +329,26 @@ wobble --log-file detailed.json --log-verbosity 2
302329
wobble --log-file complete.json --log-verbosity 3
303330
```
304331

332+
### Discovery Mode File Output
333+
334+
When using `--discover-only`, file output behavior adapts to discovery mode:
335+
336+
```bash
337+
# Discovery with independent console/file verbosity
338+
wobble --discover-only --discover-verbosity 1 --log-file discovery.json --log-verbosity 3
339+
340+
# JSON discovery output with complete test details
341+
wobble --discover-only --log-file discovery.json --log-file-format json --log-verbosity 3
342+
343+
# Text discovery output with basic counts
344+
wobble --discover-only --log-file discovery.txt --log-file-format txt --log-verbosity 1
345+
```
346+
347+
**Discovery Verbosity Mapping:**
348+
- `--log-verbosity 1`: Test counts by category
349+
- `--log-verbosity 2`: Counts + uncategorized test details
350+
- `--log-verbosity 3`: Complete test listings with file paths and decorators
351+
305352
### File Management Options
306353

307354
Control how files are handled:

docs/articles/users/GettingStarted.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,32 @@ wobble --quiet
6060
Understand what tests wobble finds in your repository:
6161

6262
```bash
63-
# Discover tests without running them
63+
# Basic discovery (test counts by category)
6464
wobble --discover-only
6565

66+
# Detailed discovery with uncategorized test listings
67+
wobble --discover-only --discover-verbosity 2
68+
69+
# Complete discovery with file paths and decorators
70+
wobble --discover-only --discover-verbosity 3
71+
6672
# List available test categories
6773
wobble --list-categories
74+
```
75+
76+
### Discovery Output Options
77+
78+
Save discovery results to files for analysis:
79+
80+
```bash
81+
# Save discovery results to text file
82+
wobble --discover-only --log-file discovery.txt
83+
84+
# Save as JSON for programmatic use
85+
wobble --discover-only --log-file discovery.json --log-file-format json
6886

69-
# JSON output for programmatic use
70-
wobble --discover-only --format json
87+
# Different detail levels for console vs file
88+
wobble --discover-only --discover-verbosity 1 --log-file detailed.json --log-verbosity 3
7189
```
7290

7391
### Category-Based Execution

docs/articles/users/IntegrationGuide.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,15 @@ wobble --format json --exclude-ci
346346
```bash
347347
# Compare test counts
348348
python -m unittest discover tests --dry-run | wc -l
349-
wobble --discover-only --format json | jq '.total_tests'
349+
wobble --discover-only --log-file discovery.json --log-file-format json
350+
cat discovery.json | jq '.discovery_summary.total_tests'
351+
352+
# Detailed discovery analysis
353+
wobble --discover-only --discover-verbosity 3 --log-file detailed_discovery.txt
354+
355+
# Validate category distribution
356+
wobble --discover-only --log-file discovery.json --log-file-format json
357+
cat discovery.json | jq '.discovery_summary.categories'
350358
```
351359

352360
**Execution validation**:

docs/articles/users/TestOrganization.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,17 @@ wobble --category regression
290290
### Test Organization Validation
291291

292292
```bash
293-
# Verify test discovery
294-
wobble --discover-only --format json
293+
# Basic test discovery with counts
294+
wobble --discover-only
295+
296+
# Detailed discovery with uncategorized test analysis
297+
wobble --discover-only --discover-verbosity 2
298+
299+
# Complete discovery report with file paths and decorators
300+
wobble --discover-only --discover-verbosity 3
301+
302+
# Save discovery analysis to file for review
303+
wobble --discover-only --log-file organization_analysis.json --log-file-format json --log-verbosity 3
295304

296305
# Check category distribution
297306
wobble --list-categories

tests/test_data_structures.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
TestStatus, ErrorInfo, TestResult, TestRunSummary,
1818
TestResultEncoder, serialize_test_results, format_test_results_text
1919
)
20+
from tests.test_data_utils import (
21+
get_test_result_template, get_timing_config, get_command_template
22+
)
2023

2124

2225
class TestTestStatus(unittest.TestCase):
@@ -35,15 +38,18 @@ class TestErrorInfo(unittest.TestCase):
3538

3639
def test_error_info_creation(self):
3740
"""Test basic ErrorInfo creation."""
41+
# Get error info template from centralized test data
42+
error_template = get_test_result_template('with_error_info')['error_info']
43+
3844
error = ErrorInfo(
39-
type="AssertionError",
40-
message="Expected 5, got 3",
41-
traceback="Traceback (most recent call last)..."
45+
type=error_template['type'],
46+
message=error_template['message'],
47+
traceback=error_template['traceback']
4248
)
43-
44-
self.assertEqual(error.type, "AssertionError")
45-
self.assertEqual(error.message, "Expected 5, got 3")
46-
self.assertEqual(error.traceback, "Traceback (most recent call last)...")
49+
50+
self.assertEqual(error.type, error_template['type'])
51+
self.assertEqual(error.message, error_template['message'])
52+
self.assertEqual(error.traceback, error_template['traceback'])
4753
self.assertIsNone(error.file_path)
4854
self.assertIsNone(error.line_number)
4955

@@ -116,27 +122,35 @@ class TestTestResult(unittest.TestCase):
116122

117123
def setUp(self):
118124
"""Set up test fixtures."""
119-
self.timestamp = datetime(2024, 1, 15, 14, 30, 25)
125+
# Get standard timestamp from centralized test data
126+
timestamp_str = get_timing_config('standard_timestamp')
127+
self.timestamp = datetime.fromisoformat(timestamp_str)
128+
129+
# Get error info template from centralized test data
130+
error_template = get_test_result_template('with_error_info')['error_info']
120131
self.error_info = ErrorInfo(
121-
type="AssertionError",
122-
message="Expected 5, got 3",
123-
traceback="Traceback (most recent call last)..."
132+
type=error_template['type'],
133+
message=error_template['message'],
134+
traceback=error_template['traceback']
124135
)
125136

126137
def test_test_result_creation(self):
127138
"""Test basic TestResult creation."""
139+
# Get test result template from centralized test data
140+
template = get_test_result_template('test_example')
141+
128142
result = TestResult(
129-
name="test_example",
130-
classname="TestClass",
143+
name=template['name'],
144+
classname=template['classname'],
131145
status=TestStatus.PASS,
132-
duration=0.123,
146+
duration=template['duration'],
133147
timestamp=self.timestamp
134148
)
135-
136-
self.assertEqual(result.name, "test_example")
137-
self.assertEqual(result.classname, "TestClass")
149+
150+
self.assertEqual(result.name, template['name'])
151+
self.assertEqual(result.classname, template['classname'])
138152
self.assertEqual(result.status, TestStatus.PASS)
139-
self.assertEqual(result.duration, 0.123)
153+
self.assertEqual(result.duration, template['duration'])
140154
self.assertEqual(result.timestamp, self.timestamp)
141155
self.assertEqual(result.metadata, {})
142156
self.assertIsNone(result.error_info)

0 commit comments

Comments
 (0)