I have a class that contains several boolean flags that affect how the program behaves, and I want to test that no combination of those flags causes any unexpected behavior. Since there are 2^n possible combinations, I don't want to write all of those test cases. Would it be an appropriate use of reflection to iterate over those flags to generate all possible conditions? The alternative seems to me to be only to test those edge cases which seem most likely to cause issues, which I think puts too much stock in my ability to predict bugs.
Also, could you give me an idea of what that might look like in Java? While I'm familiar with the idea, this would be my first use of reflection. All of my flags have getters and setters so it shouldn't matter, but they're currently backed by bit fields, and after my tests are in place I intend to convert them to be backed by EnumSet
s.
Aucun commentaire:
Enregistrer un commentaire