2
Given user is currently at Login page

With the Given above it would be invalid if I include the actual navigation to login page in the step definition simply because navigating to a page is an action and should be included in When.. unless that's just fine... or is there any other way to do it?

@Given("user is currently at Login page")
def user_is_at_login_page(){
    WebUI.openBrowser('/login')
    WebUI.verifyElementPresent('Login Page Heading')
}

I'm using Katalon Studio btw

  • That is just fine. – Mate Mrše Dec 5 '19 at 9:06
3

Given is your setup, it brings the system under test in a state you can start doing the action you want to test.

The given part describes the state of the world before you begin the behavior you're specifying in this scenario. You can think of it as the pre-conditions to the test.

https://martinfowler.com/bliki/GivenWhenThen.html

Depending on the complexity of the Given it will most likely do actions that other scenarios would do as a when.

Often my givens (for example: Given a fresh user is on page X) do the following in a single step:

  • Clean data
  • Create data and users
  • Login user
  • Navigate to the wanted state

I like to keep my Given, When, Thens as short as possible, they should describe the behaviour not the details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.