I regularly practice Test Driven Development. I truly believe in its benefits and also have been able to influence a huge number of develops to practice it.
However, there are situations in which I ask myself questions like:
- Is it important to automate this particular check (test) ?
- Will it be worth the effort/investment or is it YAGNI?
- What is the possibility of this particular scenario breaking (risk)?
- And so on…
Yesterday I was faced with a similar situation where I decided to skip the automated test.
Context: I was working on a website where users can use their credit card while shopping online. Basically the website had a simple text input box to accept the credit card number. It turns out that most browsers (except Safari) caches the input data and stores it in plain text somewhere on the computer.
So we wanted to turn off the auto-complete and caching feature on this specific input field. There is a very easy way to do this. Just need to set autocomplete=”off” in the input tag. For example:
<input type=”TEXT” name=”creditcard” autocomplete=”off” />
Its an easy fix and quite widely used. So that’s great. But how do I write an automated test for this?
If we think a little hard, there are ways to write automated test. But then you ask yourself is it worth it?
This site had lived without this feature for so long, so I did not think it was that crucial to its users. Even if this feature stops works, it won’t bring the site down. (They certainly had a good battery of automated tests which tests the core functionality if the product.) So I choose to skip the automated test. I manually tested it with different browsers made sure it was working as expected.
If this comes back and bites me, I’ll certainly invest in some form of safety net, but for now, time to hack some more code.
What would you choose to do?