java - Is it appropriate to use reflection to iterate over members for testing purposes? -
i have class contains several boolean flags affect how program behaves, , want test no combination of flags causes unexpected behavior. since there 2^n possible combinations, don't want write of test cases. appropriate use of reflection iterate on flags generate possible conditions? alternative seems me test edge cases seem cause issues, think puts stock in ability predict bugs.
also, give me idea of might in java? while i'm familiar idea, first use of reflection. of flags have getters , setters shouldn't matter, they're backed bit fields, , after tests in place intend convert them backed enumsets.
from question,i don't think need reflection testing.
1) may need have properties file/csv / excel various combinations of booleans class.say if class contains 20 fields holds boolean values,your excel contain 20 columns , number of rows possible number of combinations.
2) write util class read excel/csv/properties file , dynamically create object of target class, set boolean fields of class , other fields (map corresponding enums )and use instance unit testing.
3) can loop on rows , cover possible combinations.
Comments
Post a Comment