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

Allow navigating to the exact line where a test failed #417

Open
adamw opened this issue Jan 22, 2025 · 2 comments · May be fixed by scalameta/metals-vscode#1571
Open

Allow navigating to the exact line where a test failed #417

adamw opened this issue Jan 22, 2025 · 2 comments · May be fixed by scalameta/metals-vscode#1571

Comments

@adamw
Copy link

adamw commented Jan 22, 2025

Is your feature request related to a problem? Please describe.

Currently, when a test fails, the IDE shows the failure message next to the beginning of the test:

Image

However, it is not possible to determine where exactly the problem occurred; to obtain that information.

Describe the solution you'd like

It would be much better if it would be possible to navigate to the exact line where the failure occurred.

Describe alternatives you've considered

It's necessary to run the test through SBT (and the cmd+click on the failing assertion).

Additional context

No response

Search terms

testing

@tgodzik
Copy link
Contributor

tgodzik commented Jan 22, 2025

Thanks for reporting!

I looked into this in VS Code and it seems we have place where to put the location at, but it's a bit harder to get the actual position. With a failed message we get for example a string like:

"* org.virtuslab.yaml.parser.CommentSpec.empty document - munit.ComparisonFailException: /home/tgodzik/Documents/scala-yaml/core/shared/src/test/scala/org/virtuslab/yaml/parser/CommentSuite.scala:37\n36:    assertEquals(yaml.events, Right(expectedEvents))\n\u001b[7m37:    assertEquals(\"aa\", \"bbb\")\u001b[0m\n38:  }\nvalues are not the same\n\u001b[1m=> Obtained\u001b[0m\naa\n\u001b[1m=> Diff\u001b[0m (\u001b[91m- obtained\u001b[0m, \u001b[92m+ expected\u001b[0m)\n\u001b[91m-aa\u001b[0m\n\u001b[92m+bbb\u001b[0m"

We could look for the first path the translate that, though not sure if it would work old the time. It would be cool to get the data properly from the test runner, but it doesn't seem to have that capability.

Current quick and a bit hacky solution is use regex to find a file path in that string and point to that.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 23, 2025

Looks to work, so maybe that's good enough scalameta/metals-vscode#1571

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 a pull request may close this issue.

2 participants