DEV Community


Discussion on: What are your thoughts on testing and TDD?

stephenradams profile image
Stephen Adams

Hi, I think that TDD is great, not only does it make you think about the code you’re implementing, but it also can highlight issues in pre-existing code if you are writing tests after implementation. I do find that I write my tests after writing my code, but that’s fine it allows me to confirm that the code I’ve written works as I thought. It also helps find bugs in my code.
I do think that there are still a lot of developers who don’t write tests mainly because the projects they have worked on before do not allow time to learn how to write tests and write testable code. So when a project insists that there is 80% test coverage a lot of developers leave writing tests to later in the process, when it’s too late because they don’t know how to write tests and testable code. Which I think they should do, it helps write cleaner code and less bugs.

jooforja profile image
João Forja 💭 Author

That's a great observation. A lot of developers don't know how to write tests and how to write testable code. I think that a lot of that has to do with the culture of the company they're in. Especially when we're talking about project-based companies, which tend to privilege shipping as soon as possible vs. reducing the cost of development on the medium to long term, it's a kind of environment that privileges hacks over a sustained practice, which makes testing and TDD hard to flourish. So it's unlikely for someone working in a situation like that to be given the time to learn or to have someone to teach them how to test/TDD. At least, that's my experience.