Tag Archives: testing

Covering Utility Classes

Coverage is one of my personal metric I try get close to 100% as part of my programming style to quickly make sure I at least went through all the possible code paths.

I have three criteria for a well defined utility class:

  • It has only one private constructor
  • It has no non-static methods
  • It is final

This is based on my answer about testing against private constructors and I use it to test my utility classes to push up my coverage metric.

I have placed the full code and examples in https://github.com/trajano/commons-testing/.

Generating a random SIN

The Canadian Social Insurance Number is something that would validate against the Luhn algorithm. Since SINs may be used as input data for some applications, I have translated the code that generates a number that passes the Luhn Algorithm in Wikipedia to something that can be put into into Selenium’s user-extensions.js.