Search code examples
kotlingatling

Problem with repeating Gatling scenario in kotlin language (possible problem with kotlin keyword "repeat"?)


I wrote such basic Gatling simulation in kotlin language based on web example:

import io.gatling.javaapi.core.Simulation
import io.gatling.javaapi.core.CoreDsl.exec
import io.gatling.javaapi.core.CoreDsl.scenario
import io.gatling.javaapi.http.HttpDsl.http

class SimpleScenariosSimulation : Simulation() {

    val httpProtocol = http.baseUrl("http://localhost").inferHtmlResources()
    val scn = scenario("repeat test").repeat(10)
    {
        exec(http("Home").get("/"))
    }

    init {
        setUp(
                scn.inject(rampUsers(10).during(5)).protocols(httpProtocol)
        )
    }

}

but intellij shows an error in line (repeat word is underlined)

    val scn = scenario("repeat test").repeat(10)

and shows a popup with

enter image description here

And when I add additional String argument to repeat function:

   val scn = scenario("repeat test").repeat(10, "")

Still this word is underlined with similar popup (this popup contains even already used way of function call!):

enter image description here

Is this caused because repeat is a keyword in Kotlin language?

How can I handle this situation?

BR, fotrenc


Solution

  • Please check the official documentation, you'll see snippets for each of the supported programming languages in Gatling: Java, Kotlin and Scala.

    In particular, in the repeat loop documentation:

    repeat(5).on(
      exec(http("name").get("/"))
    )
    

    In short, you're missing the on that's required in the Java DSL.