Skip to content

Commit 1e209b8

Browse files
Update GettingStarted.md
1 parent b77de27 commit 1e209b8

File tree

1 file changed

+32
-38
lines changed

1 file changed

+32
-38
lines changed

docs/GettingStarted.md

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,40 @@ Codeception follows simple naming rules to make it easy to remember (as well as
1717

1818
* **Actions** start with a plain english verb, like "click" or "fill". Examples:
1919

20-
```php
21-
$I->click('Login');
22-
$I->fillField('#input-username', 'John Dough');
23-
$I->pressKey('#input-remarks', 'foo');
24-
```
20+
```php
21+
$I->click('Login');
22+
$I->fillField('#input-username', 'John Dough');
23+
$I->pressKey('#input-remarks', 'foo');
24+
```
2525

2626
* **Assertions** always start with "see" or "dontSee". Examples:
2727

28-
```php
29-
$I->see('Welcome');
30-
$I->seeInTitle('My Company');
31-
$I->seeElement('nav');
32-
$I->dontSeeElement('#error-message');
33-
$I->dontSeeInPageSource('<section class="foo">');
34-
```
28+
```php
29+
$I->see('Welcome');
30+
$I->seeInTitle('My Company');
31+
$I->seeElement('nav');
32+
$I->dontSeeElement('#error-message');
33+
$I->dontSeeInPageSource('<section class="foo">');
34+
```
3535

36-
* **Grabbers** take information. The return value of those are meant to be saved as variables and used later. Example:
36+
* **Grabbers** take information. The return value of those is meant to be saved as a variable and used later. Example:
3737

38-
```php
39-
$method = $I->grabAttributeFrom('#login-form', 'method');
40-
$I->assertEquals('post', $method);
41-
```
38+
```php
39+
$method = $I->grabAttributeFrom('#login-form', 'method');
40+
$I->assertSame('post', $method);
41+
```
4242

4343

4444
## Actors
4545

46-
One of the main concepts of Codeception is representation of tests as actions of a person. We have a "UnitTester", who executes functions and tests the code. We also have a "FunctionalTester", a qualified tester,
46+
One of the main concepts of Codeception is the representation of tests as actions of a person. We have a "UnitTester", who executes functions and tests the code. We also have a "FunctionalTester", a qualified tester,
4747
who tests the application as a whole, with knowledge of its internals. Lastly we have an "AcceptanceTester", a user who works with our application
4848
in a real browser.
4949

50-
Methods of actor classes are generally taken from [Codeception Modules](https://codeception.com/docs/06-ModulesAndHelpers). Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment.
50+
Methods of actor classes are generally taken from [Codeception Modules](https://codeception.com/docs/ModulesAndHelpers). Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment.
5151
Codeception tries to solve 90% of possible testing issues in its modules, so you don't have to reinvent the wheel.
5252
We think that you can spend more time on writing tests and less on writing support code to make those tests run.
53-
By default, AcceptanceTester relies on [PhpBrowser](https://codeception.com/docs/modules/PhpBrowser) module, which is set in the `tests/Acceptance.suite.yml` configuration file:
53+
By default, AcceptanceTester relies on the [PhpBrowser](https://codeception.com/docs/modules/PhpBrowser) module, which is set in the `tests/Acceptance.suite.yml` configuration file:
5454

5555
```yaml
5656
actor: AcceptanceTester
@@ -72,19 +72,18 @@ php vendor/bin/codecept build
7272

7373
## Writing a Sample Test
7474

75-
Codeception has its own testing format called "Cest" ("Codecept" + "Test").
75+
Codeception has its own testing format called "Cest" (a combination of "Codecept" and "Test").
7676
To start writing a test we need to create a new Cest file. We can do that by running the following command:
7777

7878
```bash
7979
php vendor/bin/codecept generate:cest Acceptance Signin
8080
```
8181

8282

83-
This will generate `SigninCest.php` file inside `tests/Acceptance` directory. Let's open it:
83+
This will generate the `SigninCest.php` file inside the `tests/Acceptance` directory. Let's open it:
8484

8585
```php
8686
<?php
87-
8887
namespace Tests\Acceptance;
8988
9089
use Tests\Support\AcceptanceTester;
@@ -102,40 +101,35 @@ class SigninCest
102101
}
103102
```
104103

105-
We have `_before` and `_after` methods to run some common actions before and after a test. And we have a placeholder action `tryToTest` which we need to implement.
106-
If we try to test a signin process it's a good start to test a successful signin. Let's rename this method to `signInSuccessfully`.
107-
108-
We'll assume that we have a 'login' page where we get authenticated by providing a username and password.
109-
Then we are sent to a user page, where we see the text `Hello, %username%`. Let's look at how this scenario is written in Codeception:
104+
We have `_before` and `_after` methods to run some common actions before and after a test. And we have a placeholder method `tryToTest`.
105+
If we want to test a signin process it's a good start to test a successful signin. Let's rename this method to `signInSuccessfully`.
110106

111107
```php
112108
<?php
113-
114109
namespace Tests\Acceptance;
115110
116-
use \Tests\Support\AcceptanceTester;
111+
use Tests\Support\AcceptanceTester;
117112
118113
class SigninCest
119114
{
120-
public function signInSuccessfully(AcceptanceTester $I)
115+
public function signInSuccessfully(AcceptanceTester $I): void
121116
{
122117
$I->amOnPage('/login');
123-
$I->fillField('Username','davert');
124-
$I->fillField('Password','qwerty');
118+
$I->fillField('Username', 'davert');
119+
$I->fillField('Password', 'qwerty');
125120
$I->click('Login');
126121
$I->see('Hello, davert');
127122
}
128123
}
129124
```
130125

131-
132-
This scenario can probably be read by non-technical people. If you just remove all special chars like braces, arrows and `$`,
133-
this test transforms into plain English text:
126+
This scenario can probably be read by everybody, even non-developers. If you just remove all special characters,
127+
this test transforms into plain english text:
134128

135129
```yaml
136130
I amOnPage '/login'
137-
I fillField 'Username','davert'
138-
I fillField 'Password','qwerty'
131+
I fillField 'Username', 'davert'
132+
I fillField 'Password', 'qwerty'
139133
I click 'Login'
140134
I see 'Hello, davert'
141135
```

0 commit comments

Comments
 (0)