PHPUnit is a test suite framework that is widely used for PHP projects. It provides improvements over older testing frameworks like SimpleTest, including better command line tools, code coverage reports, assertions, mock objects, and tool chain support. PHPUnit uses annotations and assertions to make tests stricter and more consistent. It supports features like fixtures, mock objects, and code coverage reporting to help test codebases thoroughly. PHPUnit can be run from the command line or a web interface, and integrates with continuous integration servers to run tests automatically.
2. PHPUnit?
PHPUnit is a test suite framework.
Pretty much the standard in PHP. Used by:
Zend Framework
Symfony
ezComponents and many many more.
Fully featured (more later).
3. Improvements over
SimpleTest
Better command line tools.
Better coverage reports.
Better selection of assertions.
Better mock objects.
Better tool chain support.
Pretty much all win.
8. Better failures
1 1) MyTest::makeSureStuffIsTheSame
2 Failed asserting that two strings are equal.
3 --- Expected
4 +++ Actual
5 @@ @@
6 This is some
7 -text
8 -on multiple lines
9 +words
10 +on
11 +a second line
25. Code coverage
How much of your code gets run in your tests.
Requires xDebug.
Comes in several formats:
Clover format.
Comprehensive HTML report.
Single test reports.
26. Clover reports
Clover reports. XML le that works well with
Jenkins/Hudson.
Console/cake testsuite
--coverage-clover clover.xml
app AllTests
27. Complete HTML
report
Full detailed report for your entire project.
Slower to generate, but more complete.
Console/cake testsuite
--coverage-html ./webroot/coverage
app AllTests
31. Runners
Command line runner.
Web runner.
Some con gurations have troubles running
sessions in cli. But its a con g option.
Main difference is how you use them.