You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This simple test can be extended to a complete scenario of site usage, therefore, by emulating the user's actions, you can test any of your websites.
207
199
208
-
This simple test can be extended to a complete scenario of site usage, therefore,
209
-
by emulating the user's actions, you can test any of your websites.
210
-
211
-
To run more tests create a public method for each of them. Include `AcceptanceTester` object as `$I` as a method parameter and use the same `$I->` API you've seen before.
212
-
If your tests share common setup actions put them into `_before` method.
213
-
214
-
For instance, to test CRUD we want 4 methods to be implemented and all next tests should start at `/task` page:
200
+
To run more tests, create a public method for each of them. If your tests share common setup actions, put them into the `_before()` method:
215
201
216
202
```php
217
203
<?php
204
+
namespace Tests\Acceptance;
218
205
219
-
namespace Tests\Functional;
220
-
221
-
use \Tests\Support\FunctionalTester;
206
+
use Tests\Support\AcceptanceTester;
222
207
223
-
class TaskCrudCest
208
+
final class TaskCrudCest
224
209
{
225
-
function _before(AcceptanceTester $I)
210
+
public function _before(AcceptanceTester $I): void
226
211
{
227
212
// will be executed at the beginning of each test
228
213
$I->amOnPage('/task');
229
214
}
230
-
231
-
function createTask(AcceptanceTester $I)
232
-
{
233
-
// todo: write test
234
-
}
235
-
236
-
function viewTask(AcceptanceTester $I)
237
-
{
238
-
// todo: write test
239
-
}
240
-
241
-
function updateTask(AcceptanceTester $I)
242
-
{
243
-
// todo: write test
244
-
}
245
-
246
-
function deleteTask(AcceptanceTester $I)
247
-
{
248
-
// todo: write test
249
-
}
250
215
}
251
216
```
252
217
218
+
Learn more about the [Cest format](https://codeception.com/docs/AdvancedUsage#Cest-Classes) in the Advanced Testing chapter.
253
219
254
-
Learn more about the [Cest format](https://codeception.com/docs/07-AdvancedUsage#Cest-Classes) in the Advanced Testing section.
255
-
256
-
## BDD
220
+
## Behavior Driven Development (BDD)
257
221
258
-
Codeception allows execution of user stories in Gherkin format in a similar manner as is done in Cucumber or Behat.
259
-
Please refer to [the BDD chapter](https://codeception.com/docs/07-BDD) to learn more.
222
+
Codeception allows execution of user stories in Gherkin format in a similar manner as it is done in Cucumber or Behat.
223
+
Please refer to [the BDD chapter](https://codeception.com/docs/BDD) to learn more.
260
224
261
225
## Configuration
262
226
263
-
Codeception has a global configuration in `codeception.yml` and a config for each suite. We also support `.dist` configuration files.
227
+
Codeception has a global configuration file `codeception.yml` and a config for each suite. We also support `.dist` configuration files.
264
228
If you have several developers in a project, put shared settings into `codeception.dist.yml` and personal settings into `codeception.yml`.
265
-
The same goes for suite configs. For example, the `unit.suite.yml` will be merged with `unit.suite.dist.yml`.
229
+
The same goes for suite configs. For example, the `Unit.suite.yml` will be merged with `Unit.suite.dist.yml`.
266
230
267
231
## Running Tests
268
232
@@ -272,51 +236,44 @@ Tests can be started with the `run` command:
272
236
php vendor/bin/codecept run
273
237
```
274
238
275
-
276
239
With the first argument you can run all tests from one suite:
277
240
278
241
```bash
279
-
php vendor/bin/codecept run acceptance
242
+
php vendor/bin/codecept run Acceptance
280
243
```
281
244
282
-
283
245
To limit tests run to a single class, add a second argument. Provide a local path to the test class, from the suite directory:
284
246
285
247
```bash
286
-
php vendor/bin/codecept run acceptance SigninCest.php
248
+
php vendor/bin/codecept run Acceptance SigninCest.php
287
249
```
288
250
289
-
290
-
Alternatively you can provide the full path to test file:
251
+
Alternatively you can provide the full path to the test file:
291
252
292
253
```bash
293
-
php vendor/bin/codecept run tests/acceptance/SigninCest.php
254
+
php vendor/bin/codecept run tests/Acceptance/SigninCest.php
294
255
```
295
256
296
-
297
-
You can further filter which tests are run by appending a method name to the class, separated by a colon (for Cest or Test formats):
257
+
You can further filter which tests to run by appending a method name to the class, separated by a colon:
298
258
299
259
```bash
300
-
php vendor/bin/codecept run tests/acceptance/SigninCest.php:^anonymousLogin$
260
+
php vendor/bin/codecept run tests/Acceptance/SigninCest.php:^anonymousLogin$
301
261
```
302
262
303
-
304
-
You can provide a directory path as well. This will execute all acceptance tests from the `backend` dir:
263
+
You can provide a directory path as well. This will execute all Acceptance tests from the `backend` dir:
305
264
306
265
```bash
307
-
php vendor/bin/codecept run tests/acceptance/backend
266
+
php vendor/bin/codecept run tests/Acceptance/backend
308
267
```
309
268
310
-
311
269
Using regular expressions, you can even run many different test methods from the same directory or class.
312
-
For example, this will execute all acceptance tests from the `backend` dir beginning with the word "login":
270
+
For example, this will execute all Acceptance tests from the `backend` dir beginning with the word "login":
313
271
314
272
```bash
315
-
php vendor/bin/codecept run tests/acceptance/backend:^login
273
+
php vendor/bin/codecept run tests/Acceptance/backend:^login
316
274
```
317
275
318
-
319
-
To execute a group of tests that are not stored in the same directory, you can organize them in [groups](https://codeception.com/docs/07-AdvancedUsage#Groups).
276
+
To execute a group of tests that are not stored in the same directory, you can organize them in [groups](https://codeception.com/docs/AdvancedUsage#Groups).
320
277
321
278
### Reports
322
279
@@ -327,7 +284,7 @@ php vendor/bin/codecept run --steps --xml --html
327
284
```
328
285
329
286
330
-
This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. Reports will be stored in the `tests/_output/` directory.
287
+
This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. The reports will be stored in the `tests/_output/` directory.
331
288
332
289
Learn more about [available reports](/docs/Reporting).
333
290
@@ -354,7 +311,7 @@ There are plenty of useful Codeception commands:
354
311
355
312
## Conclusion
356
313
357
-
We have taken a look into the Codeception structure. Most of the things you need were already generated by the `bootstrap` command.
314
+
We have taken a look into Codeception's structure. Most of the things you need were already generated by the `bootstrap` command.
358
315
After you have reviewed the basic concepts and configurations, you can start writing your first scenario.
359
316
360
317
<div class="alert alert-warning"><a href="https://github.com/Codeception/codeception.github.com/edit/master/docs/GettingStarted.md"><strong>Improve</strong> this guide</a></div>
0 commit comments