Login once for multiple scenarios

Hi I’ve been looking though all the resources I can and haven’t been able to find and agreeable solution to what I’m trying to achieve. I want to run scenarios which emulates our users real world usage, this requires certain actions being taken periodically. I wanted to be able to login with my user once and then perform different actions based on the setup of scenarios, in order to get this working I’d need to be able to login before the scenarios kick off due to the lack of ability to share between scenarios, I was planning then to use a shared array to store the auth and session information which is sent with each request as headers. But you can’t send a http request in the init phase, so what is the solution here, do I really need to send a login request each time I start a test function within scenarios, because that is going to have a significant impact on the performance of my api and doesn’t emulate the real world situation, I can’t be allow in this. Is there suggested way of handling this kind of thing? I guess in essence this is another call for shared state in scenarios feature.

Does the setup() function satisfy your requirements? It is executed once per test, at the beginning, before any scenarios start executing. And its result is made available to all of the scenario functions.

1 Like

Thanks ned, this works for my login situation, I didn’t realise you could use setup() in scenarios, I don’t know why it didn’t click, thanks again :+1: