How should I unit test?

Ideally, you should be following TDD principles, if you’re not familar with them then I recommend watching the following video from Uncle Bob. TDD can provide instant feedback on whether or not the code you’re writing is doing the correct thing, which can be very useful particularly in complex applications that are hard to test […]

What should I unit test?

Knowing what to test is difficult, but the important question you should always ask yourself is; “Am I just writing this test to increase the code coverage?” If the answer is yes, then chances are that test isn’t adding any value. Let’s look at an example I like to use; Here we have a custom […]

Why write unit tests?

This post is the first in a series on the why, what and how of unit testing. It was originally going to be a single post but there was so much I wanted to cover it didn’t seem right to do it as a single post. For this post we’re going to look at why […]

Unit Testing with Python (Part 3) – More Mocking!

Before reading this post I’d recommend reading my previous ones available here and here. In the previous tutorial we used unittest.mock to mock out our test subject’s dependencies, this simplified our tests and allowed us to focus on one piece of functionality at a time. Unfortunately the approach detailed previously has a drawback! Let’s make […]