We are trying to modularise our test code to make it more accessible to team members who have no experience with Scala. So we use separate files to define standard HTTP configurations (e.g. with and without support for debugging request/response data), various feeders, application-specific HTTP requests, test profiles, and scenarios. Lastly there are the actual tests (with the setUp part) themselves, which in most cases are the only thing people need to touch.
This mostly works okay, but there’s a slight snag with test profiles.
We can run the following, and it works fine:
setUp(
Scenario.scenario1(accounts).inject(constantUsersPerSec (1) during (5 seconds),nothingFor (10 seconds),heavisideUsers(1000) over(360 seconds)),
Scenario.scenario2(accounts).inject(constantUsersPerSec (1) during (5 seconds),nothingFor (10 seconds),heavisideUsers(1000) over(360 seconds)),
Scenario.scenario3(accounts).inject(constantUsersPerSec (1) during (5 seconds),nothingFor (10 seconds),heavisideUsers(1000) over(360 seconds)),
).protocols(Config.debugHttpConfig)
But if we separate out the profile (i.e. the part inside the ‘inject’) into another file it doesn’t work:
val profile1 = Seq(constantUsersPerSec (1) during (5 seconds),
nothingFor (10 seconds),
heavisideUsers(1000) over(360 seconds))
setUp(
Scenario.scenario1(accounts).inject(Profile.profile1),
Scenario.scenario2(accounts).inject(Profile.profile2),
Scenario.scenario3(accounts).inject(Profile.profile3)
).protocols(Config.debugHttpConfig)
Instead we have to add ‘:_*’ as follows:
setUp(
Scenario.scenario1(accounts).inject(Profile.profile1:*),
Scenario.scenario2(accounts).inject(Profile.profile2:),
Scenario.scenario3(accounts).inject(Profile.profile3:_)
).protocols(Config.debugHttpConfig)
That’s not too bad, but is it possible to somehow overload inject() such that a sequence is also accepted?