Skip to content

Commit 9c75446

Browse files
committed
grammar fixes
1 parent 514d75c commit 9c75446

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

guides/07-AdvancedUsage.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Advanced Usage
22

3-
In this chapter we will cover some techniques and options that you can use to improve your testing experience
3+
In this chapter, we will cover some techniques and options that you can use to improve your testing experience
44
and keep your project better organized.
55

66
## Cest Classes
77

8-
Cest is a common test format for Codeception, it is "Test" firth first C letter in it.
9-
It is scenario-driven format so all tests written in it are executed step by steps.
10-
Unless you need direct access to application code inside a test, Cest format is recommended to use.
8+
Cest is a common test format for Codeception, it is "Test" with the first C letter in it.
9+
It is scenario-driven format so all tests written in it are executed step by step.
10+
Unless you need direct access to application code inside a test, Cest format is recommended.
1111
As it provides more readable code for functional, api, and acceptance tests.
1212

1313
A new Cest class can be created via `g:cest` command:
@@ -75,8 +75,8 @@ that may be used in child classes. But don't forget to make these methods `prote
7575

7676
Cest format also can contain hooks based on test results:
7777

78-
* `_failed` will be executed on failed test
79-
* `_passed` will be executed on passed test
78+
* `_failed` will be executed for failed test
79+
* `_passed` will be executed for passed test
8080

8181
```php
8282
public function _failed(AcceptanceTester $I)
@@ -117,7 +117,7 @@ class UserCest {
117117
}
118118
```
119119

120-
If you need skipping a test on condition, inject `\Codeception\Scenario` into the test:
120+
If you need to skip a test on a condition, inject `\Codeception\Scenario` into the test:
121121

122122
```php
123123
public function worksOnCondition(AcceptanceTester $I, \Codeception\Scenario $scenario)
@@ -133,7 +133,7 @@ public function worksOnCondition(AcceptanceTester $I, \Codeception\Scenario $sce
133133
}
134134
```
135135

136-
For unit tests tests can be skipped via attribute or by `markTestSkipped` method:
136+
Unit tests can be skipped via the attribute or by using `markTestSkipped` method:
137137

138138
```php
139139
<?php
@@ -166,7 +166,7 @@ class UserTest extends \Codeception\Test\Unit
166166

167167
## Incomplete Tests
168168

169-
Tests can be marked as Incomplete, in this case they also will be skipped.
169+
Tests can be marked as Incomplete, in this case, they also will be skipped.
170170
To mark a test as incomplete use `Codeception\Attribute\Incomplete` which should be used similarly to `Skip` attribute:
171171

172172
```php
@@ -199,7 +199,7 @@ You can execute one (or several) specific groups of tests:
199199
php vendor/bin/codecept run -g admin -g editor
200200
```
201201

202-
The concept of groups was taken from PHPUnit and behave in the same way.
202+
The concept of groups was taken from PHPUnit and behaves in the same way.
203203

204204
For Test and Cest files you can use the `Group` attribute to add a test to a group.
205205

@@ -213,7 +213,7 @@ use Tests\Support\AcceptanceTester
213213
class UserCest {
214214

215215
#[Group('admin')] // set a group for this test
216-
#[Group('slow', 'important')] // add more groups
216+
#[Group('slow', 'important')] // add groups in a single attribute
217217
public function testAdminUser(AcceptanceTester $I)
218218
{
219219
}
@@ -345,7 +345,7 @@ class ModeratorCest {
345345

346346
### Dependencies
347347

348-
With the `Depends` attribute you can specify a test that should be passed before the current one.
348+
With the `Depends` attribute, you can specify a test that should be passed before the current one.
349349
If that test fails, the current test will be skipped. You should pass the method name of the test you are relying on.
350350

351351
```php
@@ -385,11 +385,11 @@ Codeception reorders tests so dependent tests will always be executed before the
385385

386386
## Environments
387387

388-
For cases where you need to run tests with different configurations you can define different config environments.
388+
For cases where you need to run tests with different configurations, you can define different config environments.
389389
The most typical use cases are running acceptance tests in different browsers,
390390
or running database tests using different database engines.
391391

392-
Let's demonstrate the usage of environments for the browsers case.
392+
Let's demonstrate the usage of environments for multi-browser testing.
393393

394394
We need to add some new lines to `acceptance.suite.yml`:
395395

@@ -427,8 +427,7 @@ paths:
427427

428428
```
429429

430-
The names of these files are used as environments names
431-
(e.g. `chrome.yml` or `chrome.dist.yml` for an environment named `chrome`).
430+
The names of these files are used as environment names (e.g. `chrome.yml` or `chrome.dist.yml` for an environment named `chrome`).
432431
You can generate a new file with this environment configuration by using the `generate:environment` command:
433432

434433
```
@@ -496,6 +495,12 @@ class UserCest
496495
}
497496
```
498497

498+
Multiple values can be set in one attribute:
499+
500+
```php
501+
#[Env('chrome', 'firefox')]
502+
```
503+
499504
This way you can easily control which tests will be executed for each environment.
500505

501506
It is possible to combine environments. For instance, if a test should be executed only in chrome on staging, this can be declared as a combined environment:
@@ -512,9 +517,9 @@ php vendor/bin/codecept run --env chrome,staging
512517

513518
## Get Test Metadata
514519

515-
Sometimes you may need to change the test behavior in real time.
520+
Sometimes you may need to change the test behavior in real-time.
516521
For instance, the behavior of the same test may differ in Firefox and in Chrome.
517-
In runtime we can retrieve the current environment name, test name,
522+
In runtime, we can retrieve the current environment name, test name,
518523
or list of enabled modules by calling the `$scenario->current()` method.
519524

520525
```php
@@ -554,7 +559,7 @@ public function myTest(\Codeception\Scenario $scenario)
554559

555560
## Shuffle
556561

557-
By default Codeception runs tests in alphabetic order.
562+
By default, Codeception runs tests in alphabetic order.
558563
To ensure that tests are not depending on each other (unless explicitly declared via `@depends`) you can enable `shuffle` option.
559564

560565
```yaml
@@ -564,15 +569,15 @@ settings:
564569

565570
```
566571

567-
Alternatively, you may run tests in shuffle without changing the config:
572+
Alternatively, you may run tests in the shuffle without changing the config:
568573

569574
```yaml
570575
codecept run -o "settings: shuffle: true"
571576
```
572577
573578
574-
Tests will be randomly reordered on each run. When tests executed in shuffle mode a seed value will be printed.
575-
Copy this seed value from output to be able to rerun tests in the same order.
579+
Tests will be randomly reordered on each run. When tests are executed in shuffle mode a seed value will be printed.
580+
Copy this seed value from the output to be able to rerun tests in the same order.
576581
577582
```yaml
578583
$ codecept run
@@ -663,7 +668,7 @@ which can be constructed with arguments known to Codeception.
663668

664669
In order to make auto-wiring work, you will need to implement the `_inject()` method with the list of desired arguments.
665670
It is important to specify the type of arguments, so Codeception can guess which objects are expected to be received.
666-
The `_inject()` will only be invoked once, just after creation of the TestCase object (either Cest or Test).
671+
The `_inject()` will only be invoked once, just after the creation of the TestCase object (either Cest or Test).
667672
Dependency Injection will also work in a similar manner for Helper and Actor classes.
668673

669674
Each test of a Cest class can declare its own dependencies and receive them from method arguments:
@@ -694,9 +699,4 @@ Moreover, Codeception can resolve dependencies recursively (when `A` depends on
694699
and handle parameters of primitive types with default values (like `$param = 'default'`).
695700
Of course, you are not allowed to have *cyclic dependencies*.
696701

697-
## Conclusion
698-
699-
Codeception is a framework which may look simple at first glance
700-
but it allows you to build powerful tests with a single API, refactor them,
701-
and write them faster using the interactive console. Codeception tests can be easily organized in groups or Cest classes.
702702

0 commit comments

Comments
 (0)