Assert an Invalid Sensor Reading

Assert an Invalid Sensor Reading

Try Press Step to send the stub’s out-of-range reading to the warning rule and compare Expected with Observed.

Compare expected and observed behavior

◆ Unit test

Sensor stub

Out-of-range reading ready

Warning rule

Sensor seam waiting for input

Assertion

Assertion pending

    Arrange correct behavior

    Arrange an invalid sensor reading and set the expected verdict before running the rule.

    Observe As you advance with Step, the Observed tray first shows Reading rejected and later shows Reading accepted in the bug replay. The assertion changes from PASS to FAIL.
    Explain The runs you can revisit with Back reach different verdicts because the assertion compares each observed result with the same expected rejection. Rejection passes the test and acceptance fails it.

    Technical boundaries. A sensor stub supplies the out-of-range reading directly to the warning rule. The replay uses the same invalid input for the expected behavior and the hypothetical bug. Verifying that the real bus delivers readings in the expected shape requires a separate test.

    Back to the chapter