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

How can I make BeforeSuite steps configurable? #182

Open
0xmichalis opened this issue Jun 10, 2019 · 2 comments
Open

How can I make BeforeSuite steps configurable? #182

0xmichalis opened this issue Jun 10, 2019 · 2 comments

Comments

@0xmichalis
Copy link

I need to do something like the following:

BeforeSuite:
   Given my db runs at "{{DB_HOST}}"

Scenario: 
    Given I can reach my api at "{{API_HOST}}"
    When I make a request to get all gifts with label "{{GIFT_LABEL}}"
    Then I should get at least 1 gift back

Then in a BeforeSuite step I want to seed my database, then I can run different scenarios in parallel that depend on the seeded data. I need to have DB_HOST configurable to enable my tests to run across environments (eg. a db deployed locally is going to have a different hostname from a db deployed on Kubernetes).

@l3pp4rd
Copy link
Member

l3pp4rd commented Jun 11, 2019

Hi, read the godoc. If you wanted it as a background step in gherkin, then change it.

Though, your gherkin looks ugly with these environment variables, why it cannot just take it from the step as Given my production database is running the step could read production as an argument, translate it to DB_HOST use the production database name and work on it.

@0xmichalis
Copy link
Author

@l3pp4rd the only inputs to the test are the variables passed through the arguments which makes it easier to reason about the actual requirements needed for the test to run. If I start mapping a word in a step with a source of inputs that I need to get in my tests via a different way, eg. environment variables then the test is more complicated to setup and run across all envs because now apart from setting up the features files appropriately I need to:

  • document that this test depends on an env variable apart from its feature file
  • make sure the right variable is set during the test's runtime

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

2 participants