All laws

§ 87Maintainability

Beyoncé Rule

In a shared codebase, the behavior no test checks is the behavior that changes without warning.

Google

Keep in mind

If you depend on it, put a test on it

What to do

Write a test for every behavior your product relies on in a shared library or dependency, and make sure it runs in the CI that gates other people's changes. When something breaks and no test caught it, add that test before closing the incident. If you own the shared code, say up front that tests are the contract, and do not invoke the rule unless your changes actually run consumers' tests.

Why it happens

A team changing infrastructure that the whole codebase uses cannot read every caller, so the only contract it can check at scale is the test suite. Whatever the suite does not exercise is invisible to them and changes without warning, not through carelessness but because nothing told them it mattered. The rule turns that blind spot into an assignment of responsibility: if an unrelated change passes all your tests and still breaks your product, the fix and the missing test are yours. It is only fair where a pervasive CI system runs everyone's tests against everyone's changes.

When it stops applying

Churn Rule: a test-shaped contract tells the changer what it broke, not that breaking it was free; the team making the change still owes its users the migration.

Source

Adam Bender, "Testing Overview", in Winters, Manshreck & Wright, Software Engineering at Google (O'Reilly, 2020), ch. 11 — "If you liked it, then you shoulda put a test on it", invoked by infrastructure teams making changes across the entire codebase.

Read the source

Mark: Public domain · Wikimedia Commons

Cite this

Hammurabi, § 87, “Beyoncé Rule.” https://kanywst.github.io/hammurabi/laws/beyonce-rule/

BibTeX
@misc{hammurabi-beyonce-rule,
  title  = {Beyoncé Rule},
  author = {{Hammurabi contributors}},
  note   = {Hammurabi, § 87},
  url    = {https://kanywst.github.io/hammurabi/laws/beyonce-rule/}
}

Text under CC BY-SA 4.0: credit Hammurabi and link the article.

Read in a column

Related laws

Suggest a correction on GitHub