commit | author | age
|
2207d6
|
1 |
# Configuration |
W |
2 |
|
|
3 |
## Global Configuration |
|
4 |
|
|
5 |
Configuration file `codeception.yml` is generated by `codecept bootstrap` command. It has preconfigured settings you can change. |
|
6 |
|
|
7 |
Here are global options you can change inside configuration: |
|
8 |
|
|
9 |
* `actor: Tester`: changes suffix for Actor classes. This defines a rule to generate new test suites. If you change `Tester` to `Ninja`, and generate new `api` test suite, you will get `ApiNinja` actor class. |
|
10 |
* `namespace`: set a namespace for tests. All new tests and support classes will be generated under that namespace. Allows to configure [multiple test setups for one runner](http://codeception.com/docs/08-Customization#Namespaces). |
|
11 |
* `include: []`: include additional Codeception configurations for [multiple applications setup](http://codeception.com/docs/08-Customization#Namespaces). |
|
12 |
* `paths` directories used by Codeception. Default values are: |
|
13 |
|
|
14 |
```yaml |
|
15 |
paths: |
|
16 |
# where the tests stored |
|
17 |
tests: tests |
|
18 |
|
|
19 |
# directory for fixture data |
|
20 |
data: tests/_data |
|
21 |
|
|
22 |
# directory for support code |
|
23 |
support: tests/_support |
|
24 |
|
|
25 |
# directory for output |
|
26 |
output: tests/_output |
|
27 |
|
|
28 |
# directory for environment configuration |
|
29 |
envs: tests/_envs |
|
30 |
``` |
|
31 |
|
|
32 |
* `settings`: provide additional options for test runner. They may dramatically change the way Codeception is executed. For instance, take a note of `shuffle` option which allows to randomize tests execution order and `lint` option that toggles parsing a test file (using `php -l`) before loading it. |
|
33 |
|
|
34 |
```yaml |
|
35 |
settings: |
|
36 |
|
|
37 |
# name of bootstrap that will be used |
|
38 |
# each bootstrap file should be |
|
39 |
# inside a suite directory. |
|
40 |
bootstrap: _bootstrap.php |
|
41 |
|
|
42 |
# enable/disable syntax of test files before loading |
|
43 |
# for php < 7 exec('php -l') is used |
|
44 |
# disable if you need to speed up tests execution |
|
45 |
lint: true |
|
46 |
|
|
47 |
# randomize test order |
|
48 |
shuffle: true |
|
49 |
|
|
50 |
# by default it's false on Windows |
|
51 |
# use [ANSICON](https://github.com/adoxa/ansicon) to colorize output. |
|
52 |
colors: true |
|
53 |
|
|
54 |
# Generate XML JUnit report using strict schema |
|
55 |
# Avoid putting additional report fields like steps or scenario names to it |
|
56 |
# Required for XML reports on Jenkins CI |
|
57 |
strict_xml: false |
|
58 |
|
|
59 |
# Tests (especially functional) can take a lot of memory |
|
60 |
# We set a high limit for them by default. |
|
61 |
memory_limit: 1024M |
|
62 |
|
|
63 |
# This value controls whether PHPUnit attempts to backup global variables |
|
64 |
# See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals |
|
65 |
backup_globals: true |
|
66 |
|
|
67 |
# PHPUnit can be strict about tests that do not test anything |
|
68 |
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.useless-tests |
|
69 |
report_useless_tests: false |
|
70 |
|
|
71 |
# PHPUnit can be strict about output during tests. |
|
72 |
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.output-during-test-execution |
|
73 |
disallow_test_output: false |
|
74 |
|
|
75 |
# PHPUnit can be strict about tests that manipulate global state. |
|
76 |
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.global-state-manipulation |
|
77 |
be_strict_about_changes_to_global_state: false |
|
78 |
|
|
79 |
# Log the incomplete and skipped tests into junit report |
|
80 |
# See https://phpunit.de/manual/current/en/appendixes.configuration.html |
|
81 |
# Section logging > junit |
|
82 |
log_incomplete_skipped: false |
|
83 |
``` |
|
84 |
|
|
85 |
* `modules`: allows to create shared module configuration for all included suites. |
|
86 |
|
|
87 |
```yaml |
|
88 |
modules: |
|
89 |
config: |
|
90 |
Db: |
|
91 |
dsn: '' |
|
92 |
user: '' |
|
93 |
password: '' |
|
94 |
dump: tests/_data/dump.sql |
|
95 |
``` |
|
96 |
* `extends`: allows you to specify a file (relative to the `codeception.yml` file) that holds some already pre-defined values. This can be used to always use the same configuration for modules or whatever. |
|
97 |
* `extensions`: allows to enable and configure [Codeception extensions](http://codeception.com/docs/08-Customization#Extension), [Group Objects](http://codeception.com/docs/08-Customization#Group-Objects), and [Custom Commands](http://codeception.com/docs/08-Customization#Custom-Commands). |
|
98 |
* `reporters`: allows to [change default reporters](http://codeception.com/docs/08-Customization#Custom-Reporters) of Codeception |
|
99 |
* `coverage`: [CodeCoverage](http://codeception.com/docs/11-Codecoverage#Configuration) settings. |
|
100 |
* `params`: allows to pass [external parameters](http://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Params) into module configuration. |
|
101 |
* `gherkin`: BDD-specific [Gherkin options](http://codeception.com/docs/07-BDD#Configuration). |
|
102 |
|
|
103 |
## Suite Configuration |
|
104 |
|
|
105 |
Each generated suite have its own configuration inside directory set by `paths: tests: ` configuration option in `codeception.yml`. Each suite configuration is named like `suitename.suite.yml`. It allows to enable and configure modules, and more. |
|
106 |
|
|
107 |
* `actor`: name of the actor class for current suite. |
|
108 |
* `modules`: list of enabled modules with their configuration. |
|
109 |
|
|
110 |
```yaml |
|
111 |
modules: |
|
112 |
# enabled modules and helpers |
|
113 |
enabled: |
|
114 |
# built-in modules are listed by their names |
|
115 |
- PhpBrowser: |
|
116 |
# module configuration |
|
117 |
url: http://localhost |
|
118 |
# this module is pre-configured in global config |
|
119 |
- Db |
|
120 |
|
|
121 |
# helper names are listed by their class names |
|
122 |
# by convention their names start with \ |
|
123 |
- \Helper\Acceptance |
|
124 |
|
|
125 |
# additional modules configuration |
|
126 |
# can be used for modules which are not currently enabled |
|
127 |
config: |
|
128 |
WebDriver: |
|
129 |
browser: firefox |
|
130 |
|
|
131 |
# list of modules disabled for this suite |
|
132 |
disabled: |
|
133 |
- WebDriver |
|
134 |
|
|
135 |
``` |
|
136 |
|
|
137 |
* `extends`: allows you to specify a file (relative to the `*.suite.yml` file) that holds some already pre-defined values. This can be used to always use the same configuration for modules or whatever. |
|
138 |
* `namespace`: default namespace of actor, support classes and tests. |
|
139 |
* `suite_namespace`: default namespace for new tests of this suite (ignores `namespace` option) |
|
140 |
* `env`: override any configuration per [environment](http://codeception.com/docs/07-AdvancedUsage#Environments). |
|
141 |
* `groups`: [groups](http://codeception.com/docs/07-AdvancedUsage#Groups) with the list of tests of for corresponding group. |
|
142 |
* `formats`: [formats](http://codeception.com/docs/07-AdvancedUsage#Formats) with the list of extra test format classes. |
|
143 |
* `coverage`: pre suite [CodeCoverage](http://codeception.com/docs/11-Codecoverage#Configuration) settings. |
|
144 |
* `gherkin`: per suite [BDD Gherkin](http://codeception.com/docs/07-BDD#Configuration) settings. |
|
145 |
* `error_level`: [error level](http://codeception.com/docs/04-FunctionalTests#Error-Reporting) for runner in current suite. Should be specified for unit, integration, functional tests. Passes value to `error_reporting` function. |
|
146 |
|
|
147 |
## Config Templates (dist) |
|
148 |
|
|
149 |
To provide the same configuration template for your development team, you can create a `codeception.dist.yml` config file, which will be loaded before `codeception.yml`. The dist config provides shared options, while local `codeception.yml` files override them on a per-installation basis. Therefore, `codeception.yml` should be ignored by your VCS system. |
|
150 |
|
|
151 |
Config templates can also be used for suite configuration, by creating a `suitename.suite.dist.yml` file. |
|
152 |
|
|
153 |
Configuration loading order: |
|
154 |
|
|
155 |
1. `codeception.dist.yml` |
|
156 |
2. `codeception.yml` |
|
157 |
3. `acceptance.suite.dist.yml` |
|
158 |
4. `acceptance.suite.yml` |
|
159 |
5. environment config |