In this post, I will be taking you through end to end steps to set Gatling integrated development environment. Steps include installing JDK, maven, install Gatling maven project template, scala plugin for maven & configuring scala SDK. Further to that, I will be running a sample script through the command line to verify the integrated environment
This post will enable you to get started with Gatling development environment & harness the real powers of Gatling.
Gatling is a wonderful tool and paving its way to the most popular open-source performance testing tool. Being code based, it gives developers & testers flexibility control over the scripts which can be easily maintained! Gatling takes an edge over traditional UI based performance testing tools like JMeter.It meets demands of early performance testing & integrates well in a DevOps environment.
See in Action : GATLING: KEY FEATURES
MILESTONE STEPS TO SETUP DEVELOPMENT ENVIRONMENT
Step1 - Install OpenJDK
Step 2 - Download & Set Up Maven
Step 3 - Create a Gatling Project using maven
Step 4 - Install IntelliJ - Community Edition
Step 5 - Import Gatling project in IntelliJ
Step 6 - Mark Test Source Source & Resource
Step -7 - Install Scala Plugin
Step -8 - Configure Scala SDK
Step -8 - Other Way - Add Scala-Maven Plugin to POM.xml
Step -9 - Verify Development Environment
You can download & install hotspot OpenJDK 11 using ADOPTOpenJDK here. If you are not familiar with OpenJDK, please visit below to get introduced & install the same:
See in Action: Setting up Open JDK in Windows
As the above video says, make sure that you get correct java version on giving command
Now once we are done with installation of Prerequisites, we need to download maven and unzip it to any desired folder.
Set Maven path in environment variable for easy use of mvn command:
Edit the System Environment variables--> Navigate to Advanced tab --> Environment Variables
M2_HOME : Click New --> Variable Name : M2_HOME , Variable Value: <path of maven directory>\apache-maven-<version>
Edit the 'Path' Environment Variable --> %M2_HOME%\bin
To verify maven installation-> Open command prompt->give command
In command prompt go to the location where you would like to create a Maven project and execute the following maven command:
This command generates a maven project. Archetype is a Maven project templating toolkit
You will be presented with a prompt like: Choose a number or apply filter.Give keyword Gatling
Filter down the choice to latest Gatling version
Group_id – uniquely identifies your project across all projects.
Artifact_id – a name for your project.
others are not required – you may press enter without typing anything
Type ‘Y’ to confirm
'Build Success' should be displayed.
Download community edition of IntelliJ
Once downloaded, double click exe & follow instructions
You can directly import your Maven project to IntelliJ using the following steps:
In IntelliJ: File > New > Project
In the 'New Project' window select the type of your project such as 'Scala'.
Click on Next button
In 'Project location' field browser the path till the project/artifact name of the maven project that you just created.
Click on Finish.
You should now be able to see the project in IntelliJ.
See in Action- Learn more on Create Maven Project In IntelliJ
Manually mark the src/test/scala as Test Sources Root and rebuild the project.
Manually mark src/test/resources as Test Resources
Go to File-->Settings-->Plugins
Search for scala plugin by entering scala keyword in the right side window
Install scala plugin
Go to File-->Project Structure-->Global Libraries
In right window --> click on + sign and select Scala SDK
Choose scala 2.12 version
In case you have difficulty, download scala SDK from https://www.scala-lang.org/download/2.12.8.html and select through browse button.
Instead of configuring scala SDK (previous step 8), you can add scala-mavel plugin to POM.xml as below.
This is better option as it's quick & sustainable.Scala-Maven plugin helps to compile Scala based Gatling code:
Create a new script. Right-Click on scala folder -->New -->Choose Scala Class-->Give a name to the new script as BasicSimulation
Copy below code from Gatling site https://gatling.io/docs/current/quickstart or from below.
At this point do not bother to understand the script. We are here to verify our development environment which we have created so far!
Run Engine by right-clicking Engine under scala:
A terminal window will open at the bottom and ask for a description. Press Enter. The script should run successfully
Report location is indicated once run is complete. Note my report location in the above snapshot . Below is the HTML report:
Congratulations! you are all set to create performance test scripts in Gatling development environment.
Don't limit yourself to beginner level ! Ask for 90 % off coupon code on complete course on Gatling available on Udemy !