Just churning out more near copies is not a good answer.
Just churning out more near copies is not a good answer.
1. It can make it harder to see what's actually being tested if there are too many layers of abstraction in the test.
2. Complex test code can have significant bugs of its own that can result in false passes. What tests the test code?
Thus I generally see repetitive or copy/pasted test code as a necessary evil a lot of the time.
I now find it is best to be very explicit in the individual test code about what the conditions are of that specific test.
It doesn't really matter how many helper functions you extract from your test code, in the end you have to string them together and then make assertions, and that part will always be repetitive and formulaic. If you've extracted a lot of shared code, then it might look something like "do this high-level business thing and then check that this other high-level business thing is true". But that is still going to need to be written a dozen times to cover all the test cases, and you're still going to want test names that match the test content.
There's a certain amount of repetition and formulaism that will never go away and that copilot is very good at.