Four Frameworks to perform unit testing in PHP

Doing Unit testing is helps a team to produce quality application within time by allowing the developer to test the code as soon as they write it. By developing a test document, developers are forced to do rigorous testing before it reaches to QA team. This way the span of life cycle is reduced by avoiding it going back and forth between the developer and the tester. The following few Frameworks help teams to do unit testing efficiently. This way unit testing could become a fun to your developers too.
Four Frameworks to perform unit testing in PHP are
1. SimpleTest
2. PHPUnit
3. phpt
4. SnapTest
SimpleTest:
It’s a Open souce unit test framework created by Marcus Baker for PHP. The test structure in SimpleTest is similar to the Junit and PHPUnit.  It contains all of the typical functions in Junit and PHPunit and also includes Mock objects. Simplte Test helps to automate the web application’s regression testing. Regression testing on web applications can be done by parsing the HTML page by using scrpitable HTTP client for simulations like Form submission and clicking on Hyperlinks. Some of the JWebUnit functionalities like web page navigation, cookie testing and form submission are also incorporated in this.
The following link will assist you to get more idea on SimpleTest (http://www.simpletest.org)
PHPUnit:
PHP Unit is a part of xUnit family, which has testing frameworks in it. It provides a framework that helps in creating the test scripts easily and also the functionality to execute the tests and then analyze the results. The tests are arranged into cases in PHPUnit, which is very similar to Simple Test. A case is essentially a class in which public methods are singular independent tests.  A test name starts with “test” if the test is a public method. Any test, which is not, a public method will not be taken into account unless interpreted as a test under PHPUnit.  Helper methods are very useful for recurring tasks. If used Helper methods to set up a test, the test will be considered as a separate test by the framework. Refrence to assert methods are present inside each and every test. An assertion is mainly taking an expected value and then comparing it with an actual value. If the expected value does not match the actual value, then the test fails. Mock Objects are hugely important component in maintaining a unit test’s segregation from all other classes and resources except the one under test.
The following link will assist you to get more idea on PHPUnit.
http://www.phpunit.de/manual/current/en/phpunit-book.pdf
PHPT:
A phpt test is a small script, which used by the php internal and quality assurance teams for testing PHP’s functionalities. Writing phpt tests helps to make PHP more stable. For writing up a phpt test, we need a basic knowledge on PHP language, a text editor and a method to get the results of the code.  Phpt test is used in following scenario: The run-tests.php scripts call the test and it takes different parts of phpt file to name and to create a .php file. The newly created .php file is executed and the output of the same is compared with different sections of a phpt file. The Test pass only when the output of the script “matches” with the output provided in the phpt script.  Phpt test will do the following: It tries and breaks the PHP functions. PHPT test check the functions normal parameters as well as edge cases.
The following link will assist you to get more idea on Phpt
http://qa.php.net/write-test.php
SnapTest:
The most powerful unit-testing framework for PHP 5+ is SnapTest.  PHP’s runtime language is the only one of its kind that can be used to make the unit test process simpler without sacrificing the agility tests. The philosophy on which the Snap Test was build: Unit testing should be transparent in Snap Test. Complexity of test harness and coding out stub files should be avoided in Snap Test. The obstacle in writing tests should be very less so that it becomes easier to write the tests than writing the code.
Features of the SnapTest are:
• JUnit Compliant Test Harness
• TAP Compliant Test Output
• Runnable from Command Line via .sh or .php scripts
• Full support for mock objects at runtime (minimum parallel structures) as actors and critics
• Extensible add-on system for adapting SnapTest to just about any developer environment
The following link will assist you to get more idea on SnapTest
http://code.google.com/p/snaptest/

Doing Unit testing helps a team to produce quality application within time by allowing the developer to test the code as soon as they write it. By developing a test document, developers are forced to do rigorous testing before it reaches to QA team. This way the span of life cycle is reduced by avoiding it going back and forth between the developer and the tester. The following few Frameworks help teams to do unit testing efficiently. This way unit testing could become a fun to your developers too.

Four Frameworks to perform unit testing in PHP are

1. SimpleTest

2. PHPUnit

3. phpt

4. SnapTest

SimpleTest:

It’s a Open souce unit test framework created by Marcus Baker for PHP. The test structure in SimpleTest is similar to the JUnit and PHPUnit.  It contains all of the typical functions in JUnit and PHPUnit and also includes Mock objects. Simple Test helps to automate the web application’s regression testing. Regression testing on web applications can be done by parsing the HTML page by using scrpitable HTTP client for simulations like Form submission and clicking on Hyperlinks. Some of the JWebUnit functionalities like web page navigation, cookie testing and form submission are also incorporated in this.

Download and test your version of Simple test.

PHPUnit:

PHP Unit is a part of xUnit family, which has testing frameworks in it. It provides a framework that helps in creating the test scripts easily and also the functionality to execute the tests and then analyze the results. The tests are arranged into cases in PHPUnit, which is very similar to Simple Test. A case is essentially a class in which public methods are singular independent tests.  A test name starts with “test” if the test is a public method. Any test, which is not, a public method will not be taken into account unless interpreted as a test under PHPUnit.  Helper methods are very useful for recurring tasks. If used Helper methods to set up a test, the test will be considered as a separate test by the framework. Reference to assert methods is present inside each and every test. An assertion is mainly taking an expected value and then comparing it with an actual value. If the expected value does not match the actual value, then the test fails. Mock Objects are a hugely important component in maintaining a unit test’s segregation from all other classes and resources except the one under test.

The following link will assist you to get more idea on PHPUnit.

PHPT:

A phpt test is a small script, which is used by the php internal and quality assurance teams for testing PHP’s functionalities. Writing phpt tests helps to make PHP more stable. For writing up a phpt test, we need a basic knowledge on PHP language, a text editor and a method to get the results of the code.  Phpt test is used in following scenario: The run-tests.php scripts call the test and it takes different parts of phpt file to name and to create a .php file. The newly created .php file is executed and the output of the same is compared with different sections of a phpt file. The Test pass only when the output of the script “matches” with the output provided in the phpt script.  Phpt test will do the following: It tries and breaks the PHP functions. PHPT test check the functions normal parameters as well as edge cases.

More on Phpt

SnapTest:

The most powerful unit-testing framework for PHP 5+ is SnapTest.  PHP’s runtime language is the only one of its kind that can be used to make the unit test process simpler without sacrificing the agility tests. The philosophy on which the Snap Test was build: Unit testing should be transparent in Snap Test. Complexity of test harness and coding out stub files should be avoided in Snap Test. The obstacle in writing tests should be very less so that it becomes easier to write the tests than writing the code.

Features of the SnapTest are:

• JUnit Compliant Test Harness

• TAP Compliant Test Output

• Runnable from Command Line via .sh or .php scripts

• Full support for mock objects at runtime (minimum parallel structures) as actors and critics

• Extensible add-on system for adapting SnapTest to just about any developer environment

Here you go for:  SnapTest

Let me know if you are familiar with other frameworks.