2

I'm very new at writing Cucumber tests. I'm writing Ruby helper functions to assist Cucumber step definitions. Should there be a separate set of tests to test my helper functions i.e. unit tests?

The step definitions are using the helper functions but there's nothing really testing that the helper functions are working as they should.

Does anyone unit test their Cucumber support helpers?

2
  • please don't cross-post: stackoverflow.com/questions/46198816/… "Cross-posting is frowned upon as it leads to fragmented answers splattered all over the network..."
    – gnat
    Commented Sep 13, 2017 at 15:21
  • @gnat I've deleted the post on stack overflow and was minutes away from doing so, had you given me the chance
    – QCFia
    Commented Sep 13, 2017 at 15:26

1 Answer 1

1

I would say no, for the same reason you don't write unit tests for unit tests. Tests are written to verify functionality. They should be considered part of the functionality itself: when you change the functionality, you change the tests. There's no point in writing a test of the test when you can just fix the test itself.

To answer your implied question of how you make sure the test is working like it should: The best way to ensure that the test both fails appropriately and passes correctly is to write it first. Write a failing test and make it pass. See the following for reference:

This is a recommended practice in Acceptance Test Driven Development (ATDD) and Behavior-Driven Development (BDD).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.