This question already has an answer here:
I'm currently trying to unit test a behavior which, in some very particular cases, returns B instead of A. It may depend on the value of 3 different attributes for example.
How should I test this?
- Test only the specific case where the behavior is true
- Test the specific case and one other random combination of values for which the behavior isn't true
- Test the specific case and all possible combinations
The last option seems like a maintenance nightmare as any new attribute or value for an attribute would require massive updates in all tests on behaviors that use these, but at least you would have 100% coverage of the behavior.
To give an example, we might want to know if a person is eligible for free tickles. To be eligible, you need to belong to category A, D and F, be more than 20 years old, be a lefty and have red hair.
Should I just test that "categories A or D or F + > 20yo + lefty + red hair" gives eligibility? Should I also test some random combination such as "E, 25yo, lefty, blond" is not flagged as eligible? Should I test absolutely every possible combination or category, below/above 20yo, hand and hair, one being true, all the others being false?