Php 不能以编程方式再次运行场景
在一个关于stackoverflow的问题之后,Ian找到了传递到behat参数的解决方案 对于环境来说没问题,但是对于国家参数,我有点困惑。我有这样一个特点:Php 不能以编程方式再次运行场景,php,behat,mink,scenarios,Php,Behat,Mink,Scenarios,在一个关于stackoverflow的问题之后,Ian找到了传递到behat参数的解决方案 对于环境来说没问题,但是对于国家参数,我有点困惑。我有这样一个特点: 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: |
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 |
但有了一个情景大纲,整个情景将针对每个国家运行。我想做同样的事情,但要有一个传入参数的国家列表
也许有了《赛纳里奥之后的钩子》或者类似的东西,我可以用不同的配置再次运行我的整个场景
谢谢 不幸的是,使用标准工具是不可能做到这一点的,至少在没有头痛和重新发明轮子的情况下是不可能的。一个有趣的问题 您可以通过在
behat.yml
中配置套件来实现这一点。您应该有一个带有基本配置的默认套件,以及每种语言的套件:
default:
extensions:
Behat\MinkExtension
suites:
default:
paths: […]
contexts: […]
US:
paths: […]
contexts: […]
IT:
paths: […]
contexts: […]
并使用@beforeSuite
挂钩:
/**
* @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.
}
此解决方案有几个缺点:
/**
* @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.
}