Ora

How Do I Run Gatling Test from Command Line?

Published in Performance Testing 3 mins read

Running Gatling tests directly from the command line is an efficient way to execute your performance simulations, particularly when working with Maven-based projects. This method is essential for integrating performance tests into continuous integration/continuous deployment (CI/CD) pipelines and for quick local executions.

Running Gatling Tests with Maven

One of the most common and streamlined approaches to executing your Gatling simulations from the command line involves using the Gatling Maven Plugin. This method is highly recommended for projects that are already structured and built with Maven.

Prerequisites

Before you can run your Gatling test from the command line using Maven, ensure you have the following in place:

  • Gatling Project: Your Gatling simulations should be part of a Maven-enabled project.
  • Maven Installation: Maven must be installed and correctly configured on your operating system (Windows, macOS, Linux).
  • Terminal Access: Access to a command prompt or terminal window.

Steps to Execute Your Gatling Test

Follow these straightforward steps to execute your Gatling simulations from the command line:

  1. Navigate to Your Project Directory: Open your preferred terminal or command prompt. Use the cd command to change your current directory to the root of your Gatling project. This is typically where your pom.xml file (Maven project configuration) is located.
  2. Execute the Maven Command: Once you are in the correct directory, type the following command and press Enter:
    mvn gatling:test
  3. Monitor the Execution: Gatling will begin compiling and executing your simulations. You will see real-time progress updates and log messages directly in your terminal.
  4. Access Test Reports: Upon completion of the test run, Gatling automatically generates comprehensive HTML reports. These reports, which include detailed metrics and graphs, are typically found in the target/gatling directory within your project.

Command Overview

The table below summarizes the primary command used for running Gatling tests via Maven:

Command Description
mvn gatling:test Executes all Gatling simulations detected within your Maven project by leveraging the Gatling Maven plugin.

Benefits of Command Line Execution

Running Gatling from the command line offers several significant advantages for developers and QA engineers:

  • Automation Integration: Command line execution makes it simple to integrate your performance tests into automated build and deployment processes (e.g., Jenkins, GitLab CI, GitHub Actions).
  • Resource Efficiency: Unlike GUI-based tools, command line execution requires fewer system resources, making it ideal for running tests on remote servers or in containerized environments.
  • Quick Iteration: Developers can rapidly run tests during their development cycles to quickly identify and address performance bottlenecks.
  • Parameterization: Advanced users can pass various parameters and system properties directly through the command line to configure specific aspects of their test runs, such as simulation name, number of users, or duration.