lundi 31 mai 2021

Generic test implementation design

I'm trying to write a generic test class in Java. each test checks filtering using a certain filtering attribute. The inputs for my test are: filteringAttribute, filteringCondition, filteringArgs, expectedNumOfItemsAfterFiltering.

filteringAttribute - can be of two types: integer or double. for example: the attribute age is int, but height can be 183.41566

filteringCondition - is determined by the attribute type: for example equals condition only refers to integers, between condition only refers to doubles, and greater than refers to both.

filteringArgs - are determined by the filtering condition: for example: the args for eqauls condition are integers, but for between condition are two doubles.

expectedNumOfItemsAfterFiltering - are determined by all of the above.

How can I right a test that will be generic, and will not require me to add an additional test when a new attribute is add, instead I just want to update the relevant arguments when this happens.

Thanks!

Aucun commentaire:

Enregistrer un commentaire