Hi Ranchers,
So, back to my point after all your valuble inputs....
Why should we test th code every 5th line... if i am sure of my programming logic..
Testing has evolved over a paradigm, where what we have engineered is to be faultless. (I hope everyone agrees).
Ex: Civil engineering
If I am building something physical then i would not test every brick. If i know that i have my concrete mixture as prescribed by my building blue print specs then i test the building for its overall parameters.
Ex: Mechanical engineering
If I am assembling a car with x(Horse)Ranch(Power) then i would not test every nut and bolt and tyre as for every car i build. I would quality test a sample car with various mechanical parameters.(Object orientation applies)in the sense every single component of the car is pre-manufactured by different vendors and is tested.
Coming to the software paradigm:::
I have my prebuilt OO building blocks. They are tested (I am sure SUN tests its classes before putting it in the Java API).
Ex: I built a security package with RSA. I needed random numbers with (Big Integers)at that time. I would write a piece of code that produces the keys. I would trust Java math.random. And if my extended eucliedien algorthim programming logic is correct which would be around 450 lines. Then i expect the keys to be produced.
What i would test in this scenario if i go by unit testing?
What as programmer i have tested around 6 years ago was that atleast for 100 samples of the keys produced were not identical before i handed it to testing. I did write a piece of testing code which would run the program for n number of times and compare all the results. I had to do a little syntax debugging for typos. And my code still runs with a Major Bank(Big Bucks)
I did achieve a piece of code without using unit testing.
If i read my software specifications, design document and i am not new to programming logic, syntax and OO concepts of use then i would not test my code every 5th line.
Where i would agree is that a person new to programming will benifit if he knows the rules of testing. Then his brain will automatically think for a logic and syntax while programming itself.
Summary:
Learning testing rules in general will give a good starting ride in the programming ranch. As you become a seasoned rider you implicitly do pseudo testing while programming without much effort for explicit unit testing.