Unit Testing - Steps to reaching to the direction of 100% Code Coverage

Posted by Hon Lee on January 17, 2025

Reflecting on the code coverage in the reporting tool in Devops, I had a thought, are there practices to aim for Unit Testing in the right direction towards 100% . I suggest there are some tips for this.

  1. Ensure all public fields are unit tested.

  2. Check whether private methods need to be tested depending on whether other code and methods are dependent on it.

  3. Check the amount of testable code per method that needs to be tested are required for the overall line code coverage.

  4. Make testable methods for a class as public virtual within mock classes if required.

  5. Make tests for exception handling seperately to test error/exception handling as code following that part usually stops.

  6. Always work on the latest components preferably and keep it relevant (this is what I had discovered recently)