Robot Framework -> Gherkin -> Dependency between Given and When and Then

175 views
Skip to first unread message

sagdeoa

unread,
Aug 12, 2021, 12:45:18 PM8/12/21
to robotframework-users
Hi,

I recently started working with robot framework for api test development. Gherkin is completely new to me. 

How to manage the dependency between the Given and When and Then? For ex:
If I say that

Given create account is successful ( which may have the ability to return account no)
When I update my address (this keyword needs the account no set by Given)
Then account should be updated. 

Now for When to work successfully, it should know account id or transaction id or something similar which Given has created. How will Given pass data to When and so on.

How data persists between these keywords? I do not see any examples or BDD is not meant for such kind of examples?

Regards
Arundhati

Hélio Guilherme

unread,
Aug 12, 2021, 1:28:05 PM8/12/21
to robotframework-users
Hi,

You need to store the values somewhere. For example in a Test Suite Variable. So, before ending the Given step, you should have, something like:
${AccountNumber}=    Some Keyword returning your value
Set Suite Variable    AccountNumber

Then it should be available for next steps and tests.
 
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/899ea300-ba6c-49be-b7c4-9b3d56616cb4n%40googlegroups.com.

Craig Despeaux

unread,
Aug 12, 2021, 2:07:37 PM8/12/21
to robotframework-users
I think you want to use Set Test Variable.  That will make the variable available everywhere in the test once you set it. 

In my opinion, Set Suite Variable is more useful in Suite Setup when you need to set a variable that you want to have available in all tests.

Craig

sagdeoa

unread,
Aug 18, 2021, 6:47:37 AM8/18/21
to robotframework-users
This is very helpful. Thanks a lot.
Reply all
Reply to author
Forward
0 new messages