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
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,
47
47
who tests the application as a whole, with knowledge of its internals. Lastly we have an "AcceptanceTester", a user who works with our application
48
48
in a real browser.
49
49
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.
51
51
Codeception tries to solve 90% of possible testing issues in its modules, so you don't have to reinvent the wheel.
52
52
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:
54
54
55
55
```yaml
56
56
actor: AcceptanceTester
@@ -72,19 +72,18 @@ php vendor/bin/codecept build
72
72
73
73
## Writing a Sample Test
74
74
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").
76
76
To start writing a test we need to create a new Cest file. We can do that by running the following command:
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:
84
84
85
85
```php
86
86
<?php
87
-
88
87
namespace Tests\Acceptance;
89
88
90
89
use Tests\Support\AcceptanceTester;
@@ -102,40 +101,35 @@ class SigninCest
102
101
}
103
102
```
104
103
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`.
110
106
111
107
```php
112
108
<?php
113
-
114
109
namespace Tests\Acceptance;
115
110
116
-
use \Tests\Support\AcceptanceTester;
111
+
use Tests\Support\AcceptanceTester;
117
112
118
113
class SigninCest
119
114
{
120
-
public function signInSuccessfully(AcceptanceTester $I)
115
+
public function signInSuccessfully(AcceptanceTester $I): void
121
116
{
122
117
$I->amOnPage('/login');
123
-
$I->fillField('Username','davert');
124
-
$I->fillField('Password','qwerty');
118
+
$I->fillField('Username','davert');
119
+
$I->fillField('Password','qwerty');
125
120
$I->click('Login');
126
121
$I->see('Hello, davert');
127
122
}
128
123
}
129
124
```
130
125
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,
0 commit comments