gatling tests uding a scala function

Hi There,

I’ve certain test data setup that I’m doing in before {} method. However I’ve certain variables defined in the same class (Refer to the below code ::slight_smile:

before {
//SetupContextWithAFewFields
}

val scn = scenario.exec(Context.retrieveAFewFields)

and my performance tests in another class uses scn to inject users.

scn.inject(atOnceUsers(n)).protocols(endpoint)

However, because the variables are initialized first, the context.retrieveAFewFields is being triggered even before the before{} is executed. So I thought I would move the scenario into a function and made the below chages ::

before {
//SetupContextWithAFewFields
}

def scnPrep() = {
scenario.exec(Context.retrieveAFewFields)
}

but how can I now call the tests ?

scnPrep().inject doesn’t seem to work