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

Use failure with actual and expected message to improve IDE experience for ObservationContextAssert #5550

Merged

Conversation

filiphr
Copy link
Contributor

@filiphr filiphr commented Oct 5, 2024

The goal of this PR is to improve the user experience when an assertion fails in an IDE.

e.g. the error messages prior this PR in IntelliJ look like:

old_hasContextualNameEqualToIgnoringCase
old_hasHighCardinalityKeyValue
old_hasNameEqualToIgnoringCase
old_hasLowCardinalityKeyValue
old_hasNameEqualTo
old_hasContextualNameEqualTo

After this PR they look like:

new_hasContextualNameEqualToIgnoringCase
new_hasHighCardinalityKeyValue
new_hasNameEqualToIgnoringCase
new_hasLowCardinalityKeyValue
new_hasNameEqualTo
new_hasContextualNameEqualTo

The difference is that Intellij knows how to handle the AssertionFailedError and display the nice "Click to see difference" in the UI. The AssertJ library will handle failWithActualExpectedAndMessage properly and fallback to AssertionError in case the AssertionFailedError from opentest4j is not available.

Copy link
Member

@shakuzen shakuzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@shakuzen shakuzen added this to the 1.14.0-RC1 milestone Oct 7, 2024
@marcingrzejszczak
Copy link
Contributor

Great suggestion, thank you!

@filiphr filiphr force-pushed the improved-assertion-failure branch from c272a35 to 412fd9c Compare October 7, 2024 08:18
@filiphr
Copy link
Contributor Author

filiphr commented Oct 7, 2024

Thanks @shakuzen and @marcingrzejszczak. I've also rebased this on top of main and the CircleCI is now running

@shakuzen shakuzen merged commit 4a29322 into micrometer-metrics:main Oct 7, 2024
7 checks passed
@filiphr filiphr deleted the improved-assertion-failure branch October 7, 2024 08:41
izeye added a commit to izeye/micrometer that referenced this pull request Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants