Gatling is tool for load/stress testing that can be used to create stress tests in websites. 

In this tutorial, we will create a Gatling simulation containing some basic HTTP interaction and we evaluate the obtained results in terms of performance and failure requests, using Gatling's assertions.

Gatling v2.2 release added support for JUnit reports, which can be processed by Xray.


Below is the simulation class containing 3 assertions. This code was directly run inside Gatling's folder after extracting the v2.2.3 release Gatling bundle

package xpandaddons.xray.gatling.simulations

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.http.request.builder.HttpRequestBuilder.toActionBuilder

class GoogleSimulation1 extends Simulation {
    val theHttpProtocolBuilder = http

    val theScenarioBuilder = scenario("GoogleTest")
            http("Search Request")

                 * Check the response of this request. It should be a HTTP status 200.
                 * Since the expected result is 200, the request will be verified as being OK
                 * and the simulation will thus succeed.



         * This asserts that, for all the requests in all the scenarios in the simulation
         * the maximum response time should be less than 50 ms.
         * If this is not the case when the simulation runs, the simulation will considered to have failed.

            details("Search Request").successfulRequests.percent.gt(90)

After successfully running the Test Case and generating the JUnit XML report, it can be imported to Xray (either by the REST API or through the Import Execution Results action within the Test Execution).

bin/gatling.sh --simulation xpandaddons.xray.gatling.simulations.GoogleSimulation1

Every Gatling's assertion is mapped to a Generic Test in Jira, as is the initial check for the HTTP status code. The Generic Test Definition field contains the full name of the class.

The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to the full name of the simulation class. 

When an assertion fails, then the actual value is displayed in the execution details.

As a side note, Gatling also generates an HTML report that provides many interesting and useful information in the context of load testing, including some interactive charts.