Unit testing, Black-box testing and white box testing

software picture software · Aug 31, 2011 · Viewed 29.9k times · Source

What is Unit testing, Black-box testing and White-Box testing? I googled but all the explanation I found was very technical. Can anyone answer this question in a simple way with an appropriate example?

Answer

hvgotcodes picture hvgotcodes · Aug 31, 2011

In black box testing, you don't care how the internals of the thing being tested work. You invoke the exposed API and check the result; you don't care what the thing being tested did to give you the result.

In white box testing, you do care how the internals of the thing being tested work. So instead of just checking the output of your thing, you might check that internal variables to the thing being tested are correct.

Unit testing is a way of testing software components. The "Unit" is the thing being tested. You can do both black and white box testing with unit tests; the concept is orthogonal to white/black-box testing.