Basic Configuration for behat.yml file

Profile picture for user devraj

Behat has a very powerful configuration system based on YAML configuration files and profiles. You would have seen several variation of behat.yml project to project. This is basic configuration for behat.yml to starts with the project.

# behat.yml
default:
  suites:
    default:
      paths:
        features: features
        bootstrap: 'features/bootstrap'
      contexts:
        - Behat\MinkExtension\Context\MinkContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      default_session: goutte
      base_url: http://automationpractice.com

default: All configuration parameters in behat.yml file are defined under a profile name default. All other profiles inherit parameters from the default profile. If you only need one profile, define all of your parameters under the default.

suites: With suites you can configure Behat to test different kinds of features using different kinds of contexts and doing so in one run.

paths: Parameters under this configuration block tell Behat where to find your feature and bootstrap files:

  • features: The features parameter defines where Behat will look for your *.feature files. The given directory will be scanned recursively.
  • bootstrap: The bootstrap parameter defines the directory from which Behat will automatically load all *.php files.

contexts: You can define multiple context. Here we are using Mink to use the mink default functions.

extension: The extensions block allows you to activate extensions for your suite or for specific profile of the suite:

Tags