neotest-dotnet Adapter #24
-
Hi @rcarriga. Firstly, I'd like to say, you're doing an amazing job crafting the testing ecosystem in neovim! The extensible unified framework approach is great! I'd like to get involved. I'm working on making dotnet development better in neovim, and I'm creating a plugin to extend the omnisharp lsp. I got up to writing some stuff for the testing side (much like how omnisharp-vim has a built in testing solution), but then I saw nvim-neotest, and thought it would be a much better idea to create an adapter for the testing functionality for dotnet. I was hoping you, or other contributors might be able to help me translate what I have into an adapter. Here is what I have so far:
For completion, here is the
To summarise, I am leveraging the I'm not entirely sure what this might look like in a neotest adapter (reading through the existing ones, I have some idea, but not sure if it would work in the same way as I have it in the code above). So my questions are:
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 31 replies
-
Hey delighted to hear you want to work on this!
I don't think that'd be unreasonable especially if it's a popular LSP for dotnet (I'm not at all familiar to I've no idea 😅).
If you're going to implement the treesitter anyway, does it still make sense to use the LSP as well? Is there some metadata that LSP provides that you can't get with treesitter? Of course there's no reason not to use LSP other than the potential issues of maintaining two solutions with one perhaps being neglected.
That's an interesting one, you could just start the process before returning the arguments to provide to nvim-dap. So your plugin would completely control the process and then return the nvim-dap args once it is ready to go. All of the adapter functions can be async so you can wait, poll etc without blocking NeoVim. |
Beta Was this translation helpful? Give feedback.
-
OK that all makes a lot of sense 👍 Sounds good! In terms of advice, the current documentation should be a good start but there is definitely some things lacking. Also have a look at the existing issues/repos for other adapters #9 #6 #5, you might find them useful. The main issue people seem to have is result collection which makes sense so feel free to ask for advice with specific problems. Also if you're using sumneko_lua LSP I'd recommend enabling type checking for |
Beta Was this translation helpful? Give feedback.
-
Hey @Issafalcon I'm a developer working with .NET & Neovim. I found your post while searching if there anyone mentioned a neotest adapter for .NET. I'd love to join forces with you and contribute in developing & testing this adapter and to build a better .NET development experience in Neovim in general ^^ |
Beta Was this translation helpful? Give feedback.
-
Hi @rcarriga - I've made a start on the adapter https://github.com/Issafalcon/neotest-dotnet. It would be good to get your opinion on the following approach. Essentially it boils down to the 'using LSP vs using treesitter' discussion above. The LSP methods offer all the metadata I think I need (class names, namespace names, method names, ranges), but not in the format treesitter might return. The other caveat, is that the project needs to have been built using the
FYI - @iabdelkareem - If you're keen to help on this, I'll create some initial issue items against the repo once we determine the best approach. |
Beta Was this translation helpful? Give feedback.
-
Hi @rcarriga. By way of an update, I'm making some good (albeit slow) progress with the dotnet adapter. I'm using a luarocks module I did notice the new #70 stream option, but the test output streamed directly from the runner is nowhere near as well structured as the trx. Anyway, if using luarocks isn't a deal-breaker for an adapter, I'll carry on with the current implementation, and it shouldn't be too long before it's usable. |
Beta Was this translation helpful? Give feedback.
-
Hi @rcarriga - So, after a lot of back and forth on a few approaches, I think I've finally got something that can be widely used. https://github.com/Issafalcon/neotest-dotnet. There are many more features that can be added (debugging, itemized test output files with more verbose detail etc.) but I hope it's good enough to be incorporated into the ecosystem as a start! |
Beta Was this translation helpful? Give feedback.
-
Hi @rcarriga . So I'm trying to add support for parameterized tests in the dotnet adapter. The tests are parameterized by adding an attribute per additional test above the main test method. My idea is to customize the build_position function in the treesitter parser and then add separate test nodes (each requiring a custom test name so dotnet runs correctly) for each of the attributes. My question is, how does neotest determine what is a nested test? I'd like each of the parameterized tests to nest underneath the main test method in the summary list. Is it determined by the treesitter ranges alone, or do the test nodes need to be parsed in a particular order as well? |
Beta Was this translation helpful? Give feedback.
-
Hi @rcarriga - I have another question for you, as I've hit a hurdle I can't think how to overcome. Maybe it's just not possible yet. Having implemented debugging support in neotest-dotnet (entry point https://github.com/Issafalcon/neotest-dotnet/blob/4e71023855e4de9053c43e0829b2be439b3d33ec/lua/neotest-dotnet/init.lua#L129). I've started the debug process outside the workings of neotest core, so that I can wait for the subprocess ID of the dotnet runner to be returned from the output in order to attach the debugger. It's working well, and I'm outputting the results from the dotnet test command in a new buffer. However, the issue is that neotest picks up the output from the netcoredbg process, which doesn't contain the output from the actual test. I've added a screencast to the adapter github page https://github.com/Issafalcon/neotest-dotnet so you can see what I mean. I think it's because neotest might be creating a different results file when using debug strategy, which isn't a trx file (so when I try and parse it, it fails and looks like the test run failed). Is there a simple way to fix this? At the moment I just inform people that debugging will always produce a failed output, but at least the additional stream output is there in the other buffer so they can see the actual test results. |
Beta Was this translation helpful? Give feedback.
-
Hi @rcarriga. I'm looking at implementing a new feature, to discover parameterized tests that are not inline. This requires actually compiling the C# code. See Issafalcon/neotest-dotnet#55 for details. My question for you is, what would be the best way of running the |
Beta Was this translation helpful? Give feedback.
Hey delighted to hear you want to work on this!
I don't think that'd be unreasonable especially if it's a popular LSP for dotnet (I'm not at all familiar to I've no idea 😅).
If you're going to implement the treesitter anyway, does it still make sense to use the LSP as well? Is there some metadata that LSP provides that you can't get with treesitte…