Closed christoph-blessing closed 2 years ago
You could do something like this
local neotest = require("neotest")
local skip_slow = false
neotest.setup({
adapters = {
require("neotest-python")({
args = function ()
if skip_slow then
return {"-m", "'not slow'"}
end
return {}
end
}),
},
})
vim.api.nvim_create_user_command("NeotestSuite", function (opts)
local parsed_value = ...-- Parse opts to decide what to set
skip_slow = parsed_value
neotest.run.run({ suite = true })
end, {...})
Cool, that does exactly what I want. Thanks a lot and keep up the great work with this plugin!
I have the following command bound to a key to run all tests in my project:
This works fine but I have some slow tests in my test suite and I would like to exclude them from running when using the command mentioned above. Fortunately my test runner (pytest) lets me apply custom marks to tests and then I can exclude marked tests with a command line argument. Now I want to adapt the command above to pass the appropriate command line argument to pytest. One option would be to do this:
This works but is not ideal because other test runners beside pytest will not understand
extra_args
and (presumably) error out. What is the recommended way to deal with this?One solution I could see is to write a custom function that checks if the test runner to be used is pytest and then passes the appropriate
extra_args
. If that is the best solution I would appreciate it if you could let me know how to determine the test runner that is about to be used.