3 ms·
In production code a helper lets you reduce duplication, making refactoring easier and reducing bugs. It also adds additional test interfaces that can make code
by UncleMeat 8y ago
In production code a helper lets you reduce duplication, making refactoring easier and reducing bugs. It also adds additional test interfaces that can make code more reliable. Finally, it makes code more readable.
But for tests you are optimizing for a different thing. You want to know what the input to the test is. This makes referring to the test as documentation much easier.
Helper functions can work in tests but often they are completely opaque and make tests hard to understand.