nvim-neotest / neotest

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

Feature request: Select subset of tests to execute #12

Closed stehessel closed 2 years ago

stehessel commented 2 years ago

It would be cool if there was a way to mark tests for execution - for example via a toggle in the summary window - and then run them with a command like run.run_selected(). This would increase the flexibility of test execution.

rcarriga commented 2 years ago

So I'd like to get a bit more insight into the reason for this feature. In my mind the only way to do this (without making the entire interface for adapters more complex) would be to run each selected test as an individual process. Therefore you may as well just run each one separately.

Can you (or others) describe where you see the advantage in terms of workflow?

stehessel commented 2 years ago

The use case I envision would be:

This is not about performance. How the tests are executed and whether they are run concurrently would be an implementation detail, you could also execute the tests serially in a single thread. It's about running the tests you want to run, even when they are scattered in different files.

stehessel commented 2 years ago

One corner case would be parametrized tests - e.g. using pytest. If I remember correctly PyCharm treats parameters as separate tests and allows to select individual selection for them. I think that's ideal, but it might be easier to select only based on test and file names and then run all parameters.

rcarriga commented 2 years ago

OK that all makes sense, just wanted to make sure I understood the need properly :+1:

If I remember correctly PyCharm treats parameters as separate tests and allows to select individual selection for them

That'd be a feature request for neotest-python to detect them as separate tests but that sounds very cool

rcarriga commented 2 years ago

OK I've added the ability to mark tests in the summary and run them. See :h neotest.summary.run_marked() and :h neotest.Config.summary.mappings for details

stehessel commented 2 years ago

Awesome, thank you!