8. A characterization test is test that
characterizes the actual behavior of a piece of
code.
It acts as a change detector, protecting legacy
code from unintended changes
9. public double Calc(double inv, double rt, int y)
{
double ret = 0;
for (int i = 1; i <= y; i++)
{
ret = inv * Math.Pow(1.0 + rt / 100.0, i);
}
return ret;
}
17. The Golden Master Approach
Before making any change to production code, do the following:
1) Create X number of random inputs, always using the same random seed, so
you can always generate the same set over and over again. You will probably
want LOTS of inputs for good coverage.
2) Bombard the class or system under test with these random inputs.
3) Capture the outputs for each individual random input.
18. A picture's worth a 1000 tests.
Unit testing asserts can be difficult to use.
Approval tests simplify this by taking a
snapshot of the results, and confirming that
they have not changed.