0

I'm making many HTTP request with JSON Payload and I'm reading one file for every single request to get JSON Payload as below.

  postPayload1 = val postPayload = ElFileBody("Test_case1.json")

  val TC1 = feed(accountNumberFeeder1)
    .exec(http(testCase1).post(appendPathToUrl).headers(common_header).body(postPayload).asJSON
    .check(status.is(200)
    )

But, it becomes so many JSON files inside my resources directory now. So can I merge all my JSON together in one file as below.

{"testCase1":{
  "activationSource": "HH",
  "accountStatus": null,
}
}

{"testCase2":{
  "activationSource": "HH",
  "accountStatus": null,
}
}

and access it with my keys "testCase1", "testCase2" etc ?

val postPayload = ElFileBody("Test_case.json")
Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92

1 Answers1

0

From official Gatling Documentation, I found http://gatling.io/docs/2.2.1/session/feeder.html

JSON feeders Some might want to use data in JSON format instead of CSV:

val jsonFileFeeder = jsonFile("foo.json")
val jsonUrlFeeder = jsonUrl("http://me.com/foo.json")

For example, the following JSON:

[
  {
    "id":19434,
    "foo":1
  },
  {
    "id":19435,
    "foo":2
  }
]

will be turned into:

record1: Map("id" -> 19434, "foo" -> 1)
record2: Map("id" -> 19435, "foo" -> 2)

Note that the root element has of course to be an array.

Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92