Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Younes Rafie:
Using Selenium with PHPUnit
Jul 30, 2015 @ 09:51:20

In this tutorial posted to the SitePoint PHP blog Younes Rafie shows you how to combine Selenium with PHPUnit to do acceptance testing on your application. Where PHPUnit and unit testing is more about testing the "pieces" of your application, acceptance testing it more about checking the interface and functionality for correctness according to requirements.

Testing is a really wide subject, whether it be unit testing, functional testing, acceptance testing, etc. In this article, we’re going to see how you can do acceptance testing using Selenium. I will use a practical example to illustrate a real use case. I will assume that you already know how to do unit testing using PHPUnit, or that you at least have a grasp of what it’s all about.

He starts with a few definitions around what acceptance testing is and how Selenium can help in performing these evaluations. He uses a simple user registration page for his tests and includes commands to get PHPUnit+Selenium installed as well as an alias to start the Selenium server. He then creates a first test case, setting up the Selenium "browser" to use in later requests. He then gets to testing the page itself, setting up some data providers for the content to inject into the form both valid and invalid. He shows how to work with the DOM inside of your tests and making both a valid and invalid form submission. He also shows how to use a different browser (he defaults to Firefox) and how to check of the current document is ready for evaluation, that is if all Javascript has fired and finished.

tagged: selenium phpunit acceptance testing unittest tutorial

Link: http://www.sitepoint.com/using-selenium-with-phpunit/

Trending Topics: