Testing
From MIDAS Wiki
these instructions proceed assuming you ran
cd /var/www sudo svn co https://www.kitware.com/svn/KWPublic/trunk/MIDAS/MIDASserver Midas
Contents |
Submitting to CDash
- Update (or create in /var/www/Midas/midas/config ) config.local.php file and add the following lines
$MIDAS_TESTING_ENABLE = true; $MIDAS_PG_DB_NAME = 'midas4simpletest';
- Update (or create in /var/www/Midas/midas/config ) config.test.local.php, then add and edit the following line according to your setup:
$MIDAS_LOCALHOST_URL = 'http://localhost/Midas/midas/'; $MIDAS_SITE_TEST = 'mymachine.myinstitution'; $MIDAS_CDASH_HOST = 'http://www.cdash.org/CDash'; $MIDAS_CDASH_XML_OUTPUT_DIRECTORY = 'c:/windows/temp'; $MIDAS_CDASH_BUILDNAME = 'OS-architecture'; (e.g. Linux-64bit or Ubuntu10.10-64bit) $MIDAS_CDASH_PROJECT_NAME = 'MIDAS';
- Create a database named 'midas4simpletest' and another one named 'host'
- To install curl on Ubuntu simply run
sudo apt-get install php5-curl
- Edit the /etc/php5/cli/php.ini file (see installation)
- Run the testing suite with the cake console:
cake/console/cake -app /var/www/Midas/midas cdashtestsuite app all cdash
If testItemControllerView is failing because you do not have a handle server set, enter the following in /var/www/Midas/midas/config/config.local.php, with no space between the single quote marks.
$MIDAS_HANDLE_SERVER=' ';
Plugins Testing
To test a plugin which name is ExamplePlugin you should do the following:
Configuration
- In your directory for testing: : Add the SQL file to the list of SQL files to install when running the tests in config.test.php (or config.test.local.php):
$MIDAS_SQL_FILES = array('MIDAS','MIDAS_PLUGIN1','MIDAS_PLUGIN2',' MIDAS_EXAMPLEPLUGIN ');
- Precise what plugins are being used in config.php (or config.local.php) by setting the variable to 1
$MIDAS_PLUGINS = array( 'plugin1' => 1, 'ExamplePlugin' => 1);
Testing the models
- Extends KWModelCakeTestCase
/** Class for testing plug in model */
class ExamplepluginModelTestCase extends KWModelCakeTestCase
{
//tests for plugin model
}
- Use the function loadPluginModels() instead of loadmodels() (in vendors/kw_model_cake_test_case.php); giving the name of the plugin as first argument
- load a model from the core application like item.php for example before calling a model from the plug in:
/** ModelTestCase initialize function */
function startModelTestCase()
{
//load models
$this->loadModels(array("Item"));
//load model from plug in
$this->loadPluginModels("Exampleplugin", array("Mymodel1,Mymodel2"));
...
}
Calculating Code Coverage
In order to improve code coverage, it is useful to know what the code coverage is. To run code coverage with Midas using cdash, you'll need to install Xdebug.
Go to http://www.xdebug.org/docs/install for instructions, or better yet, go to http://www.xdebug.org/find-binary.php and follow these instructions. They'll have you run "php -i" at the command line, paste the output into a window, and you'll get instructions from there.
Now run cdash on Midas with the "cov" instruction at the end:
cake/console/cake -app /your/path/to/midas cdashtestsuite app all cdash cov