Search code examples
phpbehat

Behat multiple features per domain


I would like to tell behat to run each feature file with other domain url.

There are 3 features for 3 different domains(changing) in the same folder.

domain1.feature
domain2.feature
domain3.feature

They do very similar things in the same FeatureContext.php but they have different parameters and set of other scenarios (per domain). Nature of project is to keep 3+ domains in the same spacename.

I thought I could use

Feature: "Domain1 Tests"

and then read this in constructor but not sure where to look or how. I do not want to edit behat.yml each time one domain gets replaced.

Anyone have solved similar challenge or have any suggestion?


Solution

  • Use a Background scenario in each feature to set the domain.

    For example:

      Background:
        Given I am on my_domain domain
    
      Scenario:
    

    Or if you have the same scenarios you should write some methods to handle the data based on the domain or other parameter and remove duplicate scenarios.
    Try not to duplicate scenarios only to be able to execute them on different domains, it would be a bad practice.