Sunday, October 19, 2014

Codeception Modules

In Codception various modules are comes as packages initially.
Some of them are Webdriver,symphony,Laravel etc.
Modules allow you to choose the actions and assertions that can be performed in tests.
All actions and assertions that can be performed by the Tester object in a class are defined in modules.

So you might be thinking that you are limited with the modules coming with Codeception installation.
But that's not true.
You can create custom modules by your own and use them in your tests.


So lets see at the below example:


<?php
$I = AcceptanceTester($scenario);
$I->amOnPage('/');
$I->see('Home');
$I->seeInDatabase('customers', array('id' => 1));
$I->seeFileFound('locked');
?>



So you can see the above script actually using different modules to wor,.

1. It uses PhpBrowser to load the web page.
2. It uses Db to see into the database.
3. It uses Filesystem to check the status of the file.


Modules are attached to Actor classes in the suite config.

In tests/acceptance.suite.yml we can see

class_name: AcceptanceTester
modules:
    enabled: [PhpBrowser, Db, Filesystem]


Generally Codeception is bundled with many modules as a package.
These are called stendard modules.
Some of the standard modules are Webdriver,symphony,Laravel etc.

0 comments:

Post a Comment

Powered by Blogger.