UnitsNet icon indicating copy to clipboard operation
UnitsNet copied to clipboard

Improve test coverage

Open angularsen opened this issue 6 years ago • 2 comments

Now that code coverage is run for all builds we have a baseline. It's not awful, but it sure can be improved. At the time of this writing:

  • UnitsNet - 56%
  • UnitsNet.Serialization.JsonNet - 78%

We do have tons of tests, but many of them only test specific quantities instead of all 95+ quantities.

  1. Rewrite tests that target specific quantities to test ALL quantities instead, using code generator to output the test code.
  2. Add tests for classes with very low coverage
  3. Decide on a reasonable limit to strive for. I propose aiming for >90% coverage since this is a small library with highly testable code.

angularsen avatar Jul 20 '19 15:07 angularsen

As an example, here is how Quantity.TryFrom() is only tested for certain quantity types. https://codecov.io/gh/angularsen/UnitsNet/src/9c12fb1382e8b4b220fe7a9bc625883ce29fc145/UnitsNet/GeneratedCode/Quantity.g.cs

The graphs also clearly show how it is quantity types that make up the majority of missing coverage, which makes absolute sense as per point 1.

angularsen avatar Jul 20 '19 15:07 angularsen

Code coverage support was merged in https://github.com/angularsen/UnitsNet/pull/657

angularsen avatar Jul 20 '19 15:07 angularsen