Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gherkin syntax And and But #29

Open
corrado4eyes opened this issue Aug 30, 2023 · 0 comments
Open

Gherkin syntax And and But #29

corrado4eyes opened this issue Aug 30, 2023 · 0 comments

Comments

@corrado4eyes
Copy link
Collaborator

And or But keywords is kind of syntactic sugar for the Gherkin syntax. They are used to avoid to be repetitive when describing some scenarios.

Docs

Instead of writing

feature("Some feature") {
    scenario("Some scenario") {
        given("The user is logged in") {
            // initialise user to be logged off
        }
        given("The user is not premium") {
            // initialise non premium user
        }
        then("The user should see the Home view") {
            // assert that the user sees the Home view and not another
        }
        then("The user should see the Upgrade button") {
            // assert toolbar is visible
        }
    }
}

One could simplify it

feature("Some feature") {
    scenario("Some scenario") {
        given("The user is logged in") {
            // initialise user to be logged off
        }.but("The user is not premium") {
            // initialise non premium user
        }
        
        then("The user should see the Home view") {
            // assert that the user sees the Home view and not another
        }.and("The user should see the Upgrade button") {
            // assert toolbar is visible
        }
        
    }
}

To note that but and and are basically an extension of then, when and given builder methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant