by VBprogrammer · 8y ago · 0 comments
I think he makes a very strong point that if the code is too complicated to use in tests then the production code should change. Simply because if it's hard to set up for you in tests; then it's almost impossible for someone else to use in real code. When they should be reusing your component they will give up and write a 'better' version for themselves.
Not to mention that the right abstractions will actually make your code simpler, instead of more complex. Imagine if someone needs to use an arraylist in a test, but decides to reimplement inline using arrays instead. Sure, they have avoided the use of a higher level abstraction, but the resulting code is now both harder to read and more likely to contain bugs.
He isn't really advocating never using helper methods either. In fact he gives an example where the helper methods hide some irrelevant values.
If I were to rephrase it as "repeated code isn't necessarily bad in tests" does that make it more palatable?