Other articles


  1. Why I Don't Like Mocking Frameworks

    Disclaimer: By mocking framework I generalize anything that includes support for stubs and mock objects.


    The use of mocking frameworks was a difficult part of my TDD journey. Not only are newcomers expected to get their head around the basics of the practice there are now new tools to contend …

  2. Testing Private Code

    A common problem many people ask is - should you test private code? In short, you shouldn't. You should always test the public api of your code where possible. This is not always easy. Based on the context of the code in question there are a few options available.

    Don't Test …
  3. Randomly Generated Values in Tests

    The use of randomly generated test data seems like a good thing at first glance. Having worked with several teams that have used this concept I generally discourage the practice. Consider a simple method that joins together two strings. A test using random values may look like this.

    Problems

    Harder …
  4. Three Steps to Code Quality via TDD

    Common complaints and problems that I've both encountered and hear other developers raise when it comes to the practice of Test Driven Development are:

    • Impossible to refactor without all the tests breaking
    • Minor changes require hours of changes to test code
    • Test setup is huge, slow to write and difficult …
  5. Stop.Mocking.EVERYTHING

    I've flip flopped on how to use mock objects since 2008. It's took me nearly five years to finally claim to have a solid, practical answer on what is in my opinion, their correct use.

    Mock Everything

    Some developers told me to mock everything. Every. Single. Collaborator. I wasn't sure …

  6. TDD is a Tool

    I remember being introduced to Test Driven Development (TDD) very well. This is because it had such an overwhelming change on how I write code day to day. It was incredibly alien, difficult, yet rewarding. On this journey for the last five years I've changed my style, learned how not …

  7. Achieving more Isolated Unit Testing

    Good unit tests should be:

    • fast
    • independent
    • well focused
    • isolated

    If your unit tests are slow, you're not gonna run them as often as you should. Therefore one of the main benefits of unit testing is lost - the lack of instant feedback.

    Each of your unit tests should be independent …