Test Suite

From GeeklogWiki
Revision as of 21:47, 14 August 2009 by Sean c (talk | contribs)

Jump to: navigation, search

Geeklog has it's own unit testing suite, powered by PHPUnit.


What can it do?

Using the test suite, you can run tests on the existing code, ensuring that the code continues to do exactly what it is supposed to do in a variety of scenarios. The suite uses a GUI, which displays existing tests that can be run, returns PHPUnit's console output, and stores the results to log files that can be viewed at any time.


How do I use it?

1. Running tests

You have two ways you can run your tests. One is by using a simple GUI included with the test package, and the second is by using the console.

Note: the GUI only fully supports Firefox >3 with javascript enabled.

To use the GUI, navigate with your browser to the tests folder in your Geeklog site (e.g: http://localhost/public_html/tests). You should be at a page called 'index_js.php'. Under the left panel titled 'Run Tests' is a tree structure of all available tests for the Geeklog test framework. Select any number of tests you like (if you choose a folder, all the tests inside will be included), choose whether to have the console output returned, logs created, and logs immediately shown, and click 'Run Tests'. It may take a few minutes, so be patient.

To use your tests using your console, open the console and navigate to the public_html/tests folder. From here, you can type 'phpunit (path/to/testclass/testname)', and the test you specify will be run, with the results displayed in the console. If you specify a folder, all tests inside will be run. Running tests this way will not create logs or interact with the suite.

Note: this will only work if you are in the tests root folder (with tst.class.php). This is because of the path structure.

You can find more information on running tests in the PHPUnit manual.


2. Viewing and deleting logs

If you are running tests with the GUI, the event will be logged in testpackage/logs/masterlog.txt, and JSON logs will be created in the same folder with information for the event. You can view these logs using the 'View logs' panel in the GUI - select the logs you want to view and press 'View'. Alternatively, you can delete old logs by selecting the logs and - you got it - pressing 'Delete'.