Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / vendor / drupal / drupal-extension / doc / subcontexts.rst
1 Contributed Module Subcontexts
2 ==============================
3
4 Although not yet a wide-spread practice, the Drupal Extension to Behat and Mink
5 makes it easy for maintainers to include custom step definitions in their
6 contributed projects.
7
8
9 Discovering SubContexts
10 -----------------------
11
12 In order to use contributed step definitions, define the search path in the
13 behat.yml
14
15 // sites/default/behat-tests/behat.yml
16
17 .. literalinclude:: _static/snippets/behat-sub.yml
18    :language: yaml
19    :linenos:
20    :emphasize-lines: 8-9,25-26
21
22 The Drupal Extension will search recursively within the directory or
23 directories specified to discover and load any file ending in `.behat.inc`. This
24 system, although created with Drupal contrib projects in mind, searches where
25 it's pointed, so you can also use it for your own subcontexts, a strategy you
26 might employ to re-use step definitions particular to your shop or company's
27 development patterns. The `paths` key allows running tests located in features
28 within the `features` directory of a contributed/custom module.
29
30 Disable autoloading
31 -------------------
32 Autoloading can be disabled in the behat.yml file temporarily with the
33 following:
34
35 .. literalinclude:: _static/snippets/behat-auto.yml
36    :language: yaml
37    :linenos:
38    :emphasize-lines: 25 
39
40 For Contributors
41 ----------------
42 Behat `subcontexts
43 <http://docs.behat.org/guides/4.context.html#using-subcontexts>`_ are no longer
44 supported in version 3. The Drupal Extension, however, continues to support
45 saving module-specific contexts in a file ending with `.behat.inc` 
46
47 Just like functions, preface the filename with the project's machine name to prevent namespace collisions.
48
49   .. literalinclude:: _static/snippets/subcontext.inc
50      :language: php
51      :linenos: