We have test code like:
clickElement(a);
clickElement(b);
clickElement(c);
that's repeated in many places, where clickElement is called 1 to 5 times in a row. Should we make a helper function to consolidate these, e.g.:
clickElements([a, b, c]);
I've heard arguments against creating the helper function, that it makes it harder to read and that test code should be simpler. I've heard arguments for the helper function that it simplifies things and reduces code duplication. It seems like both camps are firmly convinced that their way is clearly better. Are there other important reasons for either that I'm missing or popular/standard resources on this?
clickElements([a, b, c])
is fine - I understand what the idea is. Depending on the sytem, perhapsclickElementsSequentially([a, b, c])
is better, so that it isn't mistaken for some sort of a tripple-click combo gesture. On the other handperformTestActions()
is bad because I have no idea what's happening or why - I need extra context to understand the test.