Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

  • Blog Navigation
Why I test.

This is a cross post from my personal blog, because I’d like to hear from other Pivots about why they test.

First about unit and integration tests.

  • I write unit tests for focused feedback; i.e. tell me exactly what broke. To keep them focused I try to keep them orthogonal which usually means using fakes of any collaborators.
  • I write integration tests where I need more safety than a unit test will offer. They seem even more important when I’m stubbing and mocking a lot in a dynamically typed language like Ruby.
  • I write both types of tests to help convey intent and understand the problem better. I TDD with either a unit test or integration test, whichever feels natural.

Then about interaction and state based testing.

  • I pick the approach that feels natural at the time, favouring neither by default. I struggle with rules about when to use which.
  • I dislike interaction tests that look suspiciously similar/symmetrical/coupled to the code they refer to. I expect a test to earn its right to exist, and therefore add to the size of the codebase and build’s time, by either conveying intent that is difficult to express in the code itself (which is why I love the term ‘example‘) or addressing some other consciously identified risk.

So, now it’s your turn – why do you test?

  • Adam Milligan

    I write tests because they make my code better. They force me to explicitly think about what I want the code to do before I write it. They force me to design to interfaces, which [someone]( once said is a good idea. They force decoupling.

    I write tests because I can often think of how I want my code to behave faster than I can write the code (actually, this is often why I write test stubs that later I turn into tests). Every time I leave my machine for a significant period of time I try to leave with a failing test, since the failure will immediately remind me what I’m doing when I come back.

    I write tests because they become a living document for my code. Each test describes some small bit of behavior. Anything that my tests fail to describe, my code doesn’t need to do. I try to delete any and all code whose absence doesn’t break tests.

    I write tests so I’m not afraid to change my code, and so other people aren’t afraid to change mycode. Few things give me more stress than changing an untested code base.

    I write tests because my job is to write good software, and I believe I should do my job well.

  • I test because all the cool kids are doing it.

Share This