Test automation with php codeception

14
Test automation with PHP Codeception By Buddhi Eashwarage

Transcript of Test automation with php codeception

Page 1: Test automation with php codeception

Test automation with PHP CodeceptionBy Buddhi Eashwarage

Page 2: Test automation with php codeception

What is Test automation• Test automation means testing some application or software

by using another software tool or software framework to compare actual outcomes with predicted outcomes.

• Or simply we can say, it is a process different from manual testing

Page 3: Test automation with php codeception

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.

Page 4: Test automation with php codeception

What is the application which we are going to test• We are going to test Joomla with Codeception.

• At the moment latest Joomla release is Joomla 3.4.1

• Joomla is a CMS built with PHP.

Page 5: Test automation with php codeception

How to install Codeception• Codeception allows two methods to install it. Those are ‘Phar’

and ‘Composer’ methods.

• I prefer to do the installation using Codeceptions’ Phar file.

• Phar is a php file type which allows to compress several php files into a single php file. But user doesn’t need to extract it to local drive to install it. By simply executing several commands can install Codeception framework into application being tested.

• My system specifications: Windows, XAMPP

Page 6: Test automation with php codeception
Page 7: Test automation with php codeception

• Once downloaded the Phar file, paste it to your website root folder.

• In my case i’m using XAMPP. So my Phar file will go to ‘C:\xampp\htdocs\Joomla\codecept.phar’

• Then open up your command line tool and I assume you have already installed php into your system. You can check it by simply entering ‘php -v’.

• If it shows your php version there then you have installed php already.

Page 8: Test automation with php codeception

PHP version

Page 9: Test automation with php codeception

• Then navigate inside to your website root folder.

• Now let’s install Codeception.

• Type following commands in command line tool.• ‘php codecept.phar bootstrap’

• This command creates codeception.yml file and tests directory.

• Tests directory contains all the test scripts.

• Basically codeception has three types of testings. Such as acceptance,functional and unit testings.

Page 10: Test automation with php codeception

Acceptance Test• Now we are going to crate our first acceptance test in

Codeception.

• Run following command in command line tool.

Page 11: Test automation with php codeception

• This will creates BackendloginCept.php file inside acceptance tests directory.

• Following is Joomla backend. We’re going to automate the login process.

Page 12: Test automation with php codeception

• First open following file to add the base url.

• Add your websites’ base url there.

Page 13: Test automation with php codeception

• Add following lines to your acceptance test script.

Page 14: Test automation with php codeception

• Finally you have to run the test script. For that type following command in command line tool.

• ‘php codecept.phar run’

• You can see the output on your command line. If you have done it correctly it should pass all the tests and assertions successfully!!!

• Thank You