Gatling is a load testing tool based on Scala. It comes with support for HTTP servers and is excellent tool to load test the Rest APIs.I will explain step by step how to install and run a simple API test program with Gatling. Make sure you have Java installed on your system.
- Go to https://gatling.io and download the open source version.
- Once the zipped folder is downloaded , unzip the folder(keep the folder in some meaningful directory)
- Open the command prompt and Go to the installed directory path\bin
- Run gatling.bat (for Windows OS) or ./gatling.sh(on Mac) and wait for some time

5. You will see simulation example provided by Gatling , you can select any of the option and enter the description and then press enter

6. If you get below metrics without any error , Congratulation .. You are through first level :).

Now let’s write a Simple Gatling Scala program to test API Post request with JSON body. Wait… What …..Scalaaaaaa ??????? I don’t know Scala….
Don’t Worry…It’s okay if you don’t know Scala , I am not expert either. Lets do some tweaks.
- Go to the Folder -> gatling-charts-highcharts-bundle-3.4.1\user-files \simulations \computerdatabase
2. Copy paste any existing Scala file and rename it ( I will rename it as PostRequestAPITest.scala). I am using a public API http://dummy.restapiexample.com/api/v1/create to show you the example. Post request has JSON request body with three attribute name, salary, age.

3. Save the file and let’s run gatling again. You should see your file in the Simulation list as shown below (see option 6 )

4. Select your file option and optional description and press enter. Gatling will run and collect metrics like given below

Yay…Congratulations !! You have successfully run your first test.
You can see the metrics provide calculated response time and request count. It also generates the UI report that can be viewed under results directory. Here is snapshot of the generated report-
