Skip to content

Commit d407b9d

Browse files
authored
Merge pull request #638 from ThomasLandauer/patch-3
Adding upgrading instructions
2 parents 32f99a4 + 412c1d6 commit d407b9d

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

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

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tests/
2626
Unit/
2727
```
2828

29-
All suite names will have their own namespace, as well as actor and helper classes:
29+
All suite names have their own namespace, as well as actor and helper classes:
3030

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

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.
47+
This new directory structure will be generated by running `codecept bootstrap`.
48+
49+
### Upgrading from Codeception 4
50+
51+
Codeception 5 is compatible with the Codeception 4 directory structure. So if you don't want to change your file locations now, just keep your existing `codeception.yml`, and everything's fine.
52+
53+
However, if you want to upgrade to the new Codeception 5 directory structure (recommended), here's the new default `codeception.yml`:
54+
55+
```yaml
56+
namespace: Tests
57+
support_namespace: Support
58+
paths:
59+
tests: tests
60+
output: tests/_output
61+
data: tests/Support/Data
62+
support: tests/Support
63+
envs: tests/_envs
64+
actor_suffix: Tester
65+
extensions:
66+
enabled:
67+
- Codeception\Extension\RunFailed
68+
```
69+
70+
Next steps:
71+
72+
1. Rename your suite configuration files:
73+
`acceptance.suite.yml` => `Acceptance.suite.yml`
74+
`functional.suite.yml` => `Functional.suite.yml`
75+
`unit.suite.yml` => `Unit.suite.yml`
76+
2. Inside those configuration files, update to the new namespace:
77+
```yaml
78+
modules:
79+
enabled:
80+
- Tests\Support\Helper\Unit
81+
```
82+
3. In your `composer.json`, update to the new namespace:
83+
```json
84+
"autoload-dev": {
85+
"psr-4": {
86+
"Tests\\": "tests/"
87+
}
88+
},
89+
```
90+
4. In your `tests/Support/Acceptance|Functional|UnitTester.php` files, update to the new namespace.
91+
5. Run `vendor/bin/codecept build` to create the files in `tests/Support/_generated`.
92+
6. Modify the namespaces in all your test/cest files.
93+
7. Run the tests with capitalized suite names: `vendor/bin/codecept run Unit`
4894

4995
## Attributes
5096

@@ -103,6 +149,10 @@ Also new functions were added:
103149
* `codecept_pause()` - starts interactive pause anywhere in debug mode
104150
* `codecept_debug()` - prints a variable to console using Symfony VarDumper
105151

152+
### Upgrading from Codeception 4
153+
154+
Just remove `hoa/console` from your `composer.json`.
155+
106156
## Sharding
107157

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

0 commit comments

Comments
 (0)