Black-box and white-box testing
Gustavo Niemeyer
gustavo.niemeyer at canonical.com
Mon Mar 18 12:58:45 UTC 2013
On Mon, Mar 18, 2013 at 6:51 AM, roger peppe <roger.peppe at canonical.com> wrote:
> For myself, I like the fact that when writing tests against the publicly
> visible API, we use qualified identifiers just like any external package.
> It gives me a feel for how the API will feel to use in practice, and
> it also means that the testing code is trivial to factor to another package
> if necessary.
Not only factoring tests to another package, but refactor the
implementation itself.
This is the main reason why it's so much better to stick to black-box
testing when that's reasonable. I've worked in projects where most of
the behavior requirements were encoded into white-box testing, tightly
coupled to the shape of the code, and it was very hard to take those
assumptions and refactor them so that the code underneath could be
improved. Proper black-box testing should allow the code to change
entirely (for organization, performance, cleanliness, whatever),
because they're testing the same guarantees that the public API gives
any other client of the API.
Of course, there are exceptions, and we do have them already, so it's
not entirely black or white (!).
gustavo @ http://niemeyer.net
More information about the Juju-dev
mailing list