Gatling Global Assertions

Learn how to add global assertions to our Gatling simulation Jenkins job.

Configuring global assertions

In addition to our earlier configurations, we can also also configure global assertions that will fail the build if not met. The Gatling simulation will not fail otherwise.

These global assertions can also be configured inside the simulation test script itself, as discussed in the Assertions lesson.

From the root page of the project, click on “Configure” option as shown below:

Once done, navigate to the bottom of the page where we can find “Post-build Actions”.

From the “Add post-build actions” drop-down, select the “Gatling Checker” option as shown below:

Once the option is selected, we should see the following screen from where we can add our desired global assertions.

For the purpose of demonstration, let’s add the “Global Average Response Time Pre-warning” option and configure as shown below:

The above configuration ensures that the global average response time is 200 ms or less. Otherwise, the build will be marked as FAILURE.

We can add multiple global assertions by clicking on the “Add” button.

Once done, click on the “SAVE” button.

Triggering the build

Once the above configurations are set, we can now trigger the build again by clicking on the “Build Now” link.

As our global response time is 273 ms, our build will be marked as “FAILURE”, as shown below.

In the console of the build, we should see something like the following saying the expected and actual mismatch, hence marking the build as FAILURE.

[Gatling Check Plugin] Checking /Users/.../.jenkins/workspace/gatling-load-test/build/reports/gatling/samplesimulation-20200609211459817/js/stats.json
[Gatling Check Plugin] global ok rate metric accepted, expected = 90.000000, actual = 100.000000
ERROR: [Gatling Check Plugin] global avg response time metric unqualified, expected = 200.000000, actual = 273.000000
Build step 'Gatling Checker' changed build result to FAILURE
Archiving Gatling reports...
Adding report 'samplesimulation-20200609211459817'
Finished: FAILURE

Get hands-on with 1400+ tech skills courses.