Does "Unit Testing" falls under white box or black box testing?

I think this article by Kent Beck referring more to TDD and unit-testing sums this up fairly well. Basically, it depends on how you actually write the tests*. Here is another article on the subject that might help clarify things.

*If you are testing from within your application, then it is whitebox. If you are testing it just like an outsider would make the calls to only your public facing API, then it is blackbox.


The usual criteria for white-box testing is execution path and data structure sensitization. These are sometimes called "branch testing", "path testing", "data flow testing". See Wikipedia on white-box testing.

That is, unit-test refers to the level at which the test takes place in the structure of the system, whereas white- and black-box testing refer to whether, at any level, the test approach is based on the internal design or only on the external specification of the unit.

So if your unit-test sensitizes all of the execution paths and data structures in the unit that you are testing, then it is a white-box test. However, if your unit cannot sensitize most of the paths and data structures of the unit, then it can't claim to be a white-box test.

Be advised that in some organizations unit-testing is called white-box testing regardless of whether the unit-test is based on the unit's design rather than just its API. Best not to argue with your boss on this point.