BB.Test.RecordingEstimator (bb v0.34.0)

Copy Markdown View Source

Test double: an estimator that forwards every input it is given to a test process.

Before starting the robot, put the recipient pid into persistent term:

:persistent_term.put({BB.Test.RecordingEstimator, MyRobot}, self())

The estimator looks up the recipient at init and sends {:received, :input, input} for each call to handle_input/2 - a %BB.Message{}, or a multi-input map of them.

Pass gated: true to have it hold each input until the test sends the estimator's process :release, standing in for an estimator doing slow work. It sends {:received, :holding, input} as it starts waiting, so a test can tell the input has arrived without guessing how long that takes. Every held input must be released, or the robot can't shut down.