简体   繁体   中英

Debug Gatling Scala Code in Intellij with Maven Java Project

I didn't add a comment in this Debug Scala Post because in my opinion it was another setup.

I had a similiar problem with Maven instead of SBT. I used Maven because the complete Java project was built upon it and I only wanted to debug my Gatling Scala code. However I'm not able to debug the code with the IDE.

Here's what I tried:

  • Clean the built mvn clean install
  • Invalidate caches in IDEA with the menu button
  • Use println to see whether the code is reached - worked
  • Redeploy the project on the Glassfish
  • Delete the generated files in the Glassfish and redeploy

This is my current setup:

My solution is as follows.

With the help of colleague I figured out that the main class in Engine from the Gatling tutorial can be used to debug out of Intellij.

I basically built the whole archetype and moved the following files into the corresponding folders:

  • src/test/resources/gatling.conf
  • src/test/scala/Engine.scala and IDEPathHelper

That did the trick for me.

If anybody is finding hard to this just create a logback.xml file under src/test/resources and mention the following according to your need:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
            <immediateFlush>false</immediateFlush>
        </encoder>
    </appender>
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>../gatling.log</file>
        <append>true</append>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
        </encoder>
    </appender>
    <!-- Uncomment for logging ALL HTTP request and responses -->
    <!--  <logger name="io.gatling.http.ahc" level="TRACE" /> -->
    <!--   <logger name="io.gatling.http.response" level="TRACE" /> -->
    <!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
    <logger name="io.gatling.http.ahc" level="DEBUG" />
    <logger name="io.gatling.http.response" level="DEBUG" />
    <root level="WARN">
        <appender-ref ref="CONSOLE" />
    </root>
    <root level="WARN">
        <appender-ref ref="FILE" />
    </root>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM