Advice for handling parameterised / permutations of unit tests minimising copy/paste #5987
Replies: 1 comment 1 reply
-
There is a very old related issue: #1229, not that it helps with the discussion at hand. As of now it's impossible to hook into the unit-testing engine itself to run tests with different parameters, which means that you will have to implement some form of that yourself. I'd actually expect each invocation of a |
Beta Was this translation helpful? Give feedback.
-
Hi Ducks,
I'm doing some TDD (test driven development) . I've written a dozen unit tests, each of which relies on a module level subject under test that wraps some objects in its constructor.
I now want to run the same suite of tests with a slightly different wrapped object, or slightly different parameters to the constructor.
At the moment in the test module I basically have this setup:
Where every test shares a module level
sut
(subject under test). So if I want to make a new suite of ntests run onTestSheet.TableWithNoRows
orTestSheet.TableWithASingleColumn
or any other edge case, I can just duplicate the entire module and tweak that setting. Or extract all of my test bodies into parameterised functions; but still their calling sites need to be duplicated for each combination of parameters. I could also loop through a collection of parameters in each test but the@TestInitialize
code would also be required to run multiple times per test and that is not the flow RD uses...What would you recommend for now?
Beta Was this translation helpful? Give feedback.
All reactions