Gatling custom feeder compilation problem

I’ve recently started with learning Gatling. I’m also new to Scala. I’m trying to use a custom feeder for my gatling scenario.


private val feeder = Iterator.continually(Map(
 "value1" -> Random.nextInt(Integer.MAX_VALUE),
 "value2" -> Random.nextInt(Integer.MAX_VALUE))
)

scenario("perf test")
 .feed(feeder)

However the compilation fails at the last line where I provide my custom feeder to the scenario:

found   : Iterator[scala.collection.immutable.Map[String,Int]]
 required: io.gatling.core.feeder.FeederBuilder
    (which expands to)  () => Iterator[scala.collection.immutable.Map[String,Any]]

As far as I can see I’m doing the exact same thing as in the gatling feeder documentation. I have gatling version 3.3.1 and scala version 2.12. What am I doing wrong?

Try private val feeder: Iterator[Map[String, Any]] = ???

I’m getting a similar compilation error:

found : Iterator[scala.collection.immutable.Map[String,Any]]
required: io.gatling.core.feeder.FeederBuilder
(which expands to) () => Iterator[scala.collection.immutable.Map[String,Any]]
.feed(feeder)

Not sure what you’re doing exactly, but this should work out of the box.

Possibility #1: you’ve messed up Gatling imports.

You should have:

import io.gatling.core.Predef._
import io.gatling.http.Predef._

Don’t try doing anything stupid such as “organizing importing”, you’ll just end up breaking everything.

Possibility #2: you haven’t enabled implicitConversions on the scala-compiler

No idea how you code, but this option is enabled in all the official components and samples we provide:
https://github.com/gatling/gatling-maven-plugin-demo/blob/master/pom.xml#L54
https://github.com/gatling/gatling-sbt-plugin-demo/blob/master/build.sbt#L7
https://github.com/gatling/gatling/blob/master/gatling-compiler/src/main/scala/io/gatling/compiler/ZincCompiler.scala#L200

Indeed IntelliJ messed up the import statements. It is working now.

Thanks!