Behat 3:如何在 FeatureContext 中获取配置文件名称
Behat 3: How to get profile name inside FeatureContext
我开始
./bin/behat --suite=SuiteName --profile=profile_name
是否可以在 FeatureContext 中获取当前 behat 配置文件名称,尤其是在 BeforeSuiteScope
中
/**
* @BeforeSuite
*/
public static function beforeSuite(BeforeSuiteScope $scope)
{
}
所以我找到了蛮力法,我知道这可能不是获取个人资料名称的最佳方法,但它确实有效。
$input = new ArgvInput($_SERVER['argv']);
$profile = $input->getParameterOption(array('--profile', '-p')) ? : 'default';
var_dump($profile);die;
而ArgvInput
是Symfony\Component\Console\Input\ArgvInput
这就是 cli 参数在 behat 中的解析方式。
我开始
./bin/behat --suite=SuiteName --profile=profile_name
是否可以在 FeatureContext 中获取当前 behat 配置文件名称,尤其是在 BeforeSuiteScope
/**
* @BeforeSuite
*/
public static function beforeSuite(BeforeSuiteScope $scope)
{
}
所以我找到了蛮力法,我知道这可能不是获取个人资料名称的最佳方法,但它确实有效。
$input = new ArgvInput($_SERVER['argv']);
$profile = $input->getParameterOption(array('--profile', '-p')) ? : 'default';
var_dump($profile);die;
而ArgvInput
是Symfony\Component\Console\Input\ArgvInput
这就是 cli 参数在 behat 中的解析方式。