Recently, I was talking with another developer about confidence when writing code, and what I felt lead me to be able to get changes out to production quickly.
He wanted to know what it was that gave me confidence that my changes
a) weren’t going to break anything, and
b) had the desired results
I mentioned my previous blog post where I talked about TDD / unit testing mindset, and gave some examples of tests that were written with the typical ‘I have to test this method/action’ kind of mindset, and talked about why that might not be such a good idea.
Now, I’m not saying that it’s easy to adopt a different mindset, but writing tests, and writing them well does require a different mindset to the one we adopt when writing the ‘real’ code.
Adopting a mindset is a hard thing to do. It is more than just instruction. It takes time, deliberate practice, and guidance, but once it clicks, it’s really powerful.
Here’s an example from development work I do with one of my clients.
That team that I am working with work in a pretty Kanban-like way. Often pretending it’s scrum, but basically each developer is working on their own stream of features, sometimes getting interrupted to work on defect fixes for issues found in production for unexpected conditions.
For both the day to day feature work, and the defect fixes, where there is often a lot of perceived urgency in getting a fix out, adopting the right mindset, and having the right approach to writing tests gives a massive boost to my performance.
It provides confidence. Confidence to make changes, knowing I haven’t broken any behaviour that I had previously explicitly called out, deliberately tested in isolation.
With the right set of tests in place, I can very very quickly create a new test, see this fail, make the change, repeating until the feature is done, or the defect is fixed.
By focusing on behaviour, by adopting the right mindset, I genuinely have no concerns about deploying changes to production in a matter of hours, if not minutes.
The tests are doing what they should do. They are helping me. Making me better. Making me faster. Making me more confident in my ability to deliver.
How do you feel about your tests, TDD, or unit testing that you do? Do you have a consistent approach and understand why that approach works?