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
Copy file name to clipboardExpand all lines: _posts/2022-07-28-codeception-5.markdown
+24-26Lines changed: 24 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,25 @@ Codeception 5.0 is out!
8
8
9
9
This release is **PHP 8+** only, so we are back on track with modern PHP. We are **dropping support for PHPUnit < 9**, and are technically ready for PHPUnit 10. And we also support **Symfony 6** without dropping support of previous Symfony versions. As always, we did our best to keep backward compatibility so if you can update your dependencies, all tests should be working for you.
10
10
11
-
So let's take a look at new features:
11
+
So let's take a look at some new features:
12
12
13
13
## New Directory Structure
14
14
15
-
Codeception 5 will match PSR-12 standard. So all tests and classes will have their own namespace `Tests`. The directory structure was updated accordingly:
15
+
Codeception 5 will follow the [PSR-12 coding standard](https://www.php-fig.org/psr/psr-12/). So all tests and classes will have their own namespace `Tests`. The directory structure was updated accordingly:
16
16
17
17
```
18
18
tests/
19
19
_output
20
20
Acceptance
21
21
Functional
22
22
Support/
23
-
Data/
24
23
_generated/
24
+
Data/
25
25
Helper/
26
26
Unit/
27
27
```
28
28
29
-
All suite name will have their own namespace, as well as actor and helper classes:
29
+
All suite names will have their own namespace, as well as actor and helper classes:
30
30
31
31
```php
32
32
<?php
@@ -44,13 +44,13 @@ class LoginCest
44
44
}
45
45
```
46
46
47
-
New directory structure will be generated by running `codecept bootstrap`. The directory structure is set with a new default config, so the previous directory structure is still valid.
47
+
This new directory structure will be generated by running `codecept bootstrap`. The directory structure is set with a new default config, so the previous directory structure is still valid.
48
48
49
49
## Attributes
50
50
51
-
Annotations were an essential part of Codeception testing framework. Even though they were not native language constructs, they proved to be quite good to separate a test from its metadata. We believe that test should not include code that doesn't belong to the test scenario.
51
+
Annotations were an essential part of the Codeception testing framework. Even though they were not native language constructs, they proved to be quite good to separate a test from its metadata. We believe that test should not include code that doesn't belong to the test scenario.
52
52
53
-
So we were glad that native Attributes have landed PHP world. In this release we encourage our users to start using them:
53
+
So we were glad that native attributes have landed in the PHP world. In this release we encourage you to start using them:
54
54
55
55
```php
56
56
#[Group('important')]
@@ -69,13 +69,13 @@ public function testApiRequests(ApiTester $I, Example $e)
69
69
}
70
70
```
71
71
72
-
As you see, attributes decouple all preparation steps, keeping the test scenario minimal. We also keep supporting annotations, so an urgent upgrade is not needed. Attributes can't do something that traditional annotations can't, they are just a modern alternative.
72
+
As you see, attributes decouple all preparation steps, keeping the test scenario minimal. We also keep supporting annotations, so an urgent upgrade is not needed. Attributes can't do anything that traditional annotations can't, they are just a modern alternative.
73
73
74
-
List of available attributes (all under `Codeception\Attribute`) namespace:
74
+
List of available attributes (all under `Codeception\Attribute` namespace):
75
75
76
-
*`Before` - specifies the method that should be executed before each test
77
-
*`After` - specifies the method that should be executed after each test
78
-
*`Group` - set the group for the test
76
+
*`Before` - specifies a method that should be executed before each test
77
+
*`After` - specifies a method that should be executed after each test
78
+
*`Group` - sets the group for the test
79
79
*`Skip` - skips the current test
80
80
*`Incomplete` - marks test as incomplete
81
81
*`Depends` - sets the test that must be executed before the current one
@@ -87,9 +87,9 @@ List of available attributes (all under `Codeception\Attribute`) namespace:
87
87
88
88
## Debugging
89
89
90
-
Do you remember, `Hoa\Console`? Unfortunately, this library was deprecated and we were looking for a modern alternative that could power `codecept console` and `$I->pause();` commands. We switched to [PsySH](https://psysh.org) a PHP REPL.
90
+
Do you remember, `Hoa\Console`? Unfortunately, this library was deprecated and we were looking for a modern alternative that could power `codecept console` and `$I->pause();`. We switched to [PsySH](https://psysh.org), a PHP Read-Eval-Print Loop.
91
91
92
-
An interactive console is used to pause a test in the given state. While in pause you can try different Codeception commands, and check variable values. Instead of fixing tests blindly, you can start an interactive session. This is quite a similar effect you can get with a real debugger like XDebug but focused on Codeception commands. Especially this is helpful to write acceptance tests as the test scenario can be planned while executing a test. So basic scenario can be written as:
92
+
An interactive console is used to pause a test in the given state. While in pause you can try different Codeception commands, and check variable values. Instead of fixing tests blindly, you can start an interactive session. This is quite a similar effect you can get with a real debugger like XDebug but focused on Codeception commands. This is especially helpful for acceptance tests as the test scenario can be planned while executing a test. So the basic scenario can be written as:
93
93
94
94
```php
95
95
$I->amOnPage('/');
@@ -101,15 +101,15 @@ After opening a page you will be able to try commands in a browser. If a command
101
101
Also new functions were added:
102
102
103
103
*`codecept_pause()` - starts interactive pause anywhere in debug mode
104
-
*`codecept_debug()` - prints a variable into console using Symfony VarDumper
104
+
*`codecept_debug()` - prints a variable to console using Symfony VarDumper
105
105
106
106
## Sharding
107
107
108
-
[Parallel Execution](/docs/ParallelExecution) guide has been rewritten and focused on a new feature: sharding. It is the simplest way to run slow tests (think of acceptance tests first) in parallel on multiple agents.
108
+
The [Parallel Execution guide](/docs/ParallelExecution) has been rewritten and focused on a new feature: sharding. It is the simplest way to run slow tests (think of acceptance tests first) in parallel on multiple agents.
109
109
110
110
In this case, you specify the batch of tests that should be executed independently and each job picks up its own not intersecting group of tests to run them.
111
111
112
-
```
112
+
```bash
113
113
# first job
114
114
./vendor/bin/codecept run --shard 1/3
115
115
@@ -122,13 +122,13 @@ In this case, you specify the batch of tests that should be executed independent
122
122
123
123
This feature reduces the need for complex configuration and usage of `robo` task runner to split tests.
124
124
125
-
It is recommended to use sharding to parallelize tests between multiple jobs as the simplest approach. Unfortunately, PHP doesn't have native multi-threading for test parallelization, and even if it had, it doesn't solve the problem of running slow browser tests that interacts with a whole application. So only horizontal scaling by jobs can be suggested as a long-running approach. The more build agents you add to your Continuous Integration server, the fastest tests will run. That's it!
125
+
It is recommended to use sharding to parallelize tests between multiple jobs as the simplest approach. Unfortunately, PHP doesn't have native multi-threading for test parallelization, and even if it had, it doesn't solve the problem of running slow browser tests that are interacting with the entire application. So only horizontal scaling by jobs can be suggested as a long-running approach. The more build agents you add to your Continuous Integration server, the faster tests will run. That's it!
126
126
127
127
## Grep and Filter
128
128
129
129
New options `--grep` and `--filter` were introduced to select tests by part of their name. Actually, it is the same option and an alias. `--grep` is a common way to select tests to execute in NodeJS test runners, so we ported it to Codeception. But as usual, specific tests can also be executed by group or specifying a test signature.
130
130
131
-
```
131
+
```bash
132
132
./vendor/bin/codecept run --grep "user"
133
133
```
134
134
@@ -143,13 +143,13 @@ Please go through the list of changes introduced to see if they don't affect you
143
143
* Throw exception if actor setting is missing in suite configuration
144
144
* Removed `generate:cept` command (Cept format is deprecated)
145
145
* Removed settings `disallow_test_output` and `log_incomplete_skipped`.
146
-
* Removed setting `paths.log` (it was replaced by `paths.output` in Codeception 2.3)
146
+
* Removed setting `paths.log` (replaced by `paths.output` in Codeception 2.3)
147
147
* Removed suite setting `class_name` (replaced by `actor` in Codeception 2.3)
148
148
* Removed global setting `actor` (replaced by `actor_prefix` in Codeception 2.3)
149
149
* Removed `Configuration::logDir` method (replaced by `Configuration::outputDir` in 2.0)
150
-
* Moved XmlBuilder class to module-soap
150
+
* Moved `XmlBuilder` class to SOAP module
151
151
* Decoupled test execution and reporting from PHPUnit
152
-
* Custom reporters implementing TestListener are no longer supported and must be converted to Extensions
152
+
* Custom reporters implementing `TestListener` are no longer supported and must be converted to Extensions
153
153
* Added optional value to `fail-fast` option (#6275) by #Verest
154
154
* Removed `JSON` and `TAP` loggers
155
155
* Removed code coverage blacklist functionality
@@ -164,9 +164,7 @@ Please go through the list of changes introduced to see if they don't affect you
164
164
165
165
---
166
166
167
-
We really happy that we are finally here with Codeception 5. This release was crafted during wartime, which happens in Ukraine. It is mentally and morally hard to work on tech products knowing that at any point this peaceful virtual life can end at any moment by a random missile. Codeception was created in 2011 by Michael Bodnarchuk in Kyiv, and today in 2022 he also stays there writing this post. If you want to support Codeception, all the Ukrainian PHP community, and all our brave nation who stands for democracy against barbaric Russian invasion, consider **[donating to Ukrainian charities](https://stand-with-ukraine.pp.ua)**. Not a single time. Every month until the war ends. Every time you travel or enjoy tasty food in a restaurant think of people who are forced to defend their land, or who fled their homes. Glory to Ukraine!
167
+
We are really happy that we are finally here with Codeception 5. This release was crafted during the war that happens in Ukraine. It is mentally and morally hard to work on tech products knowing that this peaceful virtual life can end at any moment by a random missile. Codeception was created in 2011 by [Michael Bodnarchuk](https://github.com/DavertMik) in Kyiv, and today in 2022 he also stays there writing this post. If you want to support Codeception, all the Ukrainian PHP community, and all our brave nation who stands for democracy against this barbaric Russian invasion, consider **[donating to Ukrainian charities](https://stand-with-ukraine.pp.ua)**. Not a single time. Every month until the war ends. Every time you travel or enjoy tasty food in a restaurant think of people who are forced to defend their land, or who fled their homes. Glory to Ukraine!
168
168
169
169
This release wouldn't be possible without the hard work of [Gintautas Miselis](https://github.com/Naktibalda) who keeps constant work on modernizing internals and keeping Codeception up to date. Also we are really thankful to [Gustavo Nieves
170
-
](https://github.com/TavoNiievez) who did a lot of work transitioning Codeception to new Symfony and more! Thanks to our maintainers! If you want to support our work we have [OpenCollective](https://opencollective.com/codeception)!
171
-
172
-
170
+
](https://github.com/TavoNiievez) who did a lot of work transitioning Codeception to Symfony 6 and more! Thanks to our maintainers! If you want to support our work we have [OpenCollective](https://opencollective.com/codeception)!
0 commit comments