nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.35k stars 115 forks source link

[Bug] Only update results of positions that were run #142

Open halfdan opened 1 year ago

halfdan commented 1 year ago

I frequently iterate through tests one by one - especially if I have multiple failing tests I will not rerun the entire file/suite but invoke neotest to run the nearest test.

In it's current implementation (with the Elixir plugin) all tests except one in a single file will be shown as skipped. I would like to keep the last known passing/failing state until I rerun the entire file.

halfdan commented 1 year ago

In simpler words: Only update the state of tests that were actively re-run.

jfpedroza commented 1 year ago

I had in mind to solve this on the adapter side. The skips happen because when you run the nearest test, you are adding a filter to ExUnit and so ExUnit reports the other tests as skipped.

We can solve it by not reporting skipped tests if the type of position is "test".

halfdan commented 1 year ago

@jfpedroza I might take a stab at it tomorrow on the adapter then. Would still be nice if neotest would be able to filter it out.

rcarriga commented 1 year ago

Yes I do agree that neotest should not accept results that were not in the original tree :+1:

jfpedroza commented 1 year ago

I see you changed it to a bug. Would it be possible to set it as an option?

I got the Elixir adapter to work with the test watcher I mentioned, and since it allows me to change the files to run interactively, fixing this would make it not set the results for tests not initially run.

rcarriga commented 1 year ago

I might be misunderstanding, but shouldn't the test watcher only watch the tests that are chosen by the user? So if they select a specific file, then just that file is run?

jfpedroza commented 1 year ago

Yes, but there is an interactive feature (apparently based on Jest's) that lets you change what is run, without restating the program.

You can run a file initially and then write p foo or a (and a few others) in stdin to run all tests that match foo or all tests, respectively.

rcarriga commented 1 year ago

Does this just work right now then? Or is more required for this kind of functionality to be properly supported?

jfpedroza commented 1 year ago

Yes, it works. I can run a file, then change to run all tests and open a file I hadn't run before and see the status.

rcarriga commented 1 year ago

I'm not sure if we'll want to support this even if it does work right now because it would have some implications for https://github.com/nvim-neotest/neotest/issues/169. I'll have to see how viable it is when implementing

jfpedroza commented 1 year ago

I see. Even without the interactive feature, it is quite useful, so it's not a big deal if test status doesn't work for positions not initially run.