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.

Related Posts:

  • Codeception:At once how to run tests with WebDriver and PHPBrowser we can  run tests with webdriver and PHPBrowser at once by setting the environment.   The configurations can be achieved by modifying acceptance suite.ymlThe configuration can be defined as follows:class_name: A… Read More
  • 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 assertion… Read More
  • Codeception Helpers Codeception has always the flexibilty to add the add the custom actions to the test suite. It just doesn't restrict to add custom actions. 'bootstrap' is the command to that codeception generates these modules. These modules… Read More
  • Codeception:Variables for UI Elements As we know we can write complex tests using codeception.Think of a scenario of a login page. We have generally 3 fields in login page. 1.User id fiels 2.Password field 3.Sign in button. We have created a test using codecep… Read More
  • Repopulation of database using mysql instead of db module What is DB module: The DB module is used to cleaning database before each test. So this module was added into codeception.yml. To have your database properly cleaned you should configure it to access the database. Also pro… Read More

0 comments:

Post a Comment

Powered by Blogger.