Scott Bellware and Roy Osherove have different opinions about this. I believe Scott is right, but often follow the Osherove's way. Let me explain why.
I agree with Scott when he says:
I think that Jim is on the right track, but I'm the kind of guy that feels that a test class's greatest responsibility is to document behavior in the clearest possible way, even if that means sacrificing design qualities best reserved for functional code - like reuse.
Above all, unit tests should be as close to non unit tests usage as it could be. And reuse justs breaks it.
But the world is not just black and white, and often we have to trade some principles for the sake of practicability. And to risk to end up testing the reusability module itself, or worse, to miss a test hidden by the reusable module. But that's what's life is made of: compromises.
No comments:
Post a Comment