Sunday, 24 March 2013

Why you need PHPUnit for your Project


Today, let me explain the importance of PHPUnit and why you need PHPUnit for your project.
Before that one, if you don’t have PHPUnit Installed in your system, Following URL explains “How to install PHPUnit using PEAR”. http://www.phpunit.de/manual/3.0/en/installation.html

Why you need PHPUnit Testing?

As Developers like me, tends to think why you need Unit Testing. If you came across the following issues while you are developing your applications, then its right time for you to use PHPUnit in your project.

1)      How many times have you seen a blank screen in your browser.
2)      How many times did you debug your PHP Script using var_dump() and other debug statements.
3)      How many times did you run your application in your browsers for checking various workflows of your application?

Your PHP Script can be easily broken, if you forgot to put semicolon or braces, and also by changing a single line of code that may broke the other part of applications without proper testing. Then you will get a Call from the client at the middle of the night and telling website is broken. In order to avoid these unexpected one, it’s right idea for PHP developers to use PHPUnit in your applications.

Get Start with PHPUnit Today

I first became aware of TestDriven Development and unit testing about a year ago, when I first read PracticalPHP Testing E-Books written by Giorgio Sironi. You can download this book free by clicking that above links. I suggest this book to those PHP Developers who want to learn PHPUnit. I am very glad that I did!.

Once you start using PHPUnit in your application, you will realize that importance of PHPUnit and how PHPUnit is making your development life easier and it will catch and eliminate bugs much more easily and sooner in the development process. If you are new to PHPUnit, there are lots of Getting started guides available online. Following are some for your reference.


If you haven’t used PHPUnit for your current project, please don’t postpone it for your next project, do it right now by creating a simple test case and checking the various possibilities of your classes using various assert methods. Following URL explains the various asserts present in the PHPUnit. http://www.phpunit.de/manual/3.4/en/api.html#api.assert

Hope, you enjoyed this Post.

1 comment: