DISQUS

Thinking inside a bigger box: Testing: Avoid setUp and tearDown

  • Anders Norås · 1 year ago
    Agreed! I often find myself refactoring setup methods to factories called by the individual tests whenever I come across tests that need to do some prep work before they can run. Makes things much easier to grasp when you revisit the test fixtures later.
  • Christian Rørdam · 1 year ago
    Agreed! I think it is important that a test method can be read as a sequence of steps, but the steps can be reusable methods. So I do extract the gory details of actually performing the step, but I usually don't extract a subsequence of steps as a new method. And of course, I try to give the methods as good names as possible, as always.