DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Using Python Libraries in Java
  • DGS GraphQL and Spring Boot
  • How to Build a New API Quickly Using Spring Boot and Maven
  • Configurable Feign Client Retry With Reusable Library and DRY

Trending

  • What They Don’t Teach You About Starting Your First IT Job
  • From Code to Customer: Building Fault-Tolerant Microservices With Observability in Mind
  • Toward Indigenous AI: A Critical Analysis of BharatGen’s Role in Data Sovereignty and Language Equity
  • How to Use Testcontainers With ScyllaDB
  1. DZone
  2. Coding
  3. Java
  4. How to Use Gatling With Maven

How to Use Gatling With Maven

Learn all the details of how to integrate the Gatling performance testing framework with a Maven project in this tutorial.

By 
Federico Toledo user avatar
Federico Toledo
·
Jul. 31, 17 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
20.1K Views

Join the DZone community and get the full member experience.

Join For Free

In this post, we will see how to use Gatling with Maven, creating an integration via plugins. In the world of CI/CD, attaining this kind of integration has become essential. In particular, I’ll show you how to integrate Gatling, use Scala to develop a simulation, and how to execute this with Maven for generating reports.

Preparing a Project With Maven

First, we will create a new Maven project and add the dependencies. We will be able to incorporate Gatling into an existing project (whether the performance tests are going to exist in the same project as other tests, or on their own) or in a project starting from scratch. If we want to employ Gatling for a Maven project that was started from scratch and made specifically to use Gatling tests and nothing else, it would be useful to build it starting from an archetype (Maven project template), following the steps in this post.

Dependencies and Plugins

To use Gatling with Maven we will need to add a dependency (gatling-charts-highcharts) and a plugin (gatling-maven-plugin) to our project’s pom.xml file. In Maven, plugins are responsible for executing tasks, such as to compile projects, run tests, and create.jar files, among others. Generally, they provide the project with a series of commands that can be executed utilizing the following syntax:

plugin

Later we will see how we can utilize some of these commands.

The pom.xml file looks more or less like this:

how to use gatling with maven

By adding these lines to our pom.xml file, we are providing the libraries necessary to use Gatling, with which we can execute commands in Maven. These will permit us to build and execute our project, including the generation of reports.

Here is an example of a project running Maven and Gatling, with some prepared simulations on a testing environment. This project was developed starting from the archetype mentioned above.

Development IDE

I tried two different IDEs, one based on Eclipse, and one on IntelliJ. I preferred the second. In order for IntelliJ to work, we must install the Scala plugin, although when a Scala file is opened, an install link appears automatically. We will also then have to add the SDK to the project (though the IDE also makes this suggestion and it’s almost automatic).

Prepare a Simulation (script)

Now let’s develop a script utilizing Scala that will contain the simulation that we wish to run.

image (6)-min

How To Prepare A Simple Test

There are various ways to identify the URLs that we wish to use in our simulations, as well as the data needed for their configuration. For this, it’s necessary to capture the HTTP traffic between the client and the server. One of the ways to do this is using the “Network” tab in Chrome’s toolbar, which we can access by pressing the F12 key. Once we activate the network tab, we can load the desired URL, right click on the request and select the option Copy/Copy as cURL (cmd). In the copy of the results, we can find all of the data that will facilitate a correct configuration of the URLs in the script of our simulation

Execution of Gatling With Maven

Now we will use Maven to run our script. For this we will open a terminal and locate the root address of our project and execute the following command:

mvn clean gatling:execute

Maven will recognize this as a command thanks to the Gatling plugin that we added to the pom.xml file. This project will also include two other commands that can be used, which are:

commands

During the execution we can see the console output:

picture 6-min (1)

Results

By the end of the execution of our script, Gatling will have generated some excellent reports for us to analyze. We can find these results by accessing the directory that appears in the terminal at the end of the script’s execution.

Once it’s opened we will see a web report such as this:

Gatling Report screenshot

In Closing

Now you can start to integrate your scripts using the Maven building tool! This will also facilitate the execution of these scripts with Continuous Integration tools such as Jenkins. A special thanks to Oscar Calderin and Iván Serrano for greatly helping to put this tutorial on how to use Gatling with Maven together.

Have any questions? Leave us a comment!

Apache Maven Gatling (software)

Published at DZone with permission of Federico Toledo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Using Python Libraries in Java
  • DGS GraphQL and Spring Boot
  • How to Build a New API Quickly Using Spring Boot and Maven
  • Configurable Feign Client Retry With Reusable Library and DRY

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: