|
|
| Think about Loose Coupling | |
| PerlMonks |
Comment on |
| ( #3333=superdoc: print w/ replies, xml ) | Need Help?? |
|
First, congrats on taking the Testing plunge.
Some of my tests are dependant on the internals and I dither on whether or not that's a good thing, ... The XP folks call this "code smell". It's a signal that some restructuring or refactoring is needed in the code.
This happens to me a lot when I build post facto test cases, and find that a class is too dependent on, for example, there being a database underneath it, which can make it cumbersome to test. A solution to that particular problem is to restructure a class to make use a "database interface" class that can be passed in either at object creating time or to a method that populates an instance of the object. This makes it easy to swap in a "dummy" (testing) database interface during testing. This change takes code that looks like:
$calendar->loadFromDatabase();
In reply to Re: The Joy of Test
by dws
|
|