@@ -5,116 +5,166 @@ title: Commands - Codeception - Documentation
5
5
6
6
# Console Commands
7
7
8
- ## DryRun
8
+ ## CompletionFallback
9
9
10
- Shows step-by-step execution process for scenario driven tests without actually running them.
11
10
12
- * ` codecept dry-run acceptance `
13
- * ` codecept dry-run acceptance MyCest `
14
- * ` codecept dry-run acceptance checkout.feature `
15
- * ` codecept dry-run tests/acceptance/MyCest.php `
16
11
12
+ ## Run
17
13
14
+ Executes tests.
18
15
16
+ Usage:
19
17
20
- ## Build
18
+ * ` codecept run acceptance ` : run all acceptance tests
19
+ * ` codecept run tests/acceptance/MyCest.php ` : run only MyCest
20
+ * ` codecept run acceptance MyCest ` : same as above
21
+ * ` codecept run acceptance MyCest:myTestInIt ` : run one test from a Cest
22
+ * ` codecept run acceptance MyCest:myTestInIt#1 ` : run one example or data provider item by number
23
+ * ` codecept run acceptance MyCest:myTestInIt#1-3 ` : run a range of examples or data provider items
24
+ * ` codecept run acceptance MyCest:myTestInIt@name.* ` : run data provider items with matching names
25
+ * ` codecept run acceptance checkout.feature ` : run feature-file
26
+ * ` codecept run acceptance -g slow ` : run tests from * slow* group
27
+ * ` codecept run unit,functional ` : run only unit and functional suites
21
28
22
- Generates Actor classes (initially Guy classes) from suite configs.
23
- Starting from Codeception 2.0 actor classes are auto-generated. Use this command to generate them manually.
29
+ Verbosity modes:
24
30
25
- * ` codecept build `
26
- * ` codecept build path/to/project `
31
+ * ` codecept run -v ` :
32
+ * ` codecept run --steps ` : print step-by-step execution
33
+ * ` codecept run -vv ` : print steps and debug information
34
+ * ` codecept run --debug ` : alias for ` -vv `
35
+ * ` codecept run -vvv ` : print Codeception-internal debug information
27
36
37
+ Load config:
28
38
39
+ * ` codecept run -c path/to/another/config ` : from another dir
40
+ * ` codecept run -c another_config.yml ` : from another config file
29
41
42
+ Override config values:
30
43
31
- ## GenerateScenarios
44
+ * ` codecept run -o "settings: shuffle: true" ` : enable shuffle
45
+ * ` codecept run -o "settings: lint: false" ` : disable linting
32
46
33
- Generates user-friendly text scenarios from scenario-driven tests (Cest).
47
+ Run with specific extension
34
48
35
- * ` codecept g:scenarios acceptance ` - for all acceptance tests
36
- * ` codecept g:scenarios acceptance --format html ` - in html format
37
- * ` codecept g:scenarios acceptance --path doc ` - generate scenarios to ` doc ` dir
49
+ * ` codecept run --ext Recorder ` run with Recorder extension enabled
50
+ * ` codecept run --ext DotReporter ` run with DotReporter printer
51
+ * ` codecept run --ext "My\Custom\Extension" ` run with an extension loaded by class name
38
52
53
+ Full reference:
54
+ {% highlight yaml %}
55
+ Arguments:
56
+ suite suite to be tested
57
+ test test to be run
39
58
59
+ Options:
60
+ -o, --override=OVERRIDE Override config values (multiple values allowed)
61
+ --config (-c) Use custom path for config
62
+ --report Show output in compact style
63
+ --html Generate html with results (default: "report.html")
64
+ --xml Generate JUnit XML Log (default: "report.xml")
65
+ --phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml")
66
+ --no-redirect Do not redirect to Composer-installed version in vendor/codeception
67
+ --colors Use colors in output
68
+ --no-colors Force no colors in output (useful to override config file)
69
+ --silent Only outputs suite names and final results. Almost the same as ` --quiet `
70
+ --steps Show steps in output
71
+ --debug (-d) Alias for ` -vv `
72
+ --bootstrap Execute bootstrap script before the test
73
+ --coverage Run with code coverage (default: "coverage.serialized")
74
+ --disable-coverage-php Don't generate CodeCoverage report in raw PHP serialized format
75
+ --coverage-html Generate CodeCoverage HTML report in path (default: "coverage")
76
+ --coverage-xml Generate CodeCoverage XML report in file (default: "coverage.xml")
77
+ --coverage-text Generate CodeCoverage text report in file (default: "coverage.txt")
78
+ --coverage-phpunit Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
79
+ --coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
80
+ --no-exit Don't finish with exit code
81
+ --group (-g) Groups of tests to be executed (multiple values allowed)
82
+ --skip (-s) Skip selected suites (multiple values allowed)
83
+ --skip-group (-x) Skip selected groups (multiple values allowed)
84
+ --env Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
85
+ --fail-fast (-f) Stop after nth failure (defaults to 1)
86
+ --no-rebuild Do not rebuild actor classes on start
87
+ --help (-h) Display this help message.
88
+ --quiet (-q) Do not output any message. Almost the same as ` --silent `
89
+ --verbose (-v|vv|vvv) Increase the verbosity of messages: ` v ` for normal output, ` vv ` for steps and debug, ` vvv ` for Codeception-internal debug
90
+ --version (-V) Display this application version.
91
+ --ansi Force ANSI output.
92
+ --no-ansi Disable ANSI output.
93
+ --no-interaction (-n) Do not ask any interactive question.
94
+ --seed Use the given seed for shuffling tests
40
95
96
+ {% endhighlight %}
41
97
42
- ## ConfigValidate
43
98
44
- Validates and prints Codeception config.
45
- Use it do debug Yaml configs
46
99
47
- Check config:
48
-
49
- * ` codecept config ` : check global config
50
- * ` codecept config unit ` : check suite config
51
100
52
- Load config:
101
+ ## GenerateEnvironment
53
102
54
- * ` codecept config:validate -c path/to/another/config ` : from another dir
55
- * ` codecept config:validate -c another_config.yml ` : from another config file
103
+ Generates empty environment configuration file into envs dir:
56
104
57
- Check overriding config values (like in ` run ` command)
105
+ * ` codecept g:env firefox `
58
106
59
- * ` codecept config:validate -o "settings: shuffle: true" ` : enable shuffle
60
- * ` codecept config:validate -o "settings: lint: false" ` : disable linting
61
- * ` codecept config:validate -o "reporters: report: \Custom\Reporter" --report ` : use custom reporter
107
+ Required to have ` envs ` path to be specified in ` codeception.yml `
62
108
63
109
64
110
111
+ ## GherkinSnippets
65
112
66
- ## GenerateFeature
113
+ Generates code snippets for matched feature files in a suite.
114
+ Code snippets are expected to be implemented in Actor or PageObjects
67
115
68
- Generates Feature file (in Gherkin) :
116
+ Usage :
69
117
70
- * ` codecept generate:feature suite Login `
71
- * ` codecept g:feature suite subdir/subdir/login.feature `
72
- * ` codecept g:feature suite login.feature -c path/to/project `
118
+ * ` codecept gherkin:snippets acceptance ` - snippets from all feature of acceptance tests
119
+ * ` codecept gherkin:snippets acceptance/feature/users ` - snippets from ` feature/users ` dir of acceptance tests
120
+ * ` codecept gherkin:snippets acceptance user_account.feature ` - snippets from a single feature file
121
+ * ` codecept gherkin:snippets acceptance/feature/users/user_accout.feature ` - snippets from feature file in a dir
73
122
74
123
75
124
125
+ ## Build
76
126
77
- ## GherkinSteps
127
+ Generates Actor classes (initially Guy classes) from suite configs.
128
+ Starting from Codeception 2.0 actor classes are auto-generated. Use this command to generate them manually.
78
129
79
- Prints all steps from all Gherkin contexts for a specific suite
130
+ * ` codecept build `
131
+ * ` codecept build path/to/project `
80
132
81
- {% highlight yaml %}
82
- codecept gherkin: steps acceptance
83
133
84
- {% endhighlight %}
85
134
86
135
136
+ ## Console
87
137
138
+ Try to execute test commands in run-time. You may try commands before writing the test.
88
139
89
- ## GeneratePageObject
140
+ * ` codecept console acceptance ` - starts acceptance suite environment. If you use WebDriver you can manipulate browser with Codeception commands.
90
141
91
- Generates PageObject. Can be generated either globally, or just for one suite.
92
- If PageObject is generated globally it will act as UIMap, without any logic in it.
93
142
94
- * ` codecept g:page Login `
95
- * ` codecept g:page Registration `
96
- * ` codecept g:page acceptance Login `
97
143
144
+ ## GenerateFeature
98
145
146
+ Generates Feature file (in Gherkin):
99
147
100
- ## GenerateEnvironment
148
+ * ` codecept generate:feature suite Login `
149
+ * ` codecept g:feature suite subdir/subdir/login.feature `
150
+ * ` codecept g:feature suite login.feature -c path/to/project `
101
151
102
- Generates empty environment configuration file into envs dir:
103
152
104
- * ` codecept g:env firefox `
105
153
106
- Required to have ` envs ` path to be specified in ` codeception.yml `
107
154
108
155
156
+ ## Bootstrap
109
157
110
- ## GenerateCest
158
+ Creates default config, tests directory and sample suites for current project.
159
+ Use this command to start building a test suite.
111
160
112
- Generates Cest (scenario-driven object-oriented test) file:
161
+ By default, it will create 3 suites ** Acceptance ** , ** Functional ** , and ** Unit ** .
113
162
114
- * ` codecept generate:cest suite Login `
115
- * ` codecept g:cest suite subdir/subdir/testnameCest.php `
116
- * ` codecept g:cest suite LoginCest -c path/to/project `
117
- * ` codecept g:cest "App\Login" `
163
+ * ` codecept bootstrap ` - creates ` tests ` dir and ` codeception.yml ` in current dir.
164
+ * ` codecept bootstrap --empty ` - creates ` tests ` dir without suites
165
+ * ` codecept bootstrap --namespace Frontend ` - creates tests, and use ` Frontend ` namespace for actor classes and helpers.
166
+ * ` codecept bootstrap --actor Wizard ` - sets actor as Wizard, to have ` TestWizard ` actor in tests.
167
+ * ` codecept bootstrap path/to/the/project ` - provide different path to a project, where tests should be placed
118
168
119
169
120
170
@@ -128,209 +178,159 @@ Recursively cleans `output` directory and generated code.
128
178
129
179
130
180
131
- ## GenerateHelper
181
+ ## GeneratePageObject
132
182
133
- Creates empty Helper class.
183
+ Generates PageObject. Can be generated either globally, or just for one suite.
184
+ If PageObject is generated globally it will act as UIMap, without any logic in it.
134
185
135
- * ` codecept g:helper MyHelper `
136
- * ` codecept g:helper "My\Helper" `
186
+ * ` codecept g:page Login `
187
+ * ` codecept g:page Registration `
188
+ * ` codecept g:page acceptance Login `
137
189
138
190
139
191
192
+ ## GenerateSnapshot
140
193
141
- ## GenerateSuite
194
+ Generates Snapshot.
195
+ Snapshot can be used to test dynamical data.
196
+ If suite name is provided, an actor class will be included into placeholder
142
197
143
- Create new test suite. Requires suite name and actor name
198
+ * ` codecept g:snapshot UserEmails `
199
+ * ` codecept g:snapshot Products `
200
+ * ` codecept g:snapshot acceptance UserEmails `
144
201
145
- * ``
146
- * ` codecept g:suite api ` -> api + ApiTester
147
- * ` codecept g:suite integration Code ` -> integration + CodeTester
148
- * ` codecept g:suite frontend Front ` -> frontend + FrontTester
149
202
150
203
204
+ ## DryRun
151
205
206
+ Shows step-by-step execution process for scenario driven tests without actually running them.
152
207
153
- ## Console
208
+ * ` codecept dry-run acceptance `
209
+ * ` codecept dry-run acceptance MyCest `
210
+ * ` codecept dry-run acceptance checkout.feature `
211
+ * ` codecept dry-run tests/acceptance/MyCest.php `
154
212
155
- Try to execute test commands in run-time. You may try commands before writing the test.
156
213
157
- * ` codecept console acceptance ` - starts acceptance suite environment. If you use WebDriver you can manipulate browser with Codeception commands.
158
214
159
215
216
+ ## GenerateCest
160
217
161
- ## GenerateSnapshot
218
+ Generates Cest (scenario-driven object-oriented test) file:
162
219
163
- Generates Snapshot.
164
- Snapshot can be used to test dynamical data.
165
- If suite name is provided, an actor class will be included into placeholder
220
+ * ` codecept generate:cest suite Login `
221
+ * ` codecept g:cest suite subdir/subdir/testnameCest.php `
222
+ * ` codecept g:cest suite LoginCest -c path/to/project `
223
+ * ` codecept g:cest "App\Login" `
166
224
167
- * ` codecept g:snapshot UserEmails `
168
- * ` codecept g:snapshot Products `
169
- * ` codecept g:snapshot acceptance UserEmails `
170
225
171
226
172
227
173
- ## Init
228
+ ## GenerateTest
174
229
230
+ Generates skeleton for Unit Test that extends ` Codeception\TestCase\Test ` .
175
231
232
+ * ` codecept g:test unit User `
233
+ * ` codecept g:test unit "App\User" `
176
234
177
- ## GherkinSnippets
178
235
179
- Generates code snippets for matched feature files in a suite.
180
- Code snippets are expected to be implemented in Actor or PageObjects
181
236
182
- Usage:
237
+ ## ConfigValidate
183
238
184
- * ` codecept gherkin:snippets acceptance ` - snippets from all feature of acceptance tests
185
- * ` codecept gherkin:snippets acceptance/feature/users ` - snippets from ` feature/users ` dir of acceptance tests
186
- * ` codecept gherkin:snippets acceptance user_account.feature ` - snippets from a single feature file
187
- * ` codecept gherkin:snippets acceptance/feature/users/user_accout.feature ` - snippets from feature file in a dir
239
+ Validates and prints Codeception config.
240
+ Use it do debug Yaml configs
188
241
242
+ Check config:
189
243
244
+ * ` codecept config ` : check global config
245
+ * ` codecept config unit ` : check suite config
190
246
191
- ## GenerateStepObject
247
+ Load config:
192
248
193
- Generates StepObject class. You will be asked for steps you want to implement.
249
+ * ` codecept config:validate -c path/to/another/config ` : from another dir
250
+ * ` codecept config:validate -c another_config.yml ` : from another config file
194
251
195
- * ` codecept g:stepobject acceptance AdminSteps `
196
- * ` codecept g:stepobject acceptance UserSteps --silent ` - skip action questions
252
+ Check overriding config values (like in ` run ` command)
197
253
254
+ * ` codecept config:validate -o "settings: shuffle: true" ` : enable shuffle
255
+ * ` codecept config:validate -o "settings: lint: false" ` : disable linting
256
+ * ` codecept config:validate -o "reporters: report: \Custom\Reporter" --report ` : use custom reporter
198
257
199
258
200
259
201
- ## CompletionFallback
202
260
261
+ ## GenerateStepObject
203
262
263
+ Generates StepObject class. You will be asked for steps you want to implement.
204
264
205
- ## GenerateTest
265
+ * ` codecept g:stepobject acceptance AdminSteps `
266
+ * ` codecept g:stepobject acceptance UserSteps --silent ` - skip action questions
206
267
207
- Generates skeleton for Unit Test that extends ` Codeception\TestCase\Test ` .
208
268
209
- * ` codecept g:test unit User `
210
- * ` codecept g:test unit "App\User" `
211
269
212
270
271
+ ## SelfUpdate
213
272
214
- ## Bootstrap
273
+ Auto-updates phar archive from official site: ' https://codeception.com/codecept.phar ' .
215
274
216
- Creates default config, tests directory and sample suites for current project.
217
- Use this command to start building a test suite.
275
+ * ` php codecept.phar self-update `
218
276
219
- By default, it will create 3 suites ** Acceptance ** , ** Functional ** , and ** Unit ** .
277
+ @ author Franck Cassedanne < franck@cassedanne.com >
220
278
221
- * ` codecept bootstrap ` - creates ` tests ` dir and ` codeception.yml ` in current dir.
222
- * ` codecept bootstrap --empty ` - creates ` tests ` dir without suites
223
- * ` codecept bootstrap --namespace Frontend ` - creates tests, and use ` Frontend ` namespace for actor classes and helpers.
224
- * ` codecept bootstrap --actor Wizard ` - sets actor as Wizard, to have ` TestWizard ` actor in tests.
225
- * ` codecept bootstrap path/to/the/project ` - provide different path to a project, where tests should be placed
226
279
227
280
281
+ ## GenerateSuite
228
282
283
+ Create new test suite. Requires suite name and actor name
229
284
230
- ## Run
285
+ * ``
286
+ * ` codecept g:suite api ` -> api + ApiTester
287
+ * ` codecept g:suite integration Code ` -> integration + CodeTester
288
+ * ` codecept g:suite frontend Front ` -> frontend + FrontTester
231
289
232
- Executes tests.
233
290
234
- Usage:
235
291
236
- * ` codecept run acceptance ` : run all acceptance tests
237
- * ` codecept run tests/acceptance/MyCest.php ` : run only MyCest
238
- * ` codecept run acceptance MyCest ` : same as above
239
- * ` codecept run acceptance MyCest:myTestInIt ` : run one test from a Cest
240
- * ` codecept run acceptance MyCest:myTestInIt#1 ` : run one example or data provider item by number
241
- * ` codecept run acceptance MyCest:myTestInIt#1-3 ` : run a range of examples or data provider items
242
- * ` codecept run acceptance MyCest:myTestInIt@name.* ` : run data provider items with matching names
243
- * ` codecept run acceptance checkout.feature ` : run feature-file
244
- * ` codecept run acceptance -g slow ` : run tests from * slow* group
245
- * ` codecept run unit,functional ` : run only unit and functional suites
246
292
247
- Verbosity modes:
293
+ ## Init
248
294
249
- * ` codecept run -v ` :
250
- * ` codecept run --steps ` : print step-by-step execution
251
- * ` codecept run -vv ` : print steps and debug information
252
- * ` codecept run --debug ` : alias for ` -vv `
253
- * ` codecept run -vvv ` : print Codeception-internal debug information
254
295
255
- Load config:
256
296
257
- * ` codecept run -c path/to/another/config ` : from another dir
258
- * ` codecept run -c another_config.yml ` : from another config file
297
+ ## GenerateGroup
259
298
260
- Override config values:
299
+ Creates empty GroupObject - extension which handles all group events.
261
300
262
- * ` codecept run -o "settings: shuffle: true" ` : enable shuffle
263
- * ` codecept run -o "settings: lint: false" ` : disable linting
301
+ * ` codecept g:group Admin `
264
302
265
- Run with specific extension
266
303
267
- * ` codecept run --ext Recorder ` run with Recorder extension enabled
268
- * ` codecept run --ext DotReporter ` run with DotReporter printer
269
- * ` codecept run --ext "My\Custom\Extension" ` run with an extension loaded by class name
270
304
271
- Full reference:
272
- {% highlight yaml %}
273
- Arguments:
274
- suite suite to be tested
275
- test test to be run
305
+ ## GenerateScenarios
276
306
277
- Options:
278
- -o, --override=OVERRIDE Override config values (multiple values allowed)
279
- --config (-c) Use custom path for config
280
- --report Show output in compact style
281
- --html Generate html with results (default: "report.html")
282
- --xml Generate JUnit XML Log (default: "report.xml")
283
- --phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml")
284
- --no-redirect Do not redirect to Composer-installed version in vendor/codeception
285
- --colors Use colors in output
286
- --no-colors Force no colors in output (useful to override config file)
287
- --silent Only outputs suite names and final results. Almost the same as ` --quiet `
288
- --steps Show steps in output
289
- --debug (-d) Alias for ` -vv `
290
- --bootstrap Execute bootstrap script before the test
291
- --coverage Run with code coverage (default: "coverage.serialized")
292
- --disable-coverage-php Don't generate CodeCoverage report in raw PHP serialized format
293
- --coverage-html Generate CodeCoverage HTML report in path (default: "coverage")
294
- --coverage-xml Generate CodeCoverage XML report in file (default: "coverage.xml")
295
- --coverage-text Generate CodeCoverage text report in file (default: "coverage.txt")
296
- --coverage-phpunit Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
297
- --coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
298
- --no-exit Don't finish with exit code
299
- --group (-g) Groups of tests to be executed (multiple values allowed)
300
- --skip (-s) Skip selected suites (multiple values allowed)
301
- --skip-group (-x) Skip selected groups (multiple values allowed)
302
- --env Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
303
- --fail-fast (-f) Stop after nth failure (defaults to 1)
304
- --no-rebuild Do not rebuild actor classes on start
305
- --help (-h) Display this help message.
306
- --quiet (-q) Do not output any message. Almost the same as ` --silent `
307
- --verbose (-v|vv|vvv) Increase the verbosity of messages: ` v ` for normal output, ` vv ` for steps and debug, ` vvv ` for Codeception-internal debug
308
- --version (-V) Display this application version.
309
- --ansi Force ANSI output.
310
- --no-ansi Disable ANSI output.
311
- --no-interaction (-n) Do not ask any interactive question.
312
- --seed Use the given seed for shuffling tests
307
+ Generates user-friendly text scenarios from scenario-driven tests (Cest).
313
308
314
- {% endhighlight %}
309
+ * ` codecept g:scenarios acceptance ` - for all acceptance tests
310
+ * ` codecept g:scenarios acceptance --format html ` - in html format
311
+ * ` codecept g:scenarios acceptance --path doc ` - generate scenarios to ` doc ` dir
315
312
316
313
317
314
315
+ ## GenerateHelper
318
316
319
- ## SelfUpdate
317
+ Creates empty Helper class.
320
318
321
- Auto-updates phar archive from official site: 'https://codeception.com/codecept.phar ' .
319
+ * ` codecept g:helper MyHelper `
320
+ * ` codecept g:helper "My\Helper" `
322
321
323
- * ` php codecept.phar self-update `
324
322
325
- @author Franck Cassedanne < franck@cassedanne.com >
326
323
327
324
325
+ ## GherkinSteps
328
326
329
- ## GenerateGroup
327
+ Prints all steps from all Gherkin contexts for a specific suite
330
328
331
- Creates empty GroupObject - extension which handles all group events.
329
+ {% highlight yaml %}
330
+ codecept gherkin: steps acceptance
331
+
332
+ {% endhighlight %}
332
333
333
- * ` codecept g:group Admin `
334
334
335
335
336
336
0 commit comments