<p>Continuing from <a href="/daily/2024/01/30/tdd-doesnt-mean-you-know-everything-upfront">my last few emails</a>, as well as adding the new use case more easily and quicker, having automated tests also saved me from adding a regression into the code I was changing.</p>
<p>I'd written a condition in the query to ensure only results that started with the search term.</p>
<p>Initially, I removed it, but then the tests failed.</p>
<p>This reminded me why I'd written the condition that way, and I was able to re-add my fix differently.</p>
<p>Without the tests, I'd likely have removed it and introduced a regression.</p>
<p>Whilst fixing a bug, I'd have introduced a different bug.</p>
<p>My tests saved me from doing that and I was able to rectify it quickly before pushing to CI or the staging environment.</p>
<p>Continuing from <a href="/daily/2024/01/30/tdd-doesnt-mean-you-know-everything-upfront">my last few emails</a>, as well as adding the new use case more easily and quicker, having automated tests also saved me from adding a regression into the code I was changing.</p>