Codeception installation

Updated 27 November 2017

Facebook Linkedin

Before installation of Codeception, we have to understand about WebDriver. As we know a nice feature of Codeception is that most scenarios are similar like if we make our scenarios in Acceptance or Functional or Unit test in any test base our look of scenarios is similar.

So here in this section, a WebDriver we used that is Selenium WebDriver and it used to drive our browser automatically,  its main feature is that our scenarios are Run by web driver automatically, so first download Selenium standalone server.

To execute a test in a browser we need to change the suit configuration to WebDriver instead of the browser now we talk about what is suit configuration?

As we know that Codeception consists of three so-called “suites” that means collection like a “Unit suite” for all Unit tests, a “Functional suite” for all Functional tests, and an “Acceptance suite” for all Acceptance tests.

We have to generate suit configuration inside a directory and each suit configuration name like configuration name.suit.yml it allows us to enable or configure to any modules, for Acceptance it is like acceptance.suite.yml and for Functional, it is functional.suite.yml.

Below we explain about a configuration of acceptance.suit.yml:

# Codeception test Suite Configuration for acceptance.suit.yml.
# Suite for acceptance tests.
# Emulate web requests and make application to process them.
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
# Remove this suite if you don’t use frameworks.

Run Commands in Your Terminal for acceptance.suite.yml file creation :

By Run This command on Terminal  Acceptance.suit.yml file generated and inside that These details which i mentioned below is already present:

actor: acceptance Tester modules:

enabled: – WebDriver:

url : https://creative.uvdesk.com/en

browser: chrome – \Helper\Functional

here we use WebDriver, we can also perform our test by PHP browser but it does not require running in the actual browser. so we use WebDriver to run our Web application automatically.

Here we used Term actor that means all actions are performed by an actor in above case actor is acceptance tester so the test is performed by acceptance tester and all actions that can be performed in a class called Modules and we create above suit configuration in a directory by name acceptance.suite.yml.

Here by default, our configuration uses PHP browser and others browsers can be used as well we covered that part later. But Installation of Codeception by configuring of our suite URL and currently Codeception install WebDriver.
Add this to the list of enabled extensions in codeception.yml or acceptance.suite.yml:

This creates configuration file Codeception.yml inside tests directory and by default test suite, Acceptance, functional, unit test suites are created as well.

Now to start our testing in Codeception First configure the suite you want to use:

Thus in this configuration, we are Running Our test cases by WebDriver and then set the URL in which we are Performing our test, open acceptance.suit.yml in any Text editor(Netbeans, Notepad etc.) and change the URL line to contain your desired site. (e.g.: url: ‘http://creative.uvdesk.com’).

Generate a new Test file:

Since we’re using the acceptance suite, here’s what you have to do to create a new test file, type “php codecept.phar generate:cest acceptance testname” in cmd, in the folder where you saved the .phar. This is where you will run all of the Codeception commands.

There are plenty of useful Codeception commands:

generate:Cept suite filename – Generates a sample Cept scenario
generate:Cest suite filename – Generates a sample Cest test

Generate your acceptance test by running of commands like codecept generate: Cest acceptance test.

Now we have to know about Cest file and in this section only Cest file is used, so what is Cest File and why we use it.

So basically a Cest file is in which we group a few testing scenarios into one, and in this Cest File is run by webDriver and all the test scenarios are run inside that Cest File.
and on URL you put https://creative.uvdesk.com/en


Tests are executed with ‘Run’ command like php codecept.phar run acceptance FilenameCest.php –steps.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.