{"id":9342,"date":"2017-07-25T10:15:32","date_gmt":"2017-07-25T10:15:32","guid":{"rendered":"http:\/\/abstracta.us\/?p=9342"},"modified":"2025-05-05T21:20:47","modified_gmt":"2025-05-05T21:20:47","slug":"tutorial-use-gatling-maven","status":"publish","type":"post","link":"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/","title":{"rendered":"Tutorial: How to Use Gatling With Maven"},"content":{"rendered":"<p><!-- Go to www.addthis.com\/dashboard to customize your tools --><script src=\"\/\/s7.addthis.com\/js\/300\/addthis_widget.js#pubid=ra-58d80a50fc4f926d\" type=\"text\/javascript\"><\/script><\/p>\n<h1>Another key integration for\u00a0enabling CI\/CD<\/h1>\n<p><span style=\"font-weight: 400; color: #333333;\"><span style=\"font-weight: 400;\">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\u2019ll show you how to integrate Gatling, use Scala to develop a simulation, and how to execute this with Maven for generating reports.<\/span><\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Preparing_a_Project_with_Maven\"><\/span>Preparing a Project with Maven<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">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.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Dependencies_and_Plugins\"><\/span>Dependencies and Plugins<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400; color: #333333;\"><span style=\"font-weight: 400;\">To use Gatling with Maven we will need to add a dependency (<a href=\"https:\/\/mvnrepository.com\/artifact\/io.gatling.highcharts\" target=\"_blank\" rel=\"noopener\">gatling-charts-highcharts<\/a>) and a plugin (<a href=\"http:\/\/gatling.io\/docs\/current\/extensions\/maven_plugin\/\" target=\"_blank\" rel=\"noopener\">gatling-maven-plugin<\/a>) to our project\u2019s 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:<\/span><\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-1-min.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-9343\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-1-min.png\" alt=\"plugin\" width=\"797\" height=\"74\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Later we will see how we can utilize some of these commands.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The pom.xml file looks more or less like this:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/image-7-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9368 size-full\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/image-7-min.png\" alt=\"how to use gatling with maven\" width=\"1157\" height=\"742\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">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.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">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.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Development_IDE\"><\/span>Development IDE<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">I tried two different IDEs, one based on <a href=\"https:\/\/eclipse.org\/ide\/\" target=\"_blank\" rel=\"noopener\">Eclipse<\/a>, and one on <a href=\"https:\/\/www.jetbrains.com\/idea\/\" target=\"_blank\" rel=\"noopener\">IntelliJ<\/a>. 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\u2019s almost automatic).<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Prepare_a_Simulation_Script\"><\/span>Prepare a Simulation (Script)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Now let\u2019s develop a script utilizing Scala that will contain the simulation that we wish to run.<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/image-6-min.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-9367\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/image-6-min.png\" alt=\"image (6)-min\" width=\"1270\" height=\"739\" \/><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_to_Prepare_a_Simple_Test\"><\/span>How to Prepare a Simple Test<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">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\u2019s necessary to capture the HTTP traffic between the client and the server. One of the ways to do this is using the \u201cNetwork\u201d tab in Chrome\u2019s 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<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Execution_of_Gatling_with_Maven\"><\/span>Execution of Gatling with Maven<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">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:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-4-min.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-9346\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-4-min.png\" alt=\"mvn clean gatling:execute\" width=\"817\" height=\"92\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">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:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/Screen-Shot-2017-07-25-at-12.50.17-PM.png\"><img decoding=\"async\" class=\"alignnone wp-image-9364 size-full\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/Screen-Shot-2017-07-25-at-12.50.17-PM.png\" alt=\"commands\" width=\"695\" height=\"83\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">During the execution we can see the console output:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-6-min-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-9374\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-6-min-1.png\" alt=\"picture 6-min (1)\" width=\"901\" height=\"487\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Results\"><\/span>Results<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">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\u2019s execution. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Once it\u2019s opened we will see a web report such as this:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-8-min.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-9351\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-8-min.png\" alt=\"Gatling Report screenshot\" width=\"805\" height=\"358\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"In_Closing\"><\/span>In Closing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">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\u00e1n Serrano for greatly helping to put this tutorial on how to use Gatling with Maven together.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Have any questions? Leave us a comment!\u00a0<\/span><\/p>\n<hr \/>\n<h2><span class=\"ez-toc-section\" id=\"Recommended_for_You\"><\/span><strong>Recommended for You<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"color: #00b674;\"><a href=\"http:\/\/abstracta.us\/blog\/performance-testing\/gatling-vs-jmeter-findings\/\"><span style=\"font-weight: 400;\">Gatling vs. JMeter: Our Findings<\/span><\/a><br \/>\n<a href=\"http:\/\/abstracta.us\/blog\/performance-testing\/best-time-start-performance-testing\/\">When is the Best Time to Start Performance Testing?<\/a>\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/abstracta.us\/insights\/guide-continuous-testing\/\"><img decoding=\"async\" class=\"aligncenter wp-image-11292\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2016\/01\/D1erALeXgAALwsi-300x192.png\" alt=\"guide to continuous testing\" width=\"500\" height=\"320\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another key integration for\u00a0enabling CI\/CD 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\u2019ll show you how to integrate Gatling, use&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[222,102,50,642],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Tutorial: How to Use Gatling With Maven | Abstracta<\/title>\n<meta name=\"description\" content=\"In this post, we will see how to use Gatling with Maven, creating an integration via plugins, an essential tool for the world of CI\/CD.\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tutorial: How to Use Gatling With Maven | Abstracta\" \/>\n<meta property=\"og:description\" content=\"In this post, we will see how to use Gatling with Maven, creating an integration via plugins, an essential tool for the world of CI\/CD.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AbstractaQA\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-07-25T10:15:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-05T21:20:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/TUTORIAL-min.png\" \/>\n\t<meta property=\"og:image:width\" content=\"560\" \/>\n\t<meta property=\"og:image:height\" content=\"315\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fltoledo\" \/>\n<meta name=\"twitter:site\" content=\"@AbstractaUS\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/abstracta.us\/blog\/#website\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\",\"description\":\"AI-powered quality engineering\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/abstracta.us\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/07\/picture-1-min.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/#webpage\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/\",\"name\":\"Tutorial: How to Use Gatling With Maven | Abstracta\",\"isPartOf\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/#primaryimage\"},\"datePublished\":\"2017-07-25T10:15:32+00:00\",\"dateModified\":\"2025-05-05T21:20:47+00:00\",\"author\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/7421e539de0357d3adb0c69ed469a1c2\"},\"description\":\"In this post, we will see how to use Gatling with Maven, creating an integration via plugins, an essential tool for the world of CI\/CD.\",\"breadcrumb\":{\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-tools\/\",\"name\":\"Testing Tools\"}},{\"@type\":\"ListItem\",\"position\":3,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-tools\/tutorial-use-gatling-maven\/\",\"name\":\"Tutorial: How to Use Gatling With Maven\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/7421e539de0357d3adb0c69ed469a1c2\",\"name\":\"Federico Toledo, Chief Quality Officer at Abstracta\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6de7ec6536c4028b5c02ad4ec1b9af0d?s=96&d=blank&r=g\",\"caption\":\"Federico Toledo, Chief Quality Officer at Abstracta\"},\"description\":\"Co-founder and COO of Abstracta\",\"sameAs\":[\"https:\/\/twitter.com\/fltoledo\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9342"}],"collection":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/comments?post=9342"}],"version-history":[{"count":25,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9342\/revisions"}],"predecessor-version":[{"id":16033,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9342\/revisions\/16033"}],"wp:attachment":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/media?parent=9342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/categories?post=9342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/tags?post=9342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}