Skip to content

[#45] Fixed metrics doubling when formatter used with other formatters.#47

Merged
AlexSkrypnyk merged 1 commit intomainfrom
feature/45-metrics-double-combo
Nov 25, 2025
Merged

[#45] Fixed metrics doubling when formatter used with other formatters.#47
AlexSkrypnyk merged 1 commit intomainfrom
feature/45-metrics-double-combo

Conversation

@AlexSkrypnyk
Copy link
Member

@AlexSkrypnyk AlexSkrypnyk commented Nov 25, 2025

Closes #45

image

Summary by CodeRabbit

  • Bug Fixes

    • Fixed metrics duplication issue occurring when multiple formatters were used simultaneously, ensuring test statistics are reported accurately.
  • Tests

    • Added test scenario validating that metrics remain accurate and are not duplicated when multiple formatters are configured together.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request fixes a metrics duplication bug that occurred when the progress_fail formatter was used alongside other formatters. The solution introduces a dedicated TotalStatistics service for progress_fail instead of sharing the global statistics service, and includes a regression test to verify the fix.

Changes

Cohort / File(s) Summary
Service Registration and Statistics
src/DrevOps/BehatFormatProgressFail/FormatExtension.php
Introduced a new dedicated TotalStatistics service (output.progress_fail.statistics) and configured StatisticsListener, ScenarioStatsListener, StepStatsListener, and HookStatsListener to use it instead of the shared output.progress.statistics, preventing metric duplication when multiple formatters are active.
Test Coverage
tests/behat/features/format.feature
Added end-to-end test scenario "Metrics should not double when used with multiple formatters" to verify that running Behat with multiple formatters (progress and progress_fail) produces correct metrics without duplication.

Sequence Diagram(s)

sequenceDiagram
    participant Behat as Behat Runner
    participant ProgFormatter as Progress Formatter
    participant ProgFailFormatter as Progress_Fail Formatter
    participant SharedStats as Shared Statistics<br/>(Old Behavior)
    participant DedicatedStats as Dedicated Statistics<br/>(New Behavior)
    
    rect rgb(200, 220, 240)
    Note over Behat,DedicatedStats: Old Behavior (Metrics Doubled)
    end
    Behat->>ProgFormatter: test scenarios
    ProgFormatter->>SharedStats: increment counts
    Behat->>ProgFailFormatter: test scenarios
    ProgFailFormatter->>SharedStats: increment counts (duplicates!)
    Note over SharedStats: Both formatters share same counters
    
    rect rgb(220, 240, 200)
    Note over Behat,DedicatedStats: New Behavior (Metrics Correct)
    end
    Behat->>ProgFormatter: test scenarios
    ProgFormatter->>SharedStats: increment counts
    Behat->>ProgFailFormatter: test scenarios
    ProgFailFormatter->>DedicatedStats: increment counts (isolated)
    Note over DedicatedStats: Each formatter has own statistics
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • The fix is straightforward service registration and configuration changes following established patterns in the extension
  • The test scenario is a standard Behat feature test with clear expectations
  • Primary focus: verify the statistics service isolation logic is correctly implemented and the test adequately validates the fix
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/45-metrics-double-combo

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 490e9bf and 31dd209.

📒 Files selected for processing (2)
  • src/DrevOps/BehatFormatProgressFail/FormatExtension.php (3 hunks)
  • tests/behat/features/format.feature (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@AlexSkrypnyk AlexSkrypnyk merged commit 902a360 into main Nov 25, 2025
4 of 5 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/45-metrics-double-combo branch November 25, 2025 06:26
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.

Metrics double when used in combination with existing formatter

1 participant