TIP UnitTestContrib is not installed on Foswiki.org.


Foswiki Unit-Test Framework

The Foswiki Unit Test Framework consists of a set of test support packages and scripts, and a number of unit test packages that test many of the features of Foswiki.

At the time of writing this package can only be used with Foswiki 1.0. (Foswiki 1.1 has its own version of UnitTestContrib).


To run the unit tests, cd to test/unit and type perl ../bin/TestRunner.pl FoswikiSuite.pm. The FoswikiSuite package will collect all the other tests in the test/unit directory and run them. Any test failures are reported during the test run and again at the end of the run.


-clean: Sometimes sessions in a live Foswiki hang around, or a test can fail leaving fragments of fixtures behind. These sessions and fragments may stop the tests from being run again, as the tests require an cleanroom environment to run in. You can instruct the test runner to clean up any fragments passing -clean to TestRunner.pl - but use it with great care, as it deletes webs and files from /tmp without waiting for confirmation from you!

-log: Normal test output is printed to the console, so you can redirect it to a file. This is hard to do on some platforms, so the -log option is provided. This saves all the test output (STDOUT and STDERR) to a logfile. The logfile is named for the exact time the test run started. Remember that logfiles can get quite large. The logfile can also be useful when you are analysing unexpected output from subprocesses, as it blocks any attempt to redirect to the null device.


The TestRunner.pl script accepts a list of the names of test files in the current directory. It performs some preliminaries and environment checking before invoking a Unit::TestRunner that does the real work. This class iterates over the list of test files, and runs the tests. It maintains a record of any failures, and reports them at the end of the run.

Test files are built by deriving a class from Unit::TestCase. This is usually done via FoswikiTestCase or FoswikiFnTestCase, which are fixture-building classes designed specifically for use when testing Foswiki. FoswikiTestCase is used for tests where the Foswiki configuration ($Foswiki::cfg) must be saved and restored; it is also responsible for making sure the default plugins (and only the default plugins) are enabled. FoswikiFnTestCase is used where we are already fairly confident that basic Foswiki work, and we need some pre-registered users and pre-created test webs containing data that the test can work on.

FoswikiSuite automatically includes any Plugin tests it can find in subdirectories below test/unit. This is helpful when you want to test a plugin in context with all the other core unit tests.

One test file, SemiAutomaticTestCaseTests.pm, reads the semi-automatic tests from the TestCases web stored in subversion. It will not run if it can't find the TestCases web, or if the Foswiki:Extensions.TestFixturePlugin is not installed.

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Contrib Info

Another great Foswiki extension from the wikiringlogo20x20.png WikiRing - working together to improve your wiki experience!

Contrib Author(s) Crawford Currie http://c-dot.co.uk and test authors
Copyright © 2007-2010 Foswiki Contributors
License GPL (Gnu General Public License)
Version 6218 (2010-02-05)
Release 1.0.9
Foswiki::Plugins::TestFixturePlugin>=0optional, used for semi-automatic test cases (TestCases web)
Contrib Home http://foswiki.org/Extensions/UnitTestContrib
Support http://foswiki.org/Support/UnitTestContrib

Related Topics: Contribs, DeveloperDocumentationCategory, AdminDocumentationCategory, DefaultPreferences, SitePreferences

Topic attachments
I Attachment Action Size Date Who Comment
UnitTestContrib.md5md5 UnitTestContrib.md5 manage 168 bytes 05 Feb 2010 - 01:01 SvenDowideit  
UnitTestContrib.sha1sha1 UnitTestContrib.sha1 manage 192 bytes 05 Feb 2010 - 01:01 SvenDowideit  
UnitTestContrib.tgztgz UnitTestContrib.tgz manage 154 K 05 Feb 2010 - 01:00 SvenDowideit  
UnitTestContrib.zipzip UnitTestContrib.zip manage 185 K 05 Feb 2010 - 01:00 SvenDowideit  
UnitTestContrib_installerEXT UnitTestContrib_installer manage 6 K 05 Feb 2010 - 01:00 SvenDowideit  
Topic revision: r1 - 05 Feb 2010, SvenDowideit - This page was cached on 27 Oct 2016 - 15:02.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License