Skip to content

Improved test failure message #78

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

Merged
merged 2 commits into from
Jun 14, 2025
Merged

Improved test failure message #78

merged 2 commits into from
Jun 14, 2025

Conversation

elmuerte
Copy link
Contributor

@elmuerte elmuerte commented Jun 10, 2025

The original test failure message only contained the assertion failure message which does not give a lot of information. Especially in larger test cases it can be difficult to find out which assertion failed. So I expanded the failure message to include all notification lines, which includes the assertion statement that failed and the relevant backtrace. The produced message is quite similar to the RSpec default message.

image

I adjusted the path of the backtrace to a file URI which VSCode would pick up and allow you to quickly jump the relevant line in the test. This however does not work yet when using VSCode while developing on WSL, I logged an issue with vscode for that. But at least this gives you the line number so you can manually navigate to it.

Includes the failed statement and the backtrace.
@elmuerte
Copy link
Contributor Author

That's unfortunate that they changed the formatting of the backtrack in Ruby 3.4. It'll be challenging to fix that matcher.

In rube 3.4 the formatted backtrace does not use the backtick (`) but
encloses the label with only single quotes.
@elmuerte
Copy link
Contributor Author

That's unfortunate that they changed the formatting of the backtrack in Ruby 3.4. It'll be challenging to fix that matcher.

That was surprisingly easy to fix. The "match" matcher takes care of evaluating against regex in the expected value.

@st0012 st0012 added the enhancement New feature or request label Jun 14, 2025
Copy link
Owner

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

This is great! Thank you!

@st0012 st0012 merged commit cf92404 into st0012:main Jun 14, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants