composer require "codeception/codeception" --dev
Execute:
php vendor/bin/codecept bootstrap
This creates configuration file codeception.yml and tests directory and default test suites.
See DemoGenerate your first acceptance test. Acceptance tests emulate behavior of a real user visiting your site.
php vendor/bin/codecept generate:cest Acceptance First
Please make sure your local development server is running. Put application URL into: tests/Acceptance.suite.yml
actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: {YOUR APP'S URL}
It's now time to write your first test. Edit the file we've just created tests/Acceptance/FirstCest.php
<?php
class FirstCest
{
public function frontpageWorks(AcceptanceTester $I)
{
$I->amOnPage('/');
$I->see('Home');
}
}
It will check if your frontpage contains the word Home.
Tests are executed with 'run' command
php vendor/bin/codecept run --steps
This will execute our test with PhpBrowser. It's PHP script that can check HTML page contents, click links, fill forms, and submit POST and GET requests. For tests that require a real browser (e.g. JavaScript) use the WebDriver module.
Use predefined installation templates for common use cases.
Run them instead of bootstrap
command.
php vendor/bin/codecept init Acceptance
php vendor/bin/codecept init Api
php vendor/bin/codecept init Unit
Read Codeception Guides to learn how to use it.