Search code examples
behat

bin/behat not accepting arguments


While attempting to fix another issue I'm having (Behat tests not running on CircleCI) I noticed that any argument I provide to bin/behat is not accepted. For example, if I run bin/behat -h, I don't get the help options. It just runs my tests. If I rename my behat.yml file to behat-test.yml, and try to run bin/behat --config behat-test.yml, I get an error stating that the FeatureContext can't be found. No matter what I type after bin/behat it is ignored and it runs my tests.

I added a var_dump in Behat's Application.php file and it is not capturing the arguments and prints an empty array. e.g.

    public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        if (null === $input) {
            $input = new ArgvInput();
        }
        var_dump($input);

Solution

  • Turns out, due to the nature of the CMS I'm working with I had to fudge some $_SERVER variables, and I had hard-coded $_SERVER['argv'] = array(), and forgot about it, which explains why no arguments were working.