Ability to share values across different test scenarios in the same run
A
Amir Ahmetovic
Right now if I run batch tests (all test scenarios in one folder), I'm unable to reuse values between test scenarios.
Let's say I have a folder X with test scenarios:
- TS1
- TS2
- TS3
If I have a post script in TS1 which saves a value (variable, environment or global), I can't reused the value in any pre-/post- scripts on TS2 or TS3.
N
Nichole Garcia
When TS1 has extracted environment variables/global variables, and the running configuration of the test scenario has selected to save the variable change value, both TS2 and TS3 can use this variable.
If it doesn't take effect, please provide a screenshot to help us reproduce it better.
A
Amir Ahmetovic
Nichole Garcia That's how I imagined it to work but it doesn't. The value is only available for API calls within TS1 but not TS2 or TS3 (it's undefined in both cases).
I've even tried to set the global in the post-processor in TS1 but it's still happening the same.
The whole reason why I'm trying to make this work is I want to log in the user only once in TS1 and then reuse auth token in all subsequent test scenarios within the same folder.
Basically I'm trying to setup E2E testing that I'd like to run through Apidog CLI (apidog run -f XXX -e YYY) but values are not being saved. Is it because I'm running tests via CLI and not the UI?
N
Nichole Garcia
Amir AhmetovicWhen running a specific test scenario folder using CLI, each scenario is run separately. When a scenario ends, the variable values of that scenario are released.
The reason why it runs normally within the client is because when a scenario ends within the client, the variable values are saved in the local environment variable, so the next scenario can use these variable values.
We recommend the following practice: if a variable will be used in other scenarios as well, it is recommended to extract it in a single scenario, which is data preparation. Other scenarios can reference this data preparation test scenario, ensuring that a single scenario does not depend on other scenarios.
A
Amir Ahmetovic
Nichole Garcia But doesn't this mean I'd have to do login every time since after login request is successful I get the access token? I'd rather avoid this if possible as there is no need to go through the login over and over again for each test scenario.
Also, is there a reason why running tests via UI and CLI is different? Shouldn't this functionality have the same behavior regardless of the way how API testing was initiated?
N
Nichole Garcia
Amir AhmetovicThank you for your feedback. We have evaluated your request and will support batch running of CLI across testing scenarios using environment and global variables.
Currently, you may need to solve the issue by referencing testing scenarios. You can reference all the testing scenarios that need to be run in the same scenario, and then the CLI will only execute one testing scenario.