Feeder file not working with test

Hello all,

This is my third attempt at posting this question. I have a test I have been working on and I wanted to utilize a feeder file to simulate user inputs. I’ve tried putting the declaration and call of the feeder file in many different places in my code. I put the declaration inside the object, outside the object but in the class, down by the scenario declaration, and I’ve placed the call in the scenario declaration and in the object. Not sure where else I might have to put it. Here is the code I’ve used:

object AddUser{

val feeder = csv(“UserFeeder.csv”).random

val addUser = feed(feeder)
.exec(http(“Add_User”)
.post("/Path/to/URI/")
.body(StringBody("""{“action”:“ADDUSER”,
“session”:"${currentSession}",
“username”:"${username}",
“password”:“somePassword”,
“fullname”:"${fullname}",
“email”:"${email}"
}"""))
.transformResponse{
case response if response.isReceived =>
new ResponseWrapper(response) {
val stripped = response.body.string
println("### stripped = " + stripped)
override val body = new StringResponseBody(stripped, response.charset)
}
}
.asJSON
.check(jsonPath("$.result").is(“true”))
.check(status.is(200))
.extraInfoExtractor(ExtraInfo => {
if(ExtraInfo.status==“KO”)
println("httpCode: " + ExtraInfo.response.statusCode + ", Response: " + ExtraInfo.response.body)
List(ExtraInfo.response.statusCode, ExtraInfo.response.body.string)}))

}

I have also thought that maybe the location of the feeder file might have been the problem. I placed it originally in the data folder within the user-files folder. I have also tried it in the simulations folder with the script. When I try to run the test, no report is created and it basically appears to fail, but the test begins to run and closes out nearly immediately. I also attempted to see if the Advanced Simulation that came with the Gatling program would work (the one that requires the feeder file) and this provided the same results.

Anyone have any idea what is going on with this? Thank you in advance for your help.

Rob

You can try placing that datafile in user-files folder and your datafile should have the top column with the names that your would like to retrieve
like —
firstName,lasteName,mobile,country
mark,zuck,0913384,usa
harry,potter,091031,hogwards


Thanks for the response Leela. I tried moving the feeder file to my user-files folder as you suggested, and still had the same result. I do have the top row of my csv file as labels for my data. I did try it early on without that first row, but added it in after about half a dozen attempts.

Rob

In my case, I use the csvFeeder like this
val csvFeeeder = csv(“dataFile.csv”).circular

and my datafile is in user-files folder. May be its trouble with the imports. Not sure. What’re the imports that u’re using in your project

Here is a list of the imports I have for my project.

import io.gatling.core.Predef._
import io.gatling.core.feeder._
import io.gatling.core.session._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.response.ResponseWrapper
import io.gatling.http.response.StringResponseBody
import scala.concurrent.duration._
import scala.util.parsing.json._
import scala.util.Random

This is including imports for other portions of the project. Please let me know if you see anything.

Rob

Everything looks correct. Here are my list of imports,

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.util.Random

Don’t know why it’s not working for you

Turns out my Gatling files got corrupted. I had to reinstall Gatling. Everything works fine now. Thanks for all the help, despite that.

Rob

Sweet.