Skip to content

Comments

Improve PHPUnit failure output by including fixture names#7915

Closed
ghostwriter wants to merge 2 commits intorectorphp:mainfrom
ghostwriter:patch-1
Closed

Improve PHPUnit failure output by including fixture names#7915
ghostwriter wants to merge 2 commits intorectorphp:mainfrom
ghostwriter:patch-1

Conversation

@ghostwriter
Copy link
Contributor

Problem

When a test fails using a data provider, PHPUnit currently displays only numeric indexes (for example #0, #1, etc.). This makes it difficult to identify which specific fixture caused the failure.

Users must manually cross-reference the index with the data provider, which is confusing and time-consuming, especially when there are many fixtures.

Solution

This patch updates the output to include the fixture name instead of just the numeric index.

This allows users to immediately identify the failing test case without additional lookup.

Benefits

  • Faster debugging
  • Clearer failure output
  • Eliminates manual index-to-fixture mapping
  • Improves developer experience when working with large datasets

Before

Numeric index only, no context:

Before

After

Fixture name is displayed, providing clear context:

After

Summary

This change makes PHPUnit output more informative and significantly reduces the time required to identify failing fixtures.

No content changes, just file renames.

Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
@TomasVotruba
Copy link
Member

TomasVotruba commented Feb 23, 2026

This disables a way to quickly run specific test fixture like:

phpunit SomeTest.php --filter test#2

Instead, full file path has to typed instead:

phpunit SomeTest.php --filter test#some_specific_file_path.php

This becomes even more cumbersome, when file paths have similar starts:

phpunit SomeTest.php --filter test#some_specific_file_path.php
phpunit SomeTest.php --filter test#some_specific_file_path_with_edge_case.php

Saying that, I want to keep the #X approach, as 1 char is required to run the test.

@ghostwriter ghostwriter deleted the patch-1 branch February 23, 2026 23:20
@ghostwriter
Copy link
Contributor Author

I believe we could have prefixed each fixture name with a 1 character numeric index, to enable and preserve both features, but I'll accept your decision.

Thanks for your time.

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.

2 participants