History of TestingSuites

Version 5

TestingSuites

Created by: Stephan Borg, Last modification: 22 Aug 2004 (00:25 UTC) by Stephan Borg
If you don't know about Object Orientation (OO) or 'Black Box' design, take a look at the ObjectOrientation page.

Under the kernel/test/ directory, you will find an attempt at our first testing suite. This is supposed to be a quick explanation on how it works.

The testing suite is based on the principles of Object Orientation or 'black box' design. The testing suite only cares about what could possibly go into a class, what if something not meant to go into the class is handled and will the output be the way you like it.

As OO uses a lot of inheritence, by changing something small in a base class, all child classes could be affected and break. Testing suites help prevent this. Also, if developers start putting data into the class, that was never meant for it, testing suites ensure that the class handles them gracefully, rather than die a horrible death.

Lastly, a testing suite also checks that the output is what you expected.

The testing script we use was written by Vincent Oostindië, and can be found at http://www.phppatterns.com/index.php/article/articleview/33/1/2/. Its very simple in design and perfect for our need in TikiPro. You can find a copy of the script as kernel/test/index.php.

So, using our class from ObjectOrientation, I'll show you how to write a test class for it.

In a directory, place the index.php script. Now, create a new file using the prefix Test - in this case TestMyClass.php.

Some points to remember for test classes:
  1. The test scripts need to include the script they will be testing (obviously).
  2. Create one test class per test script, the class name being the same as the file name.
  3. All test classes must extend a class Test
  4. All methods within the test class beginning with the letters "test" will be executed by PHPUnit

Page History
Date/CommentUserIPVersion
11 Mar 2006 (11:48 UTC)
corrected typo
Uwe Zimmermann87.96.133.21914
Current • Source
Jan Lindåker81.229.122.24913
View • Compare • Difference • Source
Jan Lindåker192.16.134.6611
View • Compare • Difference • Source
Jan Lindåker81.226.206.1989
View • Compare • Difference • Source
Stephan Borg218.214.1.1138
View • Compare • Difference • Source
Stephan Borg218.214.1.1137
View • Compare • Difference • Source
Stephan Borg218.214.1.1136
View • Compare • Difference • Source
Stephan Borg218.214.1.1135
View • Compare • Difference • Source
Stephan Borg218.214.1.1134
View • Compare • Difference • Source
Stephan Borg218.214.1.1133
View • Compare • Difference • Source
Stephan Borg218.214.1.1132
View • Compare • Difference • Source