Hacker News new | ask | show | jobs
by riso 6577 days ago
One thing that that I don't like about unit testing is it can give you false positives that everything is working correctly.

When you follow the red-green pattern and write the test, have it fail, then write the code to make it pass, I find that my brain is thinking the same when I write the test to when I write the code. So as a simple example if I write a test that says add(2,2).should == 5, it fails since there is no add() method. I then quickly write the add method to allow the test to pass and I am happy that I get a passing test even though the logic is incorrect. Obviously this is an over-simplification, but I have experienced situations that have some resemblance.

I can't say I always agree with the laziness argument. I can't even count the number of times it would take me only a few lines of code to get something done, but writing all the unit tests increases the amount of time to complete the task by a factor of 10. Other times the tests are easily saving me hours in a day. So it depends on exactly what they are testing and how they are doing so.

I am not saying I don't like them all the time, just sometimes :)