Checkpoints

When a MockServer instance goes out of scope (i.e. when it's dropped), it will verify that all the expectations that have been set on its registered mocks have been satisfied.

When you have a complex mocking setup, it can be useful to verify the state of the mocks before the end of the test.
wiremock provides two methods for this purpose:

verify is self-explanatory, so let's dive into scoped mocks.

Scoped mocks

When you register a mock with MockServer::register, it will be active until the MockServer instance goes out of scope.
MockServer::register_scoped, instead, returns a MockGuard.
The mock will be active until the guard is alive. When the guard goes out of scope, the mock will be removed from the MockServer instance and its expectations will be verified.

Exercise

The exercise for this section is located in 07_http_mocking/03_checkpoints