News for hackers. Stuff that matters.
Re:Unit testing is not (generally) useful by axod on Thursday February 05, 2009 @11:20AM (#468101)
>> "If not for my unit tests, I'd be scared to change much of anything, for fear of stirring up a whole bunch of trouble that I'll have to fix later on."

For me, if I had unit tests everywhere, I'd be scared to change much of anything, knowing that after the refactoring, and usual testing/checking things work, I'd then have to rewrite/fix unit tests.

Re:Unit testing is not (generally) useful by darkxanthos on Thursday February 05, 2009 @12:31PM (#468301)
That's why I stopped for a while. Then I discovered BDD style testing (or context/specification, or...).

Whatever it's called, it's not quite as fine grained as a unit test and it's not as large in scope as integration testing. It's at the level of your business specs. So the only time you'll break your tests is if you've jacked up a spec.

Honestly, if my changes cause new behavior in the system but the people paying me won't care, then I don't care either.

Re:Unit testing is not (generally) useful by jon_dahl on Thursday February 05, 2009 @10:50PM (#469321)
Unit testing can be this way, but it doesn't have to be. At a really low level, unit testing can be "testing the implementation", which may be useful while you're writing code, but isn't useful during a refactoring.

But slightly higher level tests can be written to almost never have this problem. Let's say you've written code to ensure that a CC transaction doesn't go through with an invalid number. No matter what the implementation looks like - no matter how much you refactor - this test should always work. The same is true for a wide range of useful tests. (These aren't strictly "unit" tests, but they fall into a similar category.)

My personal experience is that a good unit test suite is 99% useful when refactoring, and 1% painful.