Coverage

lib.Coverage.addCoverage

Generate coverage testing for public interfaces.

public

: The public interface to generate coverage for

tests

: Attribute set of tests to match agains

::: {.example #function-library-example-lib.Coverage.addCoverage}

lib.Coverage.addCoverage usage example

# Expression
let
  # The public interface (attrset) we are testing
  public = {
    addOne = x: x + 1;
  };
  # Test suite
  tests = {
    addOne = {
      testAdd = {
        expr = public.addOne 1;
        expected = 2;
      };
    };
  };
in addCoverage public tests

# Returns
{
  addOne = {
    testAdd = {
      expected = 2;
      expr = 2;
    };
  };
  coverage = {
    testAddOne = {
      expected = true;
      expr = true;
    };
  };
}

:::