Component test reference

About Verifier

What Verifier is, why it exists, and how a test runs

Verifier performs integration testing on a running software component through its interface. You give it an interface model and a command that starts your component; it plays the role of every other component in the model, exchanges real messages on the wire, and reports whether your component behaved the way the model says it must.

What Verifier Does

Verifier does integration testing against a running software component at the interface level. It reads your component’s interface model, takes the role of everything on the other side of that interface, and drives the component through the message sequences the model declares.

Nothing is simulated at the edges. Verifier opens the same transport your component uses, encodes messages with the same serialization standard, and sends bytes so that your component receives as it would in a real system. Message contents are generated to satisfy the constraints in the model, so each test attempt uses fresh values rather than a fixed script.

Every message your component sends back is checked against its Flex model. Sequences of messages which a component should successfully handle are stored in Flex protocols. A protocol that completes the way the model allows is valid; a message that violates a constraint, arrives out of order, or never arrives makes the protocol invalid.

Benefits over Unit Tests & Property-Based Tests

Unit tests and property-based tests answer different questions. Both are worth having; neither replaces integration testing.

  • Unit and property tests need your component’s source code. Verifier doesn’t: it only needs your model and a command that runs the pre-built component, so you can test a component you did not write and cannot recompile.
  • Unit tests exercise functions in isolation. Verifier exercises the component as it actually runs, so startup behavior, wire encoding, transport configuration, and timing are all part of what gets tested.
  • Unit tests pin specific inputs to specific outputs, so covering a component takes many of them. A protocol’s constraints describe a whole family of acceptable message sequences at once, and Verifier generates new values inside that family on every attempt.

What’s in a Model

A model is a Flex file describing your component’s interface. Verifier needs four things from it.

Messages define the data on the wire — a named structure with typed fields:

message struct Request {
    id: int32;
}

message struct Response {
    id: int32;
    lat: float64;
    lon: float64;
}

Component declarations name the participants, including your component and every peer it talks to:

component Radio;
component Controller;

Connections say which components exchange messages, and are what Verifier maps onto a transport. A connection can be declared by name, or implied by the from and to clauses inside a protocol.

Protocols declare the message sequences your component must honor. Each step either receives a message or sends one, and a step can constrain field values, including values carried by an earlier message in the same sequence:

local protocol reqRes in Radio {
    recv let req: Request
        from Controller
        @Topic("messages.Request")
    ;

    send let res: Response
        where res.id == cmd.id
           && res.lat >= -90.0 && res.lat <= 90.0
           && res.lon >= -180.0 && res.lon <= 180.0
        to Controller
        @Topic("messages.Response")
    ;
}

recv and send are written from your component’s point of view, so Verifier sends what your component receives. Field types, constraint forms, and the full annotation set are covered in verifier docs open model.

Flex is a larger language than the part Verifier reads. For the language itself, see flexlang.org .

How a Test Runs

Verifier loads the Flex model and then builds a state machine for each protocol declared for your component.

For each run of Verifier, the full component model is tested in iterations: one iteration, one complete test of the component model including all protocols. Verifier can be configured to do multiple iterations every time it runs, for more comprehensive testing.

Each iteration begins by starting any command marked not to restart, which then stays up for that whole iteration. Verifier then walks every protocol in the model in turn, and for each protocol it makes as many attempts as you allow. Every attempt is independent and runs the same setup:

  • Verifier opens the transports your configuration declares and binds each connection in the model to one of them.
  • It starts the component commands that restart per attempt, waits out their startup time, and waits for each one to report that it is up. A component that sends a message early is treated as up immediately.
  • It drives the protocol. When the next step has your component receiving a message, Verifier generates one that satisfies the step’s constraints and sends it on that connection’s transport. When the next step has your component sending, Verifier waits for the message and checks it against the constraints.
  • Messages, component start and exit, delay timers, and timeouts all merge into one ordered event stream, and every protocol still in play sees every event. Each protocol reaches its pass/fail verdict separately.
  • The attempt ends when the protocol under test passes or fails, or when every protocol has become invalid. Other protocols that pass along the way are recorded but do not end the attempt, so a protocol that extends another one can still finish. While the protocol under test waits for your component to send, Verifier sends no messages for other protocols. The protocol under test always appears in the results, even when it never reached a verdict. A trace that reached an end condition is valid, one that cannot progress is invalid, and one still in a legal state when the attempt ended is inconclusive.
  • Verifier tears down the per-attempt component processes and transports, so the next attempt starts from fresh state, and writes the attempt’s result before moving on.

Every allowed attempt runs, including attempts after one has already passed. A protocol passes an iteration when at least one of its attempts is valid.

When the last iteration finishes, Verifier prints a summary and writes the full results, logs, and event traces to disk. How to read them is covered in verifier docs open results.

See Next

If you’re new to Verifier, read usage next.