Mikhail Loenko wrote:
Hi Richard,
Why? IMHO, it's easier to write test cases through public API. And the
internals may possibly change, so if we write test cases directly for
the internals, our test cases will not be stable.
One of examples might be: to test something trough public API
you need a test of 1000 lines of code, but if you can access internals,
10 lines is enough
Yes - that's one good way to look at it. Composition of a set of
methods make life miserable in terms of the combinatorics, and I'm
afraid that "testing from a distance" means we won't be complete enough
in our high level tests.
When you look at some method
public int publicAPIMethod( int arg1, int arg2, int arg3) {
// some logic
classMethod1()
// other logic
classMethod2()
// some more logic
classMethod3()
}
I think that it's far easier to produce meaningful testcases if you
trust the three methods, and only have to worry about the logical soup
to devise your testing strategy. It's a matter of "divide and conquor"
I guess. I prefer simple things to complex things.
geir