3 ms·
99% of the code I write is test first. It makes my life easier - I always know what to do next and it reduces the amount I need to keep in my head. TDD done th
by ollysb 7y ago
99% of the code I write is test first. It makes my life easier - I always know what to do next and it reduces the amount I need to keep in my head.
TDD done the way many developers do is a PITA though. When I write a test it will start off life with zero mocking. I'll hit the db and live APIs. From here I'm iterating on making it work. I only introduce mocking/factories because it's harder work not to. I'll gradually add assertions as I get an idea about what behaviour I want to pin down.
Done this way using tests is just making life easier, you can start off testing huge chunks of code if that's what you're sketching out, then add more focused tests if that's a faster way to iterate on a particular piece. For me the process is all about faster feedback and getting the computer to automate as much of my workflow as possible.
edit: Kent Beck had a fantastic video series about working this way, I can only find the first 10 mins now unfortunately but it gives you a taste, https://www.youtube.com/watch?v=VVSSga1Olt8 https://www.youtube.com/watch?v=VVSSga1Olt8.