Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A validation check can pass a broken result when the defect preserves the property being checked. A count reconciliation, for example, can confirm that five fields came out for five fields expected while missing that one field was renamed. The remedy is to identify the invariant behind each check, then test identities and values separately using evidence that does not simply come from the instrument under test.

How the broken filter passed its reconciliation

Mahiro Hirakawa describes writing a reconciliation to catch a filter that silently dropped fields. The check compared the number of fields declared by a type with the number matched by the filter. It passed even though the filter was broken, because the defect changed a field’s name without changing the total.

The example field was risk-level. The filter used the regular expression w+=S+. Since w does not include a hyphen, the pattern did not capture risk-level as one name; it matched level and associated the value with that incorrect name. Five fields went in and five matches came out. The count check saw equal totals, not correct identities. Hirakawa’s article on DEV Community gives the example; the search result identifies it as published on Sep 9 but does not show a year.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which invariant does each check protect?

An invariant is the property a check expects to remain true. A count comparison checks cardinality: how many items are present. It does not, by itself, check which items they are or whether their values are right.

Case in Hirakawa’s example Field count What changes Does a count-only check catch it?
Good result 5 Expected fields and names are present No failure to catch
Renaming caused by the filter 5 A name is wrong, but the total remains the same No
Duplicate emission 10 The same names can appear while the total increases Yes, if the expected count is 5

The counts are outputs from Hirakawa’s illustrative example, not general statistics. The two defective cases reveal different blind spots: renaming preserves the count, while duplicate emission can preserve the set of names but change the count. As Hirakawa puts it, “A check only catches failures that break the invariant it reconciles on.”

Check identities against an independent expectation

To catch the described rename, compare the declared field names with the names actually found. A check can fail if a declared name is missing from the extracted names. This tests identity rather than only quantity, and it catches the illustrated renamed field as well as a count mismatch caused by duplicate emission.

The comparison is only as strong as its expected-name list and the equality rules used. It does not establish that the value attached to a correctly named field is correct. A filter that returns the wrong value under the right name can pass both a count check and an identity check, so value correctness needs its own assertion or trusted comparison.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why the source of the expected result matters

Hirakawa describes three cases where a summary produced by an instrument became its own denominator: a filter’s match count was used to validate field extraction, a code-search result was used to check the search, and an API’s comments field was used to validate a comment counter. In each example, the repair brought in evidence the instrument did not produce: a declared record type, a term known to be present, or a second endpoint that enumerates comments instead of merely counting them.

A positive control helps only when it is independent of the measurement being checked. If the control and the result come from the same source, the check can repeat the same blind spot rather than expose it. Hirakawa summarizes the point: “The requirement is independence.”

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Build checks around specific failure cases

Before relying on a reconciliation, ask: “which invariant does this reconcile on, and what failure preserves it”. Then list plausible defects and identify what each would change. A compact test design might look like this:

  • Count: Assert the number of extracted fields against a separately declared expected count. This can catch added or omitted items when those defects change the total.
  • Identity: Compare the expected field-name set with the actual field-name set. This can catch a rename even when the count stays constant.
  • Value: Compare extracted values with trusted expected values or another independent source. Name and count checks alone do not validate content.
  • Control: Include a known-present item or independently enumerated result, and ensure the control is not generated by the same instrument being tested.

These checks complement one another; none proves every aspect of correctness. The useful question is not just “does this catch the bug,” but which constructed failure it catches and which failures could preserve the property it measures.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.