execute a chain with a feeder

Hi,

I use Gatling 2.0.0-M3a. I have a test like this:

val scn = scenario(“Normal user”)

feed(feeder)
.exec(
http(“signup”)
.post("/rest/signup")
.body(StringBody("${jsonFromTheFeeder}")).asJSON)

Basically a feeder and a signup http request. It works. I wanted to split my tests into multiple files to make it more organised. So I created a package for the rest interface and classes for each “service”.
I wanted something like this:

val scn = scenario(“Normal user”)
exec(signup)

and signup in a separate place:
val signup = exec(

feed(feeder)
.exec(
http(“signup”)
.post("/rest/signup")
.body(StringBody("${jsonFromTheFeeder}")).asJSON))

It doesn’t work that way… Could you please tell me what could be the problem?

Hi,

It doesn’t work that way

Meaning that it doesn’t compile or something else?
What happens exactly?

When I run It I get an exception:

java.lang.reflect.InvocationTargetException
Caused by: java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException

  1. június 23., hétfő 11:37:05 UTC+2 időpontban Stéphane Landelle a következőt írta:

Don’t you have a stracktrace, please?

Your problem is that you’re doing a forward reference.

If you write something like:

val scn = scenario(“Normal user”)
.exec(signup)

val signup = …

signup hasn’t been assigned when you’re evaluating scn, hence the NPE.

You have to write:

val signup = …

val scn = scenario(“Normal user”)
.exec(signup)

Oh… Thank you so much!

  1. június 23., hétfő 12:34:00 UTC+2 időpontban Stéphane Landelle a következőt írta: