PHPUnit
[ class tree: PHPUnit ] [ index: PHPUnit ] [ all elements ]

Class: PHPUnit

Source Location: /PHPUnit-1.3.2/PHPUnit.php

Class Overview


PHPUnit runs a TestSuite and returns a TestResult object.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>

Methods


Inherited Variables

Inherited Methods


Class Details

[line 109]
PHPUnit runs a TestSuite and returns a TestResult object.

Here is an example:


1 <?php
2 require_once 'PHPUnit.php';
3
4 class MathTest extends PHPUnit_TestCase {
5 var $fValue1;
6 var $fValue2;
7
8 function MathTest($name) {
9 $this->PHPUnit_TestCase($name);
10 }
11
12 function setUp() {
13 $this->fValue1 = 2;
14 $this->fValue2 = 3;
15 }
16
17 function testAdd() {
18 $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
19 }
20 }
21
22 $suite = new PHPUnit_TestSuite();
23 $suite->addTest(new MathTest('testAdd'));
24
25 $result = PHPUnit::run($suite);
26 print $result->toHTML();
27 ?>

Alternatively, you can pass a class name to the PHPUnit_TestSuite() constructor and let it automatically add all methods of that class that start with 'test' to the suite:


1 <?php
2 $suite = new PHPUnit_TestSuite('MathTest');
3 $result = PHPUnit::run($suite);
4 print $result->toHTML();
5 ?>



[ Top ]


Method Detail

run   [line 117]

PHPUnit_TestResult &run( mixed &$suite)

Runs a test(suite).
  • Access: public

Parameters:

mixed   &$suite     

[ Top ]


Documentation generated on Thu, 10 Nov 2005 05:02:22 -0500 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.