Skip to content

Commit 3fabde1

Browse files
authored
Merge pull request #636 from ThomasLandauer/patch-1
Minor language improvements
2 parents b17bc6a + 53606ff commit 3fabde1

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

_posts/2022-07-28-codeception-5.markdown

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ Codeception 5.0 is out!
88

99
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.
1010

11-
So let's take a look at new features:
11+
So let's take a look at some new features:
1212

1313
## New Directory Structure
1414

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:
1616

1717
```
1818
tests/
1919
_output
2020
Acceptance
2121
Functional
2222
Support/
23-
Data/
2423
_generated/
24+
Data/
2525
Helper/
2626
Unit/
2727
```
2828

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:
3030

3131
```php
3232
<?php
@@ -44,13 +44,13 @@ class LoginCest
4444
}
4545
```
4646

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.
4848

4949
## Attributes
5050

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.
5252

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:
5454

5555
```php
5656
#[Group('important')]
@@ -69,13 +69,13 @@ public function testApiRequests(ApiTester $I, Example $e)
6969
}
7070
```
7171

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.
7373

74-
List of available attributes (all under `Codeception\Attribute`) namespace:
74+
List of available attributes (all under `Codeception\Attribute` namespace):
7575

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
7979
* `Skip` - skips the current test
8080
* `Incomplete` - marks test as incomplete
8181
* `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:
8787

8888
## Debugging
8989

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.
9191

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:
9393

9494
```php
9595
$I->amOnPage('/');
@@ -101,15 +101,15 @@ After opening a page you will be able to try commands in a browser. If a command
101101
Also new functions were added:
102102

103103
* `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
105105

106106
## Sharding
107107

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.
109109

110110
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.
111111

112-
```
112+
```bash
113113
# first job
114114
./vendor/bin/codecept run --shard 1/3
115115

@@ -122,13 +122,13 @@ In this case, you specify the batch of tests that should be executed independent
122122

123123
This feature reduces the need for complex configuration and usage of `robo` task runner to split tests.
124124

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!
126126

127127
## Grep and Filter
128128

129129
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.
130130

131-
```
131+
```bash
132132
./vendor/bin/codecept run --grep "user"
133133
```
134134

@@ -143,13 +143,13 @@ Please go through the list of changes introduced to see if they don't affect you
143143
* Throw exception if actor setting is missing in suite configuration
144144
* Removed `generate:cept` command (Cept format is deprecated)
145145
* 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)
147147
* Removed suite setting `class_name` (replaced by `actor` in Codeception 2.3)
148148
* Removed global setting `actor` (replaced by `actor_prefix` in Codeception 2.3)
149149
* 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
151151
* 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
153153
* Added optional value to `fail-fast` option (#6275) by #Verest
154154
* Removed `JSON` and `TAP` loggers
155155
* 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
164164

165165
---
166166

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!
168168

169169
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

Comments
 (0)