TDD and encapsulation priority conflict
Posted
by Hanseh
on Stack Overflow
See other posts from Stack Overflow
or by Hanseh
Published on 2010-04-11T15:18:44Z
Indexed on
2010/04/11
15:23 UTC
Read the original article
Hit count: 421
Hi, I just started practicing TDD in my projects. I'm developing a project now using php/zend/mysql and phpunit/dbunit for testing. I'm just a bit distracted on the idea of encapsulation and the test driven approach. My idea behind encapsulation is to hide access to several object functionalities. To make it more clear, private and protected functions are not directly testable(unless you will create a public function to call it).
So I end up converting some private and protected functions to public functions just to be able to test them. I'm really violating the principles of encapsulation to give way to micro function testability. Is this the correct way of doing it?
© Stack Overflow or respective owner