In BDD can we replace [setup] with Given when we use gherkins syntax?

104 views Asked by At

I use GHERKINS syntax:

GIVEN ..
WHEN ..
THEN ..

In my robot test cases My question is : When i want to add [SETUP] + [TEARDOWN] how can i insert them?

Can GIVEN replace setup or i should include both ?

[SETUP]
GIVEN ..
WHEN .. 
THEN ..
[TEARDOWN] 
2

There are 2 answers

1
Helio On

Usually we move the code to a single user defined keyword, and then call it from [SETUP] or [TEARDOWN].

Never tested but, it might be possible to write, in [SETUP]:

Run Keywords     GIVEN ..    AND    WHEN ..    AND    THEN ..

But then the Gherkin readability does not look so good.

0
WerKop On

I don't see any issue with replacing [SETUP] with Given word. [SETUP] is not mandatory, nor [TEARDOWN]