Developer Area/Testing/Unit Testing: Difference between revisions
From Mahara Wiki
< Developer Area | Testing
(→Old instructions: This bug has been closed as the version of Ubuntu is no longer supported) |
|||
Line 1: | Line 1: | ||
= Unit Test Introduction = | =Unit Test Introduction= | ||
Work is currently underway to integrate phpunit unit testing in to Mahara. | Work is currently underway to integrate phpunit unit testing in to Mahara. | ||
Documentation for phpunit is available at http://www.phpunit.de/manual/current/en/ | Documentation for phpunit is available at http://www.phpunit.de/manual/current/en/ | ||
= Setup and Running = | =Setup and Running= | ||
You'll need to already have mahara set up and installed. Default settings are copied from your running configuration and overridden with unit test settings. | You'll need to already have mahara set up and installed. Default settings are copied from your running configuration and overridden with unit test settings. | ||
== Old instructions == | ==Old instructions== | ||
* Install phpunit on your development machine | |||
* Switch to a user with permission to access your dataroot directory. In debian this would be: | *Install phpunit on your development machine | ||
*Switch to a user with permission to access your dataroot directory. In debian this would be: | |||
sudo su - www-data | sudo su - www-data | ||
* Change directory to the root of the mahara git tree (the directory that htdocs is in) | |||
*Change directory to the root of the mahara git tree (the directory that htdocs is in) | |||
cd $path_to_mahara | cd $path_to_mahara | ||
* Run phpunit, first option only if you have set up your cli for php properly: | |||
*Run phpunit, first option only if you have set up your cli for php properly: | |||
phpunit . | phpunit . | ||
OR | OR | ||
Line 20: | Line 26: | ||
== New instructions == | ==New instructions== | ||
This requires phpunit 3.7 or later which is installed by running: | This requires phpunit 3.7 or later which is installed by running: | ||
Line 31: | Line 37: | ||
From the main directory of mahara (eg, parent directory of htdocs) | From the main directory of mahara (eg, parent directory of htdocs) | ||
= Best Practices = | =Best Practices= | ||
TODO | TODO |
Revision as of 05:36, 20 April 2022
Unit Test Introduction
Work is currently underway to integrate phpunit unit testing in to Mahara. Documentation for phpunit is available at http://www.phpunit.de/manual/current/en/
Setup and Running
You'll need to already have mahara set up and installed. Default settings are copied from your running configuration and overridden with unit test settings.
Old instructions
- Install phpunit on your development machine
- Switch to a user with permission to access your dataroot directory. In debian this would be:
sudo su - www-data
- Change directory to the root of the mahara git tree (the directory that htdocs is in)
cd $path_to_mahara
- Run phpunit, first option only if you have set up your cli for php properly:
phpunit . OR php -c /etc/php5/apache2/php.ini /usr/bin/phpunit . OR php -c /etc/php5/php-fpm/php.ini /usr/bin/phpunit .
New instructions
This requires phpunit 3.7 or later which is installed by running:
make initcomposer
Unit tests can be run by:
make phpunit
From the main directory of mahara (eg, parent directory of htdocs)
Best Practices
TODO