testing: i understand it, but i don't get it (fully)

newbee wrote:

OK, for my second project i decided that i was going to implement nit-
and functional testing.

I get the theory but i don't get a good feeling with it.
The given examples are mostly very simple and i can't think of a good
example of where a unit-or functional test can detect that some code is
broken.

They don't. You could easily write the wrong code that passes any one
of those tests. All the tests together, in conjunction with code that
is _not_ sabotage, will keep your train ... on the rails.

Is there somebody out there who is convinced of the usability of testing
and who is willing to share some real-life examples of tests and perhaps
and example of a case where a test discovered broken code?

Write the tests at the same time as you write the code. Run the tests
after every few edits. If they fail unexpectedly, revert the code back
to the last state where all tests passed, and try again.

I have reverted more times than I care to admit, and sometimes I did
not give a darn what code broke. Maybe the test was simply
hyperactive. This is still better than debugging!