Search code examples
gatlingscala-gatlingintellij-scala

Gatling Required ChainBuilder Found B When ExitOnBlockOrFail. Method Exec Not Recognised


I am wondering why this code shows an error saying that it expects a ChainBuilder but found B, and what B actually is. I'm a few months now wondering about this issue since my code still compiles with it but I would love to remove this error if possible.

enter image description here

Even when I simplify it the most but keeping the exitBlockOnFail piece it will still give me the red warning, so I'd like to know what is the connection between the two of them please.

// Error
object StudentDashboardBranches {

  def studentDashboard: ChainBuilder = exitBlockOnFail(
    exec {
      session =>
        println(session("session").as[String])
        session
    }
  )
  
}

// No error
object StudentDashboardBranches {

def studentDashboard: ChainBuilder = (
    exec {
      session =>
        println(session("session").as[String])
        session
    }
  )
}

And perhaps a different question or maybe related to the same issue, not sure, but the exec method appended after the pause is not recognised, however, this error doesn't leave if I delete the exitBlockOnFail piece as the first one does.

enter image description here

PS: These are my imports

import io.gatling.core.Predef.{exec, _}
import io.gatling.core.structure.ChainBuilder

Any help or clarification is much appreciated. Many thanks.

UPDATE

As per Stephane's answer, we were missing one of the imports.

import io.gatling.core.Predef._     // required for Gatling core structure DSL

It's working now.


Solution

  • Have you broken the DSL imports? If so, please check the doc.