dimanche 4 octobre 2015

Unit Test strategy for function with too many optional parameters

If a function has too many optional parameter following are the ways I can think of covering in unit tests. example:

void someFunction(int x , int y , int z , int a , int b , int c, int d , int e, int f, int g)
{
 // do something
}

where a to g are optional parameters

  1. write unit test for each optional parameter.
  2. run unit test for set of optional parameter.

My question is is there better way to handle this situation which give good code coverage . This is also generic issue as number of parameter increases and the permutation and combination of unit tests will increase accordingly. It not only increase the run-time of unit test suite, it also not effective to do exhaustive testing where the ROI is low.

Kindly advice what approach should I take to have a unit test coverage . Is having too many parameter in function a symptom of bad design in first place.

regards

Aucun commentaire:

Enregistrer un commentaire