Testing test's helpers?

Hi all. I’m writing some helper method for tests, and I was wondering whether I should test them too. I’ve had a look at Upcase’s spec/support and it looks as you don’t test helper methods.

What do you people do with helper methods? Just being curious :wink:


Think of testing like double-entry bookkeeping. If there’s a bug in your implementation, the test will fail. If there’s a bug in your test, but the implementation is correct, then the test will also fail.

There is a very slim chance that a bug in your test and a corresponding bug in your implementation could cause a test to pass only by coincidence, but I wouldn’t worry about this too much.

There might be some value in testing things like Page Objects and Fakes if they are reasonably complex, since you can use a TDD approach, and because it may give a more useful failure message when something is wrong.

This makes a lot of sense. Thank you very much :smile:

Id say this is why test-driving rather than testing after implementation is important. In TDD, you verify that your test gives you the expected failure before you implement. This should help you identify bugs in your tests (or test helpers). If you extract existing test code to a helper, it may be worth forcing the test to fail to ensure it still fails in the manner you expect.