我开始行为
./bin/behat --suite=SuiteName --profile=profile_name
是否可以在FeatureContext中获取当前的行为配置文件名称,特别是在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 中完成的方式。
关于php - 贝哈特 3 : How to get profile name inside FeatureContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32520667/