1 System-wide installation
2 ========================
4 A system-wide installation allows you to maintain a single copy of the testing
5 tool set and use it for multiple test environments. Configuration is slightly
6 more complex than the stand-alone installation but many people prefer the
7 flexibility and ease-of-maintenance this setup provides.
12 To install the Drupal Extension globally:
15 #. Install the Drupal Extension in `/opt/drupalextension`
16 #. Create an alias to the behat binary in `/usr/local/bin`
17 #. Create your test folder
22 Composer is a PHP dependency manager that will make sure all the pieces you
23 need get installed. `Full directions for global installation
24 <http://getcomposer.org/doc/00-intro.md#globally>`_ and more information can be
25 found on the `Composer website <http://getcomposer.org/>`_.::
27 curl -sS https://getcomposer.org/installer |
28 php mv composer.phar /usr/local/bin/composer
30 Install the Drupal Extension
31 ----------------------------
33 #. Make a directory in /opt (or wherever you choose) for the Drupal Extension::
36 sudo mkdir drupalextension
39 2. Create a file called `composer.json` and include the following:
41 .. literalinclude:: _static/snippets/composer.json
45 3. Run the install command::
49 It will be a bit before you start seeing any output. It will also suggest
50 that you install additional tools, but they're not normally needed so you can
51 safely ignore that message.
53 4. Test that your install worked by typing the following::
57 If you were successful, you'll see the help output.
59 5. Make the binary available system-wide::
61 ln -s /opt/drupalextension/bin/behat /usr/local/bin/behat
66 1. Create the directory that will hold your tests. There is no technical
67 reason this needs to be inside the Drupal directory at all. It is best to
68 keep them in the same version control repository so that the tests match the
69 version of the site they are written for.
71 One clear pattern is to keep them in the sites folder as follows:
73 Single site: `sites/default/behat-tests`
75 Multi-site or named single site: `/sites/my.domain.com/behat-tests`
77 2. Wherever you make your test folder, inside it create the behat.yml file:
79 .. literalinclude:: _static/snippets/behat-1.yml
83 3. Initialize behat. This creates the features folder with some basic things to
88 4. This will generate a FeatureContext.php file that looks like:
90 .. literalinclude:: _static/snippets/FeatureContext.php.inc
95 This will make your FeatureContext.php aware of both the Drupal Extension and
96 the Mink Extension, so you'll be able to take advantage of their drivers and
97 step definitions and add your own custom step definitions here.
98 The FeatureContext.php file must be in the same directory as your behat.yml
99 file otherwise in step 5 you will get the following error:
101 [Behat\Behat\Context\Exception\ContextNotFoundException]
102 `FeatureContext` context class not found and can not be used.
105 5. To ensure everything is set up appropriately, type::
109 You'll see a list of steps like the following, but longer, if you've
110 installed everything successfully:
113 .. code-block:: gherkin
116 default | Given I am an anonymous user
117 default | Given I am not logged in
118 default | Given I am logged in as a user with the :role role(s)
119 default | Given I am logged in as :name