8 Patterns for TDD

I’ve been doing Test Driven Development for nearly 10 years and I’ve spent most of that time doing TDD with C++. There’s a bunch of things I learned early on that I still use heavily today. And some patterns I’ve come to value over time. I’m using C++ examples but I’ve applied the same thinking in Python, PHP, Javascript and Lua.

I will also include some warning smells along the way. Things that will give hint your design is not testable.

1. Dependency Injection

This is one of the first things you’ll learn in doing TDD. It doesn’t matter if you’re doing London Style or Chicago Style you will eventually hit cases where you need to swap out the real item. It may be because that real object would touch the file system, a database or a network. Or it may be because it forms a convenient seam between your code and something more complex.

Smell: Singletons and classes that new their dependencies.

Continue reading “8 Patterns for TDD”

Testing as a Holistic Exercise

Early on when trying to apply Agile methods to software development I found a lot of the challenges were in the area of software testing. Not just because a lot more automated testing was being done, but because requirements would shift and change rapidly. Many levels of rapid feedback needed to be in place to ensure the development didn’t misstep for too long.

I started exploring more places a focus on testing and quality could be applied. And that led me on a journey earlier and earlier in the development timeline.

Continue reading “Testing as a Holistic Exercise”