Finally we are ready to show you Codeception 2.0. We tried not to break everything (as it was supposed for major version change), but keep things work as they are, but maybe in a different way. Let’s review the most important changes:
Codeception: Not Just For Guys
Before 2.0 there were only Guys in it. That is not fair! We wanted to make Codeception a tool for everyone: for guys, girls, developers, test engineers, ninjas and even wookiees… (nope, wookiees should wait for 3.0).
That’s why you can now choose the desired actor from a list during the
Before proceed you can choose default actor: $I = new [ACTOR] Select an actor. Default: Guy  Guy  Girl  Person  Engineer  Ninja  Dev
so you all your test actors (that’s how we call guy classes now) will be in form like
CodeDev, etc. Pretty flexible.
Codeception: Not Alone
Before Codeception 2.0 guys (or should we say actors now) were left to themselves. You know, it is so sad to see that there is only
$I in the test, forever alone, like on a desert island, or in space… But in 2.0 you can invite some friends into your tests. Let’s say…
So we can write multi-session tests that can be executed in two browser windows.
You may try to run this test on
github.com to see how it works:
As you see, everything in
does closure is executed in separate session. This way you can test user-to-user interactions on your site. For example Alice writes a private message to Bob and Bob responds back. Similarly you can have multiple REST sessions in a test.
Such scenario cases can be implemented. That’s what friends are for.
As it was announced earlier, the main goals for Codeception 2.0 was internal refactoring.
- Mink (and its drivers) was removed completely. Instead you can use WebDriver module to do Selenium testing, and PhpBrowser (which uses Goutte) for browser-emulation. PhpBrowser module is now more compatible with frameworks modules, they use the same methods and acts in the same manner. If you were using
Selenium2module you should switch to WebDriver, for PHPBrowser everything should (crossing fingers) work smoothly.
- 2-phases test execution with tricky magic including usage of
Maybeclass was removed. Tests are now executed one time, like any regular PHP file. So you can use any PHP code in your tests, and appearance of Maybe object would not confuse you anymore.
- Codeception 2.0 require PHP 5.4 and higher. Time changes, PHP 5.3 is getting harder and harder to support, thus we decided to move to 5.4 and keep our code base up to date. And yes, we wanted to use short array syntax. We are tired to keeping write all those nasty
- Actor classes (initial Guy classes) are now rebuilt automatically. Thus, you want get exception when change suite configuration, or add methods to helper. Rebuilds are not required anymore.
- Added Assert module that can be used to write common asserts in your tests. You can now use
seeContainsand other actions inside your Cepts or Cests.
- Experimental: added Silex module. We need your Feedback on using it.
Minor Internal Changes
Refactoring, Refactoring, Refactoring. We use PSR-2 now. We rewrote CodeCoverage. We have better directory structure… More new files. What else? Oh, lets admit it, these are not the changes you would actually notice. But internals are now more clean and easy to understand (Except the parts which heavily rely on PHPUnit).
We’d like to ask you to try Codeception 2.0 on your projects. Before the release is ready we need to collect feedback and fix all encountered issues. You know where GitHub issues are.
Development of 2.0 now happens in
master branch, so keep track on changes and send your pull requests.
Some Upgrading Notes
- Replace Selenium2 to WebDriver module
- Check you don’t use
PHPBrowser->sessionproperty anywhere (it was Mink part)
- CodeCoverage with c3 will require new version of c3.
We need your feedback, and meanwhile we will work on updating documentation parts. 1.8.x will be maintained, but new features will be added to 2.x branch.