Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

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)
  • I have followed the repository's pull request submission guidelines
  • 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]

- Created CountingTestLogger wrapper to track test counts
- Wraps existing TestLogger implementations transparently
- Counts total tests started and tests skipped
- Prints summary at end: 'Test Summary: X total, Y skipped, Z ran'
- Summary appears regardless of pass/fail status
- Thread-safe using mutex for concurrent test execution

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner October 31, 2025 16:34
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@kinyoklion kinyoklion changed the title Add test count summary to display total and skipped tests feat: Add test count summary to display total and skipped tests Oct 31, 2025
@kinyoklion
Copy link
Member

Could this functionality be directly added to the existing logger instead of being a wrapper?

@devin-ai-integration
Copy link
Contributor Author

Thank you for the feedback! I considered both approaches and went with the wrapper pattern for a few reasons:

Wrapper approach (current implementation):

  • Non-invasive to existing code - doesn't require modifying ConsoleTestLogger or JUnitTestLogger
  • Follows the decorator pattern, which is a standard design pattern for adding functionality transparently
  • Can wrap any TestLogger implementation, including custom ones users might have
  • Clear separation of concerns - counting logic is isolated in one place
  • Easy to add/remove without touching existing loggers

Direct integration alternative:

  • Would need to modify both ConsoleTestLogger and JUnitTestLogger to add the counting logic
  • JUnitTestLogger already tracks counts internally for XML output (line 156: suite.Tests++), so adding more counting might be redundant
  • Would duplicate the counting logic across multiple logger implementations
  • More invasive changes to existing, working code

That said, I'm happy to refactor to the direct approach if that's the team's preference! The main tradeoff is between:

  • Wrapper: One extra layer of indirection, but cleaner separation and no changes to existing loggers
  • Direct: No wrapper layer, but requires modifying existing loggers and potentially duplicating logic

Which approach would you prefer for this codebase?

@kinyoklion kinyoklion merged commit 7662be6 into v2 Oct 31, 2025
3 checks passed
@kinyoklion kinyoklion deleted the devin/1761928379-test-count-summary branch October 31, 2025 16:51
kinyoklion pushed a commit that referenced this pull request Oct 31, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.33.0](v2.32.1...v2.33.0)
(2025-10-31)


### Features

* Add test count summary to display total and skipped tests
([#307](#307))
([7662be6](7662be6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kinyoklion added a commit that referenced this pull request Dec 12, 2025
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants