[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/test/PHPUnit/ -> TestCase.php (sommaire)

PHP Version 4 Copyright (c) 2002-2005, Sebastian Bergmann <sb@sebastian-bergmann.de>. All rights reserved.

Author: Sebastian Bergmann <sb@sebastian-bergmann.de>
Copyright: 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
License: http://www.opensource.org/licenses/bsd-license.php BSD License
Version: CVS: $Id: TestCase.php,v 1.21 2005/11/10 09:47:14 sebastian Exp $
Poids: 294 lignes (7 kb)
Inclus ou requis:0 fois
Référencé: 1 fois
Nécessite: 0 fichiers

Définit 1 class

PHPUnit_TestCase:: (13 méthodes):
  PHPUnit_TestCase()
  countTestCases()
  getName()
  run()
  runBare()
  runTest()
  setName()
  toString()
  createResult()
  fail()
  pass()
  setUp()
  tearDown()


Classe: PHPUnit_TestCase  - X-Ref

A TestCase defines the fixture to run multiple tests.

To define a TestCase

1) Implement a subclass of PHPUnit_TestCase.
2) Define instance variables that store the state of the fixture.
3) Initialize the fixture state by overriding setUp().
4) Clean-up after a test by overriding tearDown().

Each test runs in its own fixture so there can be no side effects
among test runs.

Here is an example:

<code>
<?php
class MathTest extends PHPUnit_TestCase {
var $fValue1;
var $fValue2;

function MathTest($name) {
$this->PHPUnit_TestCase($name);
}

function setUp() {
$this->fValue1 = 2;
$this->fValue2 = 3;
}
}
?>
</code>

For each test implement a method which interacts with the fixture.
Verify the expected results with assertions specified by calling
assert with a boolean.

<code>
<?php
function testPass() {
$this->assertTrue($this->fValue1 + $this->fValue2 == 5);
}
?>
</code>

PHPUnit_TestCase($name = FALSE)   X-Ref
Constructs a test case with the given name.

param: string

countTestCases()   X-Ref
Counts the number of test cases executed by run(TestResult result).

return: integer

getName()   X-Ref
Gets the name of a TestCase.

return: string

run(&$result)   X-Ref
Runs the test case and collects the results in a given TestResult object.

param: object
return: object

runBare()   X-Ref
Runs the bare test sequence.


runTest()   X-Ref
Override to run the test and assert its state.


setName($name)   X-Ref
Sets the name of a TestCase.

param: string

toString()   X-Ref
Returns a string representation of the test case.

return: string

createResult()   X-Ref
Creates a default TestResult object.

return: object

fail($message = '')   X-Ref
Fails a test with the given message.

param: string

pass()   X-Ref
Passes a test.


setUp()   X-Ref
Sets up the fixture, for example, open a network connection.
This method is called before a test is executed.


tearDown()   X-Ref
Tears down the fixture, for example, close a network connection.
This method is called after a test is executed.




Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics