Skip to content

Commit d330b60

Browse files
authored
Merge pull request #582 from ThomasLandauer/patch-3
Reorganizing the page
2 parents 2f9606a + 6b00720 commit d330b60

File tree

1 file changed

+122
-109
lines changed

1 file changed

+122
-109
lines changed

docs/reference/Configuration.md

Lines changed: 122 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -5,162 +5,175 @@ title: Configuration - Codeception - Documentation
55

66
# Configuration
77

8-
## Global Configuration
8+
## Global Configuration: `codeception.yml`
99

10-
Configuration file `codeception.yml` is generated by `codecept bootstrap` command. It has preconfigured settings you can change.
10+
The global configuration file `codeception.yml` is generated by the `codecept bootstrap` command. Alphabetical list of options:
1111

12-
Here are global options you can change inside configuration:
12+
### `actor_suffix`
1313

14-
* `actor_suffix: 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.
15-
* `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](https://codeception.com/docs/08-Customization#Namespaces).
16-
* `include: []`: include additional Codeception configurations for [multiple applications setup](https://codeception.com/docs/08-Customization#Namespaces).
17-
* `paths` directories used by Codeception. Default values are:
14+
Sets the suffix for "Actor" classes. Default: `Tester`. If you set it to `Ninja` and generate a new `api` test suite, you will get an `ApiNinja` actor class.
1815

19-
{% highlight yaml %}
16+
### `bootstrap`
2017

21-
paths:
22-
# where the tests stored
23-
tests: tests
18+
Bootstrap script that will be executed before all suites. A script should be put into `tests` directory.
19+
20+
### `coverage`
21+
22+
[CodeCoverage](https://codeception.com/docs/11-Codecoverage#Configuration) settings.
23+
24+
### `extends`
25+
26+
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.
27+
28+
### `extensions`
2429

25-
# directory for fixture data
26-
data: tests/_data
30+
Allows to enable and configure [Codeception extensions](https://codeception.com/docs/08-Customization#Extension), [Group Objects](https://codeception.com/docs/08-Customization#Group-Objects), and [Custom Commands](https://codeception.com/docs/08-Customization#Custom-Commands).
2731

28-
# directory for support code
29-
support: tests/_support
32+
### `gherkin`
3033

31-
# directory for output
32-
output: tests/_output
34+
[Gherkin options](https://codeception.com/docs/07-BDD#Configuration).
3335

34-
# directory for environment configuration
35-
envs: tests/_envs
36+
### `include`
3637

38+
Include additional Codeception configurations for [multiple applications setup](https://codeception.com/docs/08-Customization#Namespaces).
39+
40+
### `modules`
41+
42+
Allows to create shared module configuration for all included suites.
43+
44+
{% highlight yaml %}
45+
modules:
46+
config:
47+
Db:
48+
dsn: ''
49+
user: ''
50+
password: ''
51+
dump: tests/_data/dump.sql
3752
{% endhighlight %}
3853

39-
* `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.
54+
### `namespace`
55+
56+
Sets the namespace under which all new tests and support classes will be generated. Allows to configure [multiple test setups for one runner](https://codeception.com/docs/08-Customization#Namespaces).
57+
58+
### `params`
59+
60+
Allows to pass [external parameters](https://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Parameters) into module configuration.
61+
62+
### `paths`
63+
64+
Directories used by Codeception. Default values:
4065

4166
{% highlight yaml %}
67+
paths:
68+
tests : tests # where the tests stored
69+
data : tests/_data # directory for fixture data
70+
support: tests/_support # directory for support code
71+
output : tests/_output # directory for output
72+
envs : tests/_envs # directory for environment configuration
73+
{% endhighlight %}
4274

43-
settings:
75+
### `reporters`
76+
77+
Allows to [change default reporters](https://codeception.com/docs/08-Customization#Custom-Reporters) of Codeception
4478

45-
# enable/disable syntax of test files before loading
46-
# for php < 7 exec('php -l') is used
47-
# disable if you need to speed up tests execution
48-
lint: true
79+
### `settings`
4980

50-
# randomize test order
51-
shuffle: true
81+
Provide additional options for the 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.
5282

53-
# by default it's false on Windows
54-
# use [ANSICON](https://github.com/adoxa/ansicon) to colorize output.
83+
Syntax example:
84+
{% highlight yaml %}
85+
settings:
5586
colors: true
87+
{% endhighlight %}
5688

57-
# Generate XML JUnit report using strict schema
58-
# Avoid putting additional report fields like steps or scenario names to it
59-
# Required for XML reports on Jenkins CI
60-
strict_xml: false
89+
Possible settings:
6190

62-
# Tests (especially functional) can take a lot of memory
63-
# We set a high limit for them by default.
64-
memory_limit: 1024M
91+
* `backup_globals: true`: Controls whether PHPUnit attempts to backup global variables, see https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals
92+
* `be_strict_about_changes_to_global_state: false`: PHPUnit can be strict about tests that manipulate global state, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.global-state-manipulation
93+
* `colors: true`: By default this is false on Windows. Use [ANSICON](https://github.com/adoxa/ansicon) to colorize output.
94+
* `disallow_test_output: false`: PHPUnit can be strict about output during tests, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.output-during-test-execution
95+
* `editor_url: 'atom://core/open/file?filename=%%file%%&line=%%line%%'`: In the console output, the test runner will replace all references to files with "clickable" URL's, allowing you to open the file directly in your IDE. Depending on your operating system, you may have to set up an appropriate uri handler. Syntax for some common editors (same as in [PHPStan](https://phpstan.org/user-guide/output-format#opening-file-in-an-editor)):
96+
* PhpStorm: `'phpstorm://open?file=%%file%%&line=%%line%%'`
97+
* Visual Studio Code: `'vscode://file/%%file%%:%%line%%'`
98+
* Atom: `'atom://core/open/file?filename=%%file%%&line=%%line%%'`
99+
* `error_level: E_ALL & ~E_STRICT & ~E_DEPRECATED`: Set the error_reporting level. You can specify either a predefined constant or an integer value, see https://www.php.net/manual/en/function.error-reporting.php and https://www.php.net/manual/en/errorfunc.constants.php
100+
* `memory_limit: 1024M`: Tests (especially functional) can take a lot of memory. We set a high limit for them by default.
101+
* `lint: true`: Enable/disable syntax of test files before loading. For PHP < 7 `exec('php -l')` is used. Disable if you need to speed up tests execution.
102+
* `log_incomplete_skipped: false`: Log the incomplete and skipped tests into junit report ,see https://phpunit.de/manual/current/en/appendixes.configuration.html Section logging > junit
103+
* `report_useless_tests: false`: PHPUnit can be strict about tests that do not test anything, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.useless-tests
104+
* `shuffle: true`: Randomize test order
105+
* `strict_xml: false`: Generate XML JUnit report using strict schema. Avoid putting additional report fields like steps or scenario names to it. Required for XML reports on Jenkins CI
65106

66-
# This value controls whether PHPUnit attempts to backup global variables
67-
# See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals
68-
backup_globals: true
107+
## Suite Configuration: `unit.suite.yml`, `functional.suite.yml` etc.
69108

70-
# PHPUnit can be strict about tests that do not test anything
71-
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.useless-tests
72-
report_useless_tests: false
109+
Each suite has its own configuration inside the directory set by `paths: tests: ` in `codeception.yml`. Alphabetical list of options:
73110

74-
# PHPUnit can be strict about output during tests.
75-
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.output-during-test-execution
76-
disallow_test_output: false
111+
### `actor`
77112

78-
# PHPUnit can be strict about tests that manipulate global state.
79-
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.global-state-manipulation
80-
be_strict_about_changes_to_global_state: false
113+
Name of the "Actor" class of the current suite.
81114

82-
# Log the incomplete and skipped tests into junit report
83-
# See https://phpunit.de/manual/current/en/appendixes.configuration.html
84-
# Section logging > junit
85-
log_incomplete_skipped: false
115+
### `bootstrap`
86116

87-
# Set the error_reporting level
88-
# You can specify either a predefined constant or an integer value
89-
# See https://www.php.net/manual/en/function.error-reporting.php
90-
# See https://www.php.net/manual/en/errorfunc.constants.php
91-
error_level: E_ALL & ~E_STRICT & ~E_DEPRECATED
117+
Bootstrap script that will be executed before current suite. A script should be put into suite directory.
92118

93-
{% endhighlight %}
119+
### `coverage`
94120

95-
* `modules`: allows to create shared module configuration for all included suites.
121+
Per suite [CodeCoverage](https://codeception.com/docs/11-Codecoverage#Configuration) settings.
96122

97-
{% highlight yaml %}
123+
### `env`
98124

99-
modules:
100-
config:
101-
Db:
102-
dsn: ''
103-
user: ''
104-
password: ''
105-
dump: tests/_data/dump.sql
125+
Override any configuration per [environment](https://codeception.com/docs/07-AdvancedUsage#Environments).
106126

107-
{% endhighlight %}
108-
* `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.
109-
* `extensions`: allows to enable and configure [Codeception extensions](https://codeception.com/docs/08-Customization#Extension), [Group Objects](https://codeception.com/docs/08-Customization#Group-Objects), and [Custom Commands](https://codeception.com/docs/08-Customization#Custom-Commands).
110-
* `reporters`: allows to [change default reporters](https://codeception.com/docs/08-Customization#Custom-Reporters) of Codeception
111-
* `coverage`: [CodeCoverage](https://codeception.com/docs/11-Codecoverage#Configuration) settings.
112-
* `params`: allows to pass [external parameters](https://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Parameters) into module configuration.
113-
* `gherkin`: BDD-specific [Gherkin options](https://codeception.com/docs/07-BDD#Configuration).
114-
* `bootstrap`: bootstrap script that will be executed before all suites. A script should be put into `tests` directory.
127+
### `error_level`
115128

116-
## Suite Configuration
129+
[error level](https://codeception.com/docs/04-FunctionalTests#Error-Reporting) for runner in the current suite. Can be specified for unit, integration, functional tests. Passes value to `error_reporting` function.
117130

118-
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.
131+
### `extends`
119132

120-
* `actor`: name of the actor class for current suite.
121-
* `modules`: list of enabled modules with their configuration.
133+
Allows you to specify a file (relative to `*.suite.yml`) that holds some already pre-defined values. This can be used to always use the same configuration for modules or whatever.
122134

123-
{% highlight yaml %}
135+
### `gherkin`
124136

137+
Per suite [Gherkin](https://codeception.com/docs/07-BDD#Configuration) settings.
138+
139+
### `groups`
140+
141+
[groups](https://codeception.com/docs/07-AdvancedUsage#Groups) with the list of tests of for corresponding group.
142+
143+
### `formats`
144+
145+
[formats](https://codeception.com/docs/07-AdvancedUsage#Formats) with the list of extra test format classes.
146+
147+
### `modules`
148+
149+
List of enabled modules with their configuration.
150+
151+
{% highlight yaml %}
125152
modules:
126-
# enabled modules and helpers
127153
enabled:
128-
# built-in modules are listed by their names
129-
- PhpBrowser:
130-
# module configuration
131-
url: http://localhost
132-
# this module is pre-configured in global config
133-
- Db
134-
135-
# helper names are listed by their class names
136-
# by convention their names start with \
137-
- \Helper\Acceptance
138-
139-
# additional modules configuration
140-
# can be used for modules which are not currently enabled
154+
- PhpBrowser: # built-in modules are listed by their names
155+
url: http://localhost # module configuration
156+
- Db # Module without configuration (or inherited from `codeception.yml`)
157+
- \Helper\Acceptance # helper names are listed by their class names, starting with `\`
158+
159+
# Additional modules configuration; can be used for modules which are not currently enabled
141160
config:
142161
WebDriver:
143162
browser: firefox
144163

145-
# list of modules disabled for this suite
146164
disabled:
147-
- WebDriver
165+
- WebDriver # modules disabled for this suite
166+
{% endhighlight %}
148167

168+
### `namespace`
149169

150-
{% endhighlight %}
170+
Default namespace of actor, support classes and tests.
171+
172+
### `suite_namespace`
173+
174+
Default namespace for new tests of this suite (ignores `namespace` option)
151175

152-
* `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.
153-
* `namespace`: default namespace of actor, support classes and tests.
154-
* `suite_namespace`: default namespace for new tests of this suite (ignores `namespace` option)
155-
* `env`: override any configuration per [environment](https://codeception.com/docs/07-AdvancedUsage#Environments).
156-
* `groups`: [groups](https://codeception.com/docs/07-AdvancedUsage#Groups) with the list of tests of for corresponding group.
157-
* `formats`: [formats](https://codeception.com/docs/07-AdvancedUsage#Formats) with the list of extra test format classes.
158-
* `coverage`: per suite [CodeCoverage](https://codeception.com/docs/11-Codecoverage#Configuration) settings.
159-
* `gherkin`: per suite [BDD Gherkin](https://codeception.com/docs/07-BDD#Configuration) settings.
160-
* `error_level`: [error level](https://codeception.com/docs/04-FunctionalTests#Error-Reporting) for runner in current suite. Can be specified for unit, integration, functional tests. Passes value to `error_reporting` function. Suite specific value will override the global value.
161-
* `bootstrap`: bootstrap script that will be executed before current suites. A script should be put into suite directory.
162-
163-
## Config Templates (dist)
176+
## Configuration Templates: `*.dist.yml`
164177

165178
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.
166179

0 commit comments

Comments
 (0)