Posts

Showing posts from January, 2010

Unit Testing's False Security

Unit Testing is software development where developers write code to test other code.  They key point here is the word unit in unit test case! Let us take a very idealized case.  Suppose I have a calculator class (unit).
class Calculator    int add( int a, int b)    int divide (int a, int b);
   int sqroot( int a);
To unit test the 'calculator' unit, You can write some unit test cases for it.

Calculator_test {     bool test_add()
    {
         assert( add(5,3) == 8 );
         assert( add(-1, 6) == 5);
    }

    bool test_divide()...
    bool test_sqroot()...
}

It is very nice and clean.  I start out with this clean example as this how people end up on the wrong path. This is so clean and testable... let's just apply it to everything.  It's a symptom of the plague of computer science which has spent that past decades obsessing on formally proving a program 'correct'. Unit testing works very well when th…