All tests live in the t/ directory, /data/WebGUI/t.
Tests do not need to be run as root, but the user who runs the tests must meet these conditions:
There are basically three ways to run tests:
One very important thing to keep in mind is that the tests may be destructive. They may rewrite your config file and make permanent changes in the database. It is recommended that you NOT run the tests on a production database unless you have a backup.
The testCodebase.pl script in sbin is a wrapper around prove, and it is the easiest way to run the entire test suite. testCodebase.pl needs to be executed from within the directory /data/WebGUI/sbin.
The script handles setting up environment variables needed to run various sections of the test. You need to give it a valid WebGUI config file that points to a scratch database. Run the script with the -h switch to get a summary of the options.
Run all tests, including i18n label validation and code inline help:
perl testCodebase.pl --configFile www.example.com.conf
Run all tests, skipping the long tests:
perl testCodebase.pl --configFile --noLongTests www.example.com.conf
If you just want to run one or two sections (directories) of tests, you want to use prove. Just as with running testCodebase.pl, you need a valid WebGUI config file that points to a scratch database.
Tests are just perl scripts, so you can run them from the command line: (make sure you are using a valid WebGUI config file that oints to a scratch database)
perl test.t or
env WEBGUI_CONFIG=/data/WebGUI/etc/notAProductionSite.conf perl test.t
The main WebGUI test module t/lib/WebGUI/Test.pm, sets up the tests so that STDERR is redirected to STDOUT. This is for convenience.
WebGUI::Test also redirects logfile output so that it can be tested and verified, so do not look in your webgui.log file for errors. You can either poke down into the errorHandler guts, or use the variables setup inside of WebGUI::Test. See t/Session/ErrorHandler.t for examples.
If your test needs to pass data to WebGUI via a web request (e.g., you need to submit data via parameters), then you can use the PseudoRequest library in t/lib/WebGUI. There is no documentation besides reading the code. Check out the t/Session/Http.t for examples of use.
see also Writing Tests
Keywords: api Development testing