Create a Feature, Fix a Bug, Write a Test
I am still amazed that many developers when they create a feature or fix a bug that they don’t write a unit test (or functional test) to ensure that things work as expected. Years ago I had a developer on my team that would not write tests. The impact was that they would report a bug as fixed, pass the application over to QA for testing, and then QA would fail the test and the developer would have to continue to work on fixing that bug. No matter how hard I tried, this developer just would not test their code or write a test to ensure that things were working as expected. Unfortunately that behavior led to us letting them go.
Just today I was reading an email from one of the insider communities I belong. There was a bug reported with a new release of software that seemed to me to be an obvious bug, one that was most likely seen before. It was a bug that certainly should have been covered by a test when the feature was created. It made me think “How could this bug have gotten to a release version of software?”. If only they had a test to cover the feature or bug.
I definitely recommend that you write tests as you are writing code and hopefully your software is relatively bug free. However, when bugs happen, and they do, writing a test to ensure that the bug is fixed is a great way to increase the numbers tests for your application over time.