Sathish Chinnasamy
Sathish Chinnasamy

Reputation: 161

what is the standard way of using behavior-driven development (BDD) for robot framework?

Guide me how to use when, then, and etc

Sometimes i try to use When And And Then and sometimes Given When Then When Then

Is this valid ???

Upvotes: 0

Views: 172

Answers (2)

Suresh Parimi
Suresh Parimi

Reputation: 71

It is valid. If we use the way you mention in the question, we are mostly abusing the use of BDD. The question is tool agnostic.

BDD recommends: 1 feature -> 1 Behaviour ->1 Scenario -> 1 TestCase-> 1 result

You will cover more behaviours in BDD scenario, When you have multiple combinations of When-Then(like in your question). You will have a choice of dividing that scenario into independent scenarios. Just make sure you use the proper Given (preconditions) steps.

You can And as many times as possible in combination with Given or When or Then.The Golden Rule of BDD is to make sure the scenarios we write should be understood by the other readers intuitively. The more keywords you use the more information you are providing to the readers. More the information, more confusion in understanding the system behaviours. We should be cautious on how better we manage the information in one scenario.

Upvotes: 0

Brian O'Neill
Brian O'Neill

Reputation: 329

Not really a question related to Robot Framework. Gherkin Given, When, Then syntax is a small part of BDD.

RF does handle Gherkin prefixes on Keywords and most IDEs (with RF plugins) do also.

As for "sometimes Given When Then When Then"... this is typically not advised in BDD, but technically you can do as you like because the syntax really doesn't DO anything. It can help you make tests more readable and understandable.

I would argue that once you have Then that you should not see anymore Given or Whens, only Ands.

The Then is the assertion/outcome of the behaviour. If you feel you need another When-Then, you most likely need another test.

Upvotes: 3

Related Questions