[Tutor] duplication in unit tests
Lie Ryan
lie.1296 at gmail.com
Wed Dec 9 01:14:55 CET 2009
On 12/9/2009 10:43 AM, Kent Johnson wrote:
>> So my questions -- Am I misunderstanding how to properly write unit
>> tests for this case? Or perhaps I've structured my program
>> incorrectly, and that's what this duplication reveals? I suspected,
>> for instance, that perhaps I should group these methods
>> (convertEmDashes, splitLines, etc.) into a single larger function or
>> method.
>
> Yes, your tests are revealing a problem with the structure. You should
> probably have a single process() method that does all the cleanup
> methods and the split. Then you could also have a test for this.
I should add, a unittest can be a white-box testing. You can have
TestCases for the whole "process" (blackbox test), but you can also have
TestCases for each splitLine, convertEmDashes, etc (whitebox test).
The test for the large "process" will be, sort of, a simple integration
test for each sub-processes.
More information about the Tutor
mailing list