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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Two Engines, One Query: DuckDB Inside Neo4j
  • Testing Java and Spring Applications With Kotlin: Low-Risk to Adoption
  • Wasm Inside Neo4j: Building the Example That Didn't Exist
  • OpenAPI From Code With Spring and Java: A Recipe for Your CI

Trending

  • Why AI Agents Need a Shared Enterprise Ontology
  • Article Moderation: Your Questions, Answered
  • AI Agents for Software Engineering and Autonomous Development Workflows
  • Why Your GPU Fleet Is Both Full and Idle: Building a Capacity Orchestration Layer

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Jul. 31, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
20.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Two Engines, One Query: DuckDB Inside Neo4j
  • Testing Java and Spring Applications With Kotlin: Low-Risk to Adoption
  • Wasm Inside Neo4j: Building the Example That Didn't Exist
  • OpenAPI From Code With Spring and Java: A Recipe for Your CI

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook