How to specify dependency between multiple given, when or then in cucumber-jvm

684 views Asked by At

I have a feature file which has multiple given when and then steps for ex

// File My.feature
Give doUserLogin
And changeUserPreference
When executeWhen1
And executeWhen2
Then executeThen1
And executeThen2

These are mapped to step definitions correctly, the problem i'm facing is that some are getting executed parallel for ex. in given, 'changeUserPreference' is happening before 'doUserLogin'. Similarly in Then part, 'executeThen2' is triggered before 'executeThen1' is fully completed.

How to specify the dependency between these statements.Is there any way i can say don't start execution of second statement(given, when or then) until first one is executed completely.

1

There are 1 answers

0
BakaTono On

If your 'doUserLogin' step is exiting before the download completes, that would explain why the 'changeUserPreference' is starting up. This could happen, say, if you were connecting to an external system and initiating a download and then the api you are using is performing the download in another thread, then the main thread would continue on to the next step while the download is continuing in another thread.

My advice would be to execute this scenario in debug mode (assuming you are using an IDE that supports this) and see if your 'doUserLogin' step is finishing before the file download.