More than one test-case for a class
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
More than one test-case for a class
I recently ran into a situation where I needed to create two separate test-cases for one single class. Is this a good idea, or does it indicate that the class needs to be refactored into two classes? They test two different aspects of the class: the first is for its functionality, the second is for its error reporting. I would have put them together in one test-case, but their requirements for the setup()/teardown() functions are different.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Well, I can't throw exceptions because that would disrupt the program flow: these are all non-fatal errors, really, I guess they're really warnings or notices. (Also, PHP 4). So that setup probably wouldn't work.
To reuse your metaphor though, I would still need to test that the class with functionality is actually throwing the exceptions when appropriate error conditions are met. So I'd still be testing the same class >.>
To reuse your metaphor though, I would still need to test that the class with functionality is actually throwing the exceptions when appropriate error conditions are met. So I'd still be testing the same class >.>
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US