Folks,
I think unit testing is valuable for software development. There is some
kind of testing framework in phpwiki at phpwiki/tests. However, it seems
to be "functional tests"-- that is, tests of the entire interface,
rather than individual classes or methods (unit testing). Furthermore,
it requires perl and java, and seems to have many moving parts.
I have written the very beginning of a small unit test framework, and I
attach it to this email. Take unit.tgz, and
cd phpwiki/tests
tar xvfz unit.tgz
cd unit
php test.php
and it should run the tests.
If this looks good and is checked in, I will start writing more tests
for it, and encourage others to do so.
I started with InlineParser, as it seemed to be something we'd like to
have unit tests for.
I cut and paste the readme.html from the tarball below.
Dan
Introduction
This directory contains unit tests for PhpWiki. You must have PEAR's
PHPUnit package <http://pear.php.net/package/PHPUnit>. These tests are
unrelated to maketest.pl in the directory above this one, which do not
use PHPUnit.
Prerequisites
PHP
You need the php command-line interface
<http://us3.php.net/features.commandline>. It was experimental as of PHP
4.2.0, default as of PHP 4.3.0. You also need the 'pear' executable.
PHPUnit
You can use pear to see if PHPUnit is installed:
/export/scratch/apache/2.0.46/php/bin) % ./pear list
Installed packages:
===================
Package Version State
Archive_Tar 0.9 stable
Console_Getopt 1.0 stable
DB 1.3 stable
HTTP 1.2 stable
HTTP_Upload 0.8.1 stable
Mail 1.0.1 stable
Net_SMTP 1.0 stable
Net_Socket 1.0.1 stable
PEAR 1.1 stable
PHPUnit 1.0.0 stable
XML_Parser 1.0.1 stable
XML_RPC 1.0.4 stable
If it is not installed, you can use 'pear' to install it:
/export/scratch/apache/2.0.46/php/bin) % ./pear install PHPUnit
Running these unit tests
You must be in the phpwiki/tests/unit subdirectory. Then use the php
command-line executable to run the tests. For example:
phpwiki/tests/unit % php test.php
Run tests ..
TestCase inlineparsertest->testnowikiwords() passed
TestCase inlineparsertest->testwikiword() passed
|