Issafalcon / neotest-dotnet

Neotest adapter for dotnet
MIT License
73 stars 29 forks source link

Diagnostics message misplaced #66

Closed veyxov closed 1 year ago

veyxov commented 1 year ago

Problem

image

The error which is thrown in the assertion, is showing beside the [Fact] attribute. Should be on the assertion line, where the exception occurred.

versions

neovim - 0.9.1 dotnet - 7.0.107

Thank you for your great work 🙏

Issafalcon commented 1 year ago

Hi @veyxov - Thanks for opening an issue. I'm afraid this isn't something that the neotest-dotnet adapter can control, and it's rather a feature of neotest (core).

The way neotest determines the position in the file that the test is located and also the position where the test error output should be linked to, is by taking the beginning of the treesitter range where the query matches the test definition. In this case, it's where the Fact attribute starts. I can't modify where this position is, and if I did it in the adapter, it would break how neotest (core) works.

I know in other IDEs, that the position where the error was thrown is given in the output, and it may be possible to parse this position from the stack trace, find the point in the test itself that originated the call further up in the stack, fetch the error output for that particular test via neotest, create a new diagnostic message, and insert it into the diagnostic error list in neovim. However, to do that as part of the neotest adapter isn't something on my roadmap for the adapter itself. That said, I would happily consider a PR for that feature.

Issafalcon commented 1 year ago

Closing this as there are no plans to implement it.