Add behat in Symfony 4

To add behat in Symfony 4 i have generally followed this link

https://blog.rafalmuszynski.pl/how-to-configure-behat-with-symfony-4/

However i ran into problems so i thought of sharing this info.

The steps are

run composer req behat/behat --dev

but stumbled on the following error:

~/work/thefootie-behat $ composer req behat/behat --dev

Using version ^3.5 for behat/behat

./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Restricting packages listed in "symfony/symfony" to "4.1.*"

Your requirements could not be resolved to an installable set of packages.



  Problem 1

    - Installation request for behat/behat ^3.5 -> satisfiable by behat/behat[v3.5.0].

    - behat/behat v3.5.0 requires symfony/class-loader ~2.1||~3.0 -> satisfiable by symfony/class-loader[3.4.x-dev] but these conflict with your requirements or minimum-stability.


Installation failed, reverting ./composer.json to its original content.

It seems I had to choose to downgrade my minimum stability to dev to install this, as this is dev only packages I don't really mind.

~/work/thefootie-behat $ composer config minimum-stability dev

Following which I did not have any problems with the rest of the instructions.

Installation and adding config in behat.yml was fine, but when i tried to run behat i got the error below:

~/work/thefootie-behat $ ./vendor/behat/behat/bin/behat

PHP Warning:  require_once(/Users/devuser/work/thefootie-behat): failed to open stream: Undefined error: 0 in /Users/devuser/work/thefootie-behat/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1097

Warning: require_once(/Users/devuser/work/thefootie-behat): failed to open stream: Undefined error: 0 in /Users/devuser/work/thefootie-behat/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1097

PHP Fatal error:  require_once(): Failed opening required '/Users/devuser/work/thefootie-behat/' (include_path='.:/usr/local/Cellar/php/7.2.5/share/php/pear') in /Users/devuser/work/thefootie-behat/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1097

Fatal error: require_once(): Failed opening required '/Users/devuser/work/thefootie-behat/' (include_path='.:/usr/local/Cellar/php/7.2.5/share/php/pear') in /Users/devuser/work/thefootie-behat/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1097

After some googling i came across, a post and downgraded the behat/symfony2-extension to 2.1.5 - this seemed to have resolved the issue.

Turned out we used the behat/symfony2-extension with dev-master stability.

"Downgrading" to 2.1.5 resolved the issue.

After downgrading i can see the demo steps passed!


~/work/thefootie-behat $ ./vendor/behat/behat/bin/behat 
Feature:
  In order to prove that the Behat Symfony extension is correctly installed
  As a user
  I want to have a demo scenario

  Scenario: It receives a response from Symfony's kernel # features/demo.feature:10
    When a demo scenario sends a request to "/"          # FeatureContext::aDemoScenarioSendsARequestTo()
    Then the response should be received                 # FeatureContext::theResponseShouldBeReceived()

1 scenario (1 passed)
2 steps (2 passed)
0m0.20s (20.80Mb)

Comments

Popular posts from this blog

Install the right version of php_mongo.dll in windows

Installing sqlyog on Mac OS X Yosemite

Use ProxySQL to obfuscate data for development.