Search code examples
phpbehatminkautotest

Behat 3: How to get profile name inside FeatureContext


I am starting behat with

./bin/behat --suite=SuiteName --profile=profile_name

Is it possible to get current behat profile name inside FeatureContext especially inside BeforeSuiteScope

/**
 * @BeforeSuite
 */
public static function beforeSuite(BeforeSuiteScope $scope)
{
}

Solution

  • So I found brute force method, I know probably its not the best way of getting profile name, but it works.

    $input   = new ArgvInput($_SERVER['argv']);
    $profile = $input->getParameterOption(array('--profile', '-p')) ? : 'default';
    var_dump($profile);die;
    

    And ArgvInput is Symfony\Component\Console\Input\ArgvInput

    Thats how cli params parsing done in behat.