3 ms·
A lot. And for good reason. I generally guide people away from the negativity around the thought of "it takes longer to write tests than code". Coding is simply
by nstart 9y ago
A lot. And for good reason. I generally guide people away from the negativity around the thought of "it takes longer to write tests than code". Coding is simply the logic put into the language you are writing something in. Programming is the act of thinking and solving the problem and then putting it into code.
If someone said they take longer to think about the code than to write the code, we'd instinctively guide them towards saying that's natural.
Writing tests is very much a way of thinking through a problem and bringing clarity to exactly which piece you want to solve at the time. That is always going to take longer because it involves thinking through the problem first. It's natural.
The answer to how much time is invested into writing tests?
For me, it's usually more than the time taken to write the code to pass the tests. By the time I'm done writing the tests I know what I need to do to make it pass.
A second answer to the question is, as much time as it takes. Because I definitely don't want to repay that time later in the form of regressions and stress when change comes knocking at the door.