3.8. Validators

In this section we will reveal as much details about validators as possible. First we describe the architecture and then we discuss an approach to develop new validators.

Please note that the process of validation can have a significant impact on the performance measurement. It is advised to use them only during the development of a performance test or to validate suspicious results.

3.8.1. Validators Architecture

Figure 3.4. Validators Architecture


Similarly to reporting, validation is started from the SenderTask. A received response message is passed to the ValidationManager which stores them to a pipeline (i.e. FileQueue). Individual MessageValidators then consume the messages from this pipeline and count the correct and failed response messages.

The MessageValidator always receives the original message as well so it can see the particular request after any string templates were replaced with concrete values.

3.8.2. Writing a New Validator

The MessageValidator interface is the easiest to implement in PerfCake. It only has s ingle method, it does not need to be thread-safe because it is always called from a single thread in parallel to the running test. It should not perform any resource demanding tasks.

By default, before the scenario execution has finished, there is only a single call to the MessageValidator every 500ms (unless configured otherwise). After that, the validation runs without no pauses.

The single method is isValid() and returns true on successful message validation. There is no common abstract ancestor and you are supposed to implement the interface directly.