How does a behaviour model act as the oracle, and what does a passing generated run actually prove?
answer
- Something has to say the behaviour is wrong
- Predict, act, project, compare
- Abstract names against rows and flags
- A mismatch has three suspects, not one
- Green means agreement, not correctness
basics
~20 sAt each step the model predicts the next state; the harness compares that prediction with what the system actually did. A pass proves only agreement with the model, so an incomplete or wrong model goes confidently green.
solid answer
~50 sThe oracle is whatever decides that observed behaviour is wrong, and in this technique the model plays that part. The run is a lockstep loop: the harness asks the model which action comes next and what state should follow, the adapter performs the action against the system, projects the observable result onto the model's vocabulary, and compares. A mismatch is a **conformance failure**, and triage has three candidates — the system is wrong, the model is wrong, or the adapter's projection is wrong — which is why teams reject the reflex of always blaming the system. A green run proves agreement with the model over the paths generated, and nothing more. Anything the model does not describe — timing, resource consumption, data values inside a transition — is invisible to it, so the model must be reviewed against the specification as an artefact in its own right.
code
pseudocode · 15 linesfailure = none
for step in path:
predicted = model.nextState(current, step.action)
adapter.perform(step.action)
observed = adapter.projectToModelState() # rows and flags -> a model state name
if observed != predicted:
failure = conformanceFailure(
prefix = path.upTo(step),
predicted = predicted,
observed = observed)
break
assert adapter.invariantsFor(predicted).allHold()
current = predictedgo deeper
Know that the oracle is whatever decides behaviour is wrong, and that here the model plays that part by predicting the next state so the harness can compare it with what happened. Say that a pass means agreement with the model.
Explain the four moves of a step — select, act, project, compare — and be clear that projecting real system state onto an abstract state name is hand-written work. Name the three possible causes of a mismatch rather than assuming the system is at fault.
Demonstrate that you have triaged real conformance failures and know the split between system, model and adapter faults. Be ready to state what your model does not describe — resources, timing, values inside a transition — and how that gap has bitten a team you worked on.
Own the assurance claim. Decide what a green conformance run is allowed to be used for in a release decision, how model correctness itself is reviewed and by whom, and how independence of derivation is enforced so the oracle is not just the implementer's assumptions restated.
## What the word oracle means here An oracle is the thing that decides whether observed behaviour is wrong. Every test has one, explicit or not: a hard-coded expected value, a stored approved output, a crash signal, a human looking at the screen. The distinguishing feature of model-based testing is that the oracle and the case source are the *same artefact*. The model both chooses what to do and says what should happen, which is why one model edit can change hundreds of predictions at once. ## The lockstep loop A run proceeds in steps, and each step has four moves. 1. **Select**: the harness asks the model for the next action on the path, together with the state the model says the system should reach. 2. **Act**: the adapter performs that action against the real system. 3. **Observe and project**: the adapter reads what it can from the system and projects it onto the model's vocabulary. This is the subtle move. The model's states are abstractions — a billing run in `Disputed` — while the system holds rows, flags and timestamps. The projection is a function from real observable state onto a model state name, and it must be written by hand. 4. **Compare**: predicted state against projected state. Equal, continue; different, stop and report a **conformance failure** with the path prefix that produced it. The oracle is usually **partial** in two directions. It checks only the concepts the model names, and it checks them only at the granularity the projection can see. A well-built projection also asserts a few invariants that hold in a given state — in `Settled`, the outstanding balance is zero — which strengthens the oracle without enlarging the state space. ## Triaging a mismatch The reflex is to log a defect against the system. In practice a mismatch has three possible causes and the split is not one-sided. - **The system is wrong.** The genuine find: an action led somewhere the specification does not allow, or was accepted when the model forbids it. - **The model is wrong.** The model is code, written from the same documents and often by the same people, and it carries its own faults: a guard misread, a transition drawn from the wrong source state, an action added to the product and never modelled. - **The projection is wrong.** The action succeeded and the state is correct, but the adapter read the system too early, or mapped two distinct real states onto one model name. An early model-based effort tends to run at roughly one genuine system fault for every two or three model and adapter faults, and that ratio is the honest thing to say in an interview. It improves as the model stabilises. Mature teams keep the triage explicit, tagging each failure by culprit, because the trend across those tags is what tells them whether the technique is paying. ## What a green run does and does not prove It proves that over the generated paths, at the granularity the projection can see, the system agreed with the model. Four gaps follow directly. **Unmodelled behaviour is invisible.** A 4-person team maintaining a utility billing run had a green model-based suite for six weeks. The model described nine states and every legal transition faithfully, and conformance was perfect. Then the month-end run for a bulk of 12,400 accounts died part-way through: each cancel-then-reissue cycle left an open handle to the invoice-document store, and after roughly 3,900 cycles the run hit a resource exhaustion and stopped. The suite had exercised that exact transition pair hundreds of times and reported green every time, because the model described *which state comes next* and said nothing about resources released on the way. The oracle can only be as broad as the model's vocabulary. **Data inside a transition is invisible** unless projected. The model says the run reaches `Invoiced`; whether the invoice total is correct to the penny is a separate check the projection must be told to make. **Shared misunderstanding passes silently.** If the same engineer derives model and implementation from the same misreading of a tariff rule, the two agree and the suite is green. This is the deepest limitation and the reason mature teams treat the model as a reviewable artefact in its own right — walked through with the analyst or the domain owner, ideally derived by someone other than the implementer. **Only the generated paths were checked.** Paths outside the criterion's set say nothing at all. ## What to say in an interview Describe the lockstep loop, name the projection as the piece people forget, give the three-way triage, and be explicit that conformance is agreement with a fallible artefact rather than correctness. Then name what your model does not describe — that list is the honest statement of the suite's blind spot, and having one ready is the difference between a candidate who has run this and one who has read about it.
- A generated run reports a mismatch. What are your candidate causes and how do you tell them apart?Three candidates: the system misbehaved, the model is wrong, or the adapter's projection misread the system. Replay the path prefix by hand against the system and check the real state directly — if the system is where the model predicted, the projection is at fault. If it is somewhere else, read the specification for that transition: if the specification agrees with the system, the model is stale. Only what survives both checks is a system defect.
- How do you strengthen the oracle without enlarging the state space?Attach invariants to states rather than adding states. Each model state carries a small set of conditions the projection asserts on arrival — in a settled state the outstanding balance is zero, in a disputed state exactly one open dispute exists. This deepens what each step checks while the number of states, transitions and generated paths stays the same, which is the cheapest strengthening available.
- If the model and the implementation share a misunderstanding, the suite passes. What reduces that risk?Independence of derivation and review. Have the model written from the specification by someone other than the implementer, walk it through with the analyst or domain owner as a reviewable artefact, and treat model changes as a reviewed change rather than a private fix. It cannot be eliminated — no oracle derived from the same understanding as the code can — but a model that a domain owner has read is far harder to get quietly wrong.
saying these in an interview costs you the question
- Says a green conformance run proves the system is correct
- Treats every mismatch as a defect in the system
- Assumes model states can be read from the system without a projection
- Expects the model to catch faults it never describes
- Lets the implementer write the model with no independent review
- Never checks data values because the state name matched