Tag Archives: PHP testing

What is Codeception?
Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides you an absolutely new way of writing acceptance, functional and even unit tests. Powered by PHPUnit.

Now its time to open terminal console and generate Test Cases. Here are the steps to integrate:

  1. Download Codeception
  2. Generate BootStrap files
  3. Write a Test Case for Register Api
  4. Build and Run
  5. Screenshots

1. Download and Install Codeception

Create a folder for TestCases generator. Name it as PhpTestGen.
Download composer.phar file from Composer Project.

Create a new file composer.json with below contents.

2. Generate BootStrap files

CodeCeption has a boostrap process which helps in generating basic structure for test cases.

After successfully running about command you should have below folder structure.

<img class="alignnone size-full wp-image-1805" src="http://blog.nbostech.com/wp-content/uploads/2016/01/Screen-Shot-2016-01-20-at-2.39.46-PM.png" alt="Screen Shot 2016-01-20 at 2.39.46 PM" width="766" height="410" srcset="http://blog.nbostech.com/wp-content/uploads/2016/01/Screen-Shot-2016-01-20-at-2.39.46-PM.png 766w, http://blog.nbostech.com/wp-content/uploads/2016/01/Screen-Shot-2016-01-20-at-2.39.46-PM-300×161.png 300w, http://blog.nbostech viagra prix qu.com/wp-content/uploads/2016/01/Screen-Shot-2016-01-20-at-2.39.46-PM-624×334.png 624w” sizes=”(max-width: 766px) 100vw, 766px” />

From the above screenshot we can see that Acceptance, api, functional and unit are the suites which has its respective yml file.

YML file is the configuration for each testcase we are going to write in future.

3. Write a Test Case for Register Api

Modify a yml file of API suite with below changes

And make changes in RegisterCest.php with this lines


4. Build and Run

There are several ways to execute bunch of tests. You can run tests from specific directory:

5. ScreenShots for success and failure

Screen Shot 2016-01-20 at 2.58.24 PM

Run the same test again, since user is already registered it will fail.Screen Shot 2016-01-20 at 2.59.44 PM