--

Hi Georgefcroft.

You are 100% correct, testing private methods is absolutely an anti-pattern.

That makes me remember a lot of discussion when discussing TDD of people saying that it is important to create tests for all methods, included private... which it is easy to end, because with TDD the code emerges because tests ask for it... therefore, when they appear they are already tested. But... human nature.

I think that the believe in test privates, fragility of tests, all they come from not validating business rules, but code instead. Also from the feeling that test is a non productive code that does not deserve time to clean (which is 100% wrong!, in fact, it should be cleaner than production code).

Thanks a lot, and I will introduce this bit of clarification just to avoid bad outcomes.

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

No responses yet