Sunday, November 2, 2014

Creation Of Cest

Ever wanted a structure as classes for your Cepts!
Then Cest format should be your choice.
The biggest advantage is that it is very simple and compatibility with Cept scenarios.
So if your script/test is bit lengthy and you need to split it then you can approach the cest approach.

Just create a new cest file by running the command in console as :
$ php codecept.phar generate:cest suitename CestName

The generated file will look like this:

<?php
class Mytest
{
    public function _before(\AcceptanceTester $I)
    {
    }

    public function _after(\AcceptanceTester $I)
    {
    }

    // tests
    public function actualtest(\AcceptanceTester $I)
    {  
    }
}
?>

Here in the above file the _before and _after annotations are used for the setup and flow of test execution.
So _before will prepare the test set up before the test execution.
And _after will prepare the generation of falied reports,generation of reports etc.

We will pass the actor objects to actualtest method.

<?php
class Mytest
{
    // test
    public function myLogin(\AcceptanceTester $I)
    {
        $I->wantTo('log in to site');
        $I->amOnPage('/');
        $I->click('Login');
        $I->fillField('username', 'test');
        $I->fillField('password', 'password');
        $I->click('Login');
        $I->see('Home');
        $I->seeInCurrentUrl('/home');
    }
}
?>

Related Posts:

  • 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
  • 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
  • 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
  • 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

0 comments:

Post a Comment

Powered by Blogger.