Commit 7662be6
feat: Add test count summary to display total and skipped tests (#307)
## Summary
Adds a test count summary that displays at the end of each test run
showing the total number of tests attempted, how many were skipped, and
how many actually ran.
## Changes
- **New `CountingTestLogger` wrapper**
(`framework/ldtest/test_logger.go`):
- Wraps any existing `TestLogger` implementation
- Tracks test counts by intercepting `TestStarted` and `TestSkipped`
calls
- Thread-safe using `sync.Mutex` for concurrent test execution
- Provides `GetCounts()` method to retrieve counts
- **Updated test execution** (`main.go`):
- Wraps the configured test logger with `CountingTestLogger`
- Prints summary after test completion: `Test Summary: X total, Y
skipped, Z ran`
- Summary appears regardless of pass/fail status
## Example Output
```
All tests passed
Test Summary: 150 total, 12 skipped, 138 ran
```
## Important Review Points
1. **No unit tests added**: While existing tests pass and the code
compiles, I didn't add specific unit tests for the new
`CountingTestLogger`. Consider whether these should be added.
2. **Output placement**: The summary appears after the existing
pass/fail messages and any failure listings. Verify this placement meets
expectations.
3. **Count interpretation**:
- "Total" = all tests that were attempted (called `TestStarted`)
- "Skipped" = tests filtered out or explicitly skipped (called
`TestSkipped`)
- "Ran" = Total - Skipped
4. **Cannot test with real SDK**: I verified the code compiles, passes
existing tests, and passes linting, but couldn't test against an actual
SDK test service to see the output in practice.
---
**Requirements**
- [ ] I have added test coverage for new or changed functionality *(No
unit tests added for CountingTestLogger)*
- [x] I have followed the repository's [pull request submission
guidelines](../blob/master/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions *(Code compiles, existing tests pass, linting passes)*
**Related issues**
Requested by [email protected] in Slack thread:
https://launchdarkly.slack.com/archives/C03DEV5CMFD/p1761927792275089
**Describe the solution you've provided**
Implemented a transparent wrapper (`CountingTestLogger`) that tracks
test counts by intercepting `TestStarted` and `TestSkipped` calls. The
wrapper delegates all calls to the underlying logger, ensuring existing
functionality remains unchanged. At the end of test execution, a summary
line is printed showing total tests, skipped tests, and tests that
actually ran.
**Describe alternatives you've considered**
1. **Modifying the `Results` struct**: Could have added count fields to
`Results`, but this would require more invasive changes throughout the
test execution logic.
2. **Only showing total and skipped**: The requirement asked for "total
ran" and "skipped", but showing all three numbers (total, skipped, ran)
provides more clarity about what "ran" means.
3. **Different output format**: Could format as "X tests ran (Y
skipped)" but the current format "X total, Y skipped, Z ran" is more
explicit.
**Additional context**
Link to Devin run:
https://app.devin.ai/sessions/61b07c9217f54e62848d32fc3b5136b1
Requested by: [email protected]
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>1 parent 3d958bc commit 7662be6
2 files changed
+54
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
47 | 93 | | |
48 | 94 | | |
49 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
| |||
0 commit comments