State management in test scenario #1642
Unanswered
InvictusMB
asked this question in
How to... ?
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I haven't found any specific guidelines on managing state in test scenarios other than Delayed assertions section.
I want to create a
Task
to solve captcha for an integration test of the API. Captcha lives in JWT inside cookie which I can decrypt if I know a secret.The task could be split into 3 smaller things:
I need a way to pass data between those. My best guess is that I could use Ability to store the state and Question to pull it out for further interactions.
This is how I would approach the implementation:
I can imagine I will need
CallAPIEnpoints
ability in the first place. That ability should also be able to expose cookies of the latest request. I will then use that ability insideFetchCaptcha
interaction.I can use
TakeNote
interaction to save intermediate state but that needs aQuestion
. So I will create aLastRequestCookie
question.Then I will need
DecryptToken
ability that will be used byDecryptCaptcha
interaction.DecryptCaptcha
interaction will also takeQuestion
as an argument.That question will be something like
NoteOnATopic
. Which might be a good addition to Serenity core btw.There will be
LastDecryptedToken
question to access the state ofDecryptToken
ability.And finally a
PostSolvedCaptcha
interaction that takes aQuestion
as an argument.The pseudocode might look like this:
Does that make sense or I am making it too complex?
I believe I could get away without taking notes if those interactions would always come together in that sequence.
Are there other ways to pass data between interactions?
It looks a bit ugly to me because questions become tightly coupled with implementation details of an interaction but that coupling is implicit.
If FetchCaptcha implementation details change and it starts using different ability, LastRequestCookie question would know nothing about it and will just fail in run time.
Beta Was this translation helpful? Give feedback.
All reactions