Test factories / partial fixtures to allow for more DRY code? #11153
wasabigeek
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When writing unit tests, we have to copy most of the input data across tests, even if only a few columns have different data. This is tedious but also makes the tests all implicitly coupled (e.g. changes in logic might mean having to change all the test inputs) and less obvious on what the critical changed columns are. Fixtures/YAML anchors work great if the inputs are exactly the same, but this feels rarely the case.
For example, given the below:
Is there a way to have a default set of values
foo: bar, bar: foo
where individual data can be overridden, something like YAML aliases:But ideally more flexible across the various data format types? I've mostly worked with test "factories" for example.
Beta Was this translation helpful? Give feedback.
All reactions