Codeception 2.0 is out. It was a long journey to get here but it was worth it.
Main purpose of making Codeception 2.0 was not to break things up. Instead we focused on making Codeception simpler in use and reduce that awkward WTF moments you were experiencing rebuilding Guy classes and discovering dark magic of Maybe
object.
That’s it. Codeception does not have 2-phases of execution and runs your tests as native PHP scenarios. It also does not require you to rebuild actor classes on configuration change - it is done automatically. And at last we don’t have Guys anymore. They were renamed in more neutral Tester
objects. But it is up to you how will you call your actors: Testers, Guys, or even ninjas, those names can be configured!
Naming Conventions
We decided to change some naming conventions in Codeception.
_log
directory was renamed to_output
. It was logical decision, as Codeception does not print any logs by default, but constantly uses_log
directory for printing debug information and reports._helpers
was renamed to_support
. Now it is more obvious that this directory may contain not only helpers but any kind of support code required for tests.
As it was said, Guys were renamed to Testers. Actor classes and helpers are named by suite. For instance, acceptance test will start with this line:
In unit tests we simplified access to actor classes by just using $this->tester
property (actor title). Looks a bit more readable.
If you are upgrading from 1.x you can still use codeGuy
as it was left for compatibility.
Listed naming changes are recommended defaults. You don’t need to follow them if you plan to upgrade from 1.x.
Changes
Let’s briefly name some important changes added in Codeception 2.0
- PHP >= 5.4
- Upgraded to PHPUnit 4.x
- Upgraded to Guzzle 4.x
- Removed Mink (and Selenium, Selenium2, ZombieJS modules)
- Removed Goutte
- Logger moved to extension and disabled by default
- Naming conventions changed
- One-time execution for all tests
- Autorebuild of actor classes
- MultiSession testing with Friends
- Strict Locators introduced
- Fail fast option
-f
added torun
command - Coverage options changed behavior in
run
command - Bootstrap test are loaded suite, not before each test
- Parallel Execution (!!!)
Guides
Guides were reviewed and updated for 2.0 release. Unit Testing guide was completely rewritten, and new chapter Parallel Execution was added. Please note that parallel running tests is advanced feature and will require some time for you for set everything up correctly. But If your tests run longer then 30 minutes, you will get a real benefit out of it.
The Most Important Bug Fixed
The Most Important Bug was reported by many of our users:
@codeception Nice website footer: © 2011 - <?php date('Y') ?>
You should create a test for that ;-)
— Bret R. Zaun (@bretrzaun) November 15, 2013
Hey, @codeception you have unparsed PHP in your footer.
— Phil Kershaw (@PhilKershaw) April 10, 2014
Oh @codeception !!!!!! Should _really_ fix this. lol. <3<3<3 pic.twitter.com/Wi3szPMKMN
— Darren Nolan (@DarrenNolan_) May 23, 2014
We decided to fix it for 2.0 release. Now the date in footer is displayed correctly according to PHP rules (using <?=
).
Upgrading
Codeception 2.0 was publishing pre-releases since February. Lots of developers already gave it a try and reported their issues. We hope the upgrade will go smoothly for you. Basically what you need is to:
- run
build
command - remove any internal usage of Mink or Goutte
- remove any usage of
$scenario->prepare()
as it always return false now - optionally remove
$scenario->running()
calls and$I->execute
calls. They are not required anymore. - take a look into PhpBrowser module which is uses Guzzle4 directly. You may have issues with using it (as it was completely rewritten). Please report those issues to GitHub.
- Selenium2 module should be replaced with WebDriver (as you already didn’t do so).
- if you use variables in
_bootstrap.php
, rename it to_fixtures.php
and load it manually into your tests.
If you have issues during upgrade send issues to GitHub and we will make upgrade more smoother.
Via Composer:
P.S. Codeception 1.8.6 was released as well. List of its changes will go tomorrow.