Closed adrigzr closed 2 years ago
The issue of parameterised tests has been raised by several adapters (#64 for example). I see a few ways to approach them
Option 3 is and always will be the best route to go, and I explicitly designed the interfaces with that route in mind, both neotest-python and neotest-plenary hook into the runner. I can add in a hook to generate tests from the args as you suggest though.
OK I've gotten around to this. Instead of allowing for another capture type, I've gone with a more blind approach of allowing a build_position
option to be given to the parse function. You can see the default for usage but it can return either a position or a list of positions so you can return sub-tests.
This approach should allow using treesitter captures to do some of the heavy lifting when parsing arguments.
Going to close this as I don't believe neotest core can do much more, the rest will be down to adapters. Going with my fourth option above would be a large endeavour for a relatively minor feature, especially when there are better solutions
I want to implement in neotest-jest the possibility to capture and interpolate dynamic tests as:
This code should generate the following tests:
"case 1"
"case 2"
"case 3"
For this to work, I've created a query like:
where
@test.args
are the arguments passed to theeach
method.For this to work, I need to do some changes in
neotest
:But even with this, I need a method to generate more tests based on this
args
inneotest
.Is this the best way or do you have something in mind for these cases?