should unit tests be black box tests or white box tests? -


say have 3 methods, similar different input types:

void printlargestnumber(int a, int b) { ... } void printlargestnumber(double a, double b) { ... } void printlargestnumber(string numberasstring, string numberasstring) { ... } 

all 3 use same underlying logic. example: maybe double version 1 compares numbers, , other 2 convert inputs double.

we imagine few different unit tests: first input larger, second larger, both inputs negative, etc.

my question

should 3 methods have full set of tests (black box since don't assume core implementation same)

or

should double version tested heavily , other 2 tested lightly verify parameter conversion (white box testing since know share same implementation , it's been tested in double tests)?

if of methods public, i.e. callable outside world, i'd test of them full set of tests. 1 reason white-box tests more brittle black-box tests; if implementation changes public contract might change of methods.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -