I can't live without TDD
I used to hate writing tests, but now I simp for it.
This is just a rant about my love for TDD, and my story, from hating to loving testing.
I hated testing in my earlier days. I found it confusing. It seemed to me like a waste of time, why write tests at all. Just write the code and ship the feature, this way we also save time.
I was angry, I didn't like that the professional software engineers all were writing tests, and in fact, I was hoping to find a job at first that wouldn't require writing tests because I heard such jobs exist. I won't lie, I was happy to hear such jobs exist.
I actually thought I was smart for thinking this way, but it was just my ego and arrogance.
The course didn't just help me understand writing tests, but also why we do it. Reading the articles from Kent as well, why testing is necessary to ship software with confidence.
It eventually clicked for me. We are humans and we write a bunch of bugs, testing is necessary to ship great software. Without tests, you can't know if you have introduced any bugs when implementing a feature. The feature might be working, but what about the existing code and behaviors in place? Exactly!
Anyways, I wrote an article about the purpose of testing, not to go too in-depth here: The purpose of testing.
My journey to TDD
I'm now writing tests, but not doing Test-Driven Development. I learned about it later, and sort of had a similar story here. I was thinking to myself, how is it possible writing a test before any real code?
As you can tell, I didn't get TDD nor had I tried it. I was reading about TDD and trying to understand its purpose. After properly learning about TDD and all the three steps in the cycle, it made me realize that TDD is not about testing, it is about writing good software:
I think what really made me like TDD is that in the second step we are supposed to write the necessary amount of code to make the test pass, and then in the third step it is about refactoring the code. It made me realize that TDD is more than just writing tests.
I tried it multiple times, but TDD really shined for me after I acquired more knowledge of the testing tools I was using. TDD can be painful if writing tests is hard for you, but if you can write tests and understand the tech you're using, it is a pleasure and joy.
I think the lesson we can learn here is not to judge using your ego and limited knowledge, but instead to ask and learn more.
Don't let your ego keep you away from growth.