6K Views

Get started with codeception

Updated 27 October 2017

Facebook Linkedin

In the previous blog by default, we created 3 suites Acceptance, Functional, and Unit.

So before creating suit configuration, we have to generate bootstrap commands. we generate bootstrap commands, because each suite has its own bootstrap file, It’s located in the suite directory and is named _bootstrap.php and It will be executed before each test.

let’s take a look at Codeception architecture. We assume that you already installed Codeception and bootstrapped your first three test suites. As in previous part, Codeception generated three of them: Unit, Functional, and Acceptance. They are well described in previous part and as in your tests folder, you have three config. files and three directories with a name corresponding to their suites like acceptance.suite.yml for Acceptance and for Functional it is functional.suite.yml and for Unit , it is unit.suite.yml.

Writing a Sample Scenario for sign in support UVdesk panel and then after sign in testing on Mailbox Panel.
By default we write our test in narrative scenarios and to make PHP file a valid scenario, its name should have a Cest suffix.

Lets say we created tests/acceptance/SigninCest.php.

We can do that by running the command:

A Scenario always starts with class initialization. After that, writing a scenario with typing $I->

We have to define a class inside of which we are writing our scenarios, class name should be same as file name like if we are testing on the sign in support UVdesk section and our file name is SigninCest.php then our class is the Sign in likewise,

As we know that all actions are performed by tester object ie. SigninTest inside a class which is Signin are defined in modules.

Above command create new Cest file with name SigninCest inside acceptance directory.

The generated file will look like this:

In a _before and _after method, you can use common setups and teardowns for the tests in the class. This actually makes Cest tests more flexible than Cepts, which rely only on similar methods in Helper classes.

We assume that we have a login page, where we get authenticated by providing username and password. Then after login, we sent a user page where we have mailbox panel and we click on the mailbox and then we add new mailbox with mailbox name and mailbox email id and then a new mailbox added in our UVdesk mailbox panel.

Let’s look at how this scenario is written in Codeception:

This scenario can probably be read by non-technical people. If you just remove all special chars like braces, arrows and $, this test transforms into plain English text:

Before we execute this test, we should make sure that the website is running on a local web server. Let’s open the tests/acceptance.suite.yml file and replace the URL with the URL of your web application like we are performing a test on http://support.uvdesk.com

Category(s) Codeception
. . .

Leave a Comment

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


Be the first to comment.