After a question on stackoverflow Parameters in Behat 3 Ian found a solution for pass to behat parameters.
For environment it's ok, but for country parameters I'm a bit confused. I have a feature like this :
Scenario Outline: Test if first link works
Given I am on website "<country>"
Then I visit the url "my-url"
Then I click on first link
Examples:
| country |
| US |
| IT |
This is what I have, and now I want to run something like :
env="stg" country="US,IT" php53 bin/behat --suite=mySuite
But with a scenario outline, the whole scenario is run for each country. I want to do the same thing, but with a list of country passed in parameters.
Maybe with the hook AfterScenario or something like that I can run again my whole scenario with a different configuration ?
Thanks !
That unfortunately isn't possible with standard tools, at least not without a headache and reinventing the wheel. An interesting question though!
You might get this working by configuring the suites in your behat.yml
. You should have a default suite with the base configuration, and a suite for each language:
default:
extensions:
Behat\MinkExtension
suites:
default:
paths: […]
contexts: […]
US:
paths: […]
contexts: […]
IT:
paths: […]
contexts: […]
And use a @beforeSuite
hook:
/**
* @beforeSuite
*
* @param BeforeSuiteScope $scope
*/
public static function setUpSuite(BeforeSuiteScope $scope)
{
$suiteName = $scope->getSpecificationIterator()->getSuite()->getName();
// If the suite denotes one of the languages, then set it as the main language.
}
This solution has a few cons:
Another solution that comes to mind is to just use another PHP / Bash script that will sequentially run Behat with the country param. It also have some cons:
As you see, this is not a trivial task. Personally I have a better belief in the second solution, though it might be more timely, it also gives space for a lot of customisation. On another hand, unless you have a completely different content / logic for each country, you might not need to go into such extremes. Doing a few targeted checks that language can be changed and that it changes as expected should be enough. Re-running same tests for 40 countries would take hours and won't add any significant value.