Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure is confusing when asserting a string matches a format #6026

Open
stof opened this issue Nov 7, 2024 · 2 comments
Open
Labels
feature/assertion Issues related to assertions and expectations feature/phpt End-to-end tests in PHPT format type/enhancement A new idea that should be implemented

Comments

@stof
Copy link
Contributor

stof commented Nov 7, 2024

When asserting a string matches a format fails, the failure produces a string diff between the string and the expected format. This is quite confusing because this diff will report differences for each placeholder in the expected format, even when the corresponding content in the string matched that placeholder (and the issue was elsewhere)

@stof stof added the type/enhancement A new idea that should be implemented label Nov 7, 2024
@sebastianbergmann sebastianbergmann added feature/phpt End-to-end tests in PHPT format feature/assertion Issues related to assertions and expectations labels Nov 7, 2024
@sebastianbergmann
Copy link
Owner

I agree that this is confusing, but this is, AFAIK, how the official PHPT test runner has always worked. I mention PHPT here because assertStringMatchesFormat() (re)uses the code for EXPECTF handling in PHPT tests.

@stof
Copy link
Contributor Author

stof commented Nov 7, 2024

Well, doing a format-aware diffing is more complex. But if the logic is implemented, maybe the official PHPT test runner would also accept using it to provide better failure reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/assertion Issues related to assertions and expectations feature/phpt End-to-end tests in PHPT format type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

2 participants