tfui latest

100% coverage as a behavioral forcing function

The pipeline enforces 100% code coverage on all packages except cmd/ glue and internal/terraform/exec (the live terraform adapter). But tests must describe user-visible behavior – never written “for coverage.” These two rules create deliberate tension: every branch must justify its existence through a behavioral test.

If a branch can’t be reached by a behavioral test, the branch shouldn’t exist. This eliminates speculative code: defensive guards for impossible states, error handling for conditions that can’t occur, “just in case” branches. The coverage gate forces authors to think carefully about each branch – if you can’t describe what the user experiences when this path executes, remove the path.

Coverage is a side-effect of complete behavioral specification. One test suite serves both purposes.

Consequences

  • No unreachable defensive code. If a dependency can’t fail in practice, don’t handle its error.
  • No speculative branches. Code only exists if a user-visible behavior requires it.
  • When coverage drops, the question is “which behavior is untested?” not “which line is uncovered.”

Considered Options

Separate coverage tests from behavior tests

Rejected – tests written to reach a line describe no behavior, and the gate would stop asking whether the branch should exist. There is one suite, and every test in it describes a behavior.

Edit this page on GitHub