wiki:CiviCRM HowTo Run Tests

Version 5 (modified by Richard Bramley, 10 years ago) ( diff )

--

CiviCRM HowTo Run Tests

Tags: CiviCRM HowTo

Summary and expansion of the procedure outlined in the CiviCRM page Settings up your personal testing sandbox.

Gitify a project

The tests and test tools are not in the release package of CiviCRM, so you have to gitify the code - that is, convert it into a git repository and get the latest version of the code from Git Hub.

I have had a couple of problems with this:

  1. The gitify script gives you no options but to use the Master branch.
  2. The gitify script gives you an example that does not work.
  3. Still, some of the tests fail.

Nevertheless, the procedure to do this is:

  1. sudo apt-get install git (if it is not already installed)
  2. wget https://github.com/civicrm/civicrm-core/raw/master/bin/gitify
  3. bash gitify git://github.com/civicrm <path to civicrm> --hooks. e.g. bash gitify git://github.com/civicrm /var/www/sites/all/modules/civicrm/ --hooks

Set up test database

  1. Create DB civicrm_tests_dev
  2. Create the test user with SUPER privileges.
  3. cd /path-to/civicrm
  4. mysql -u user -p -hhostname civicrm_tests_dev < sql/civicrm.mysql
  5. mysql -u user -p -hhostname civicrm_tests_dev < sql/civicrm_generated.mysql
  6. In the file <path to civicrm>/tests/phpunit/CiviTest/civicrm.settings.local.php add the line define('CIVICRM_DSN', 'mysql://db_username:db_password@localhost/civicrm_tests_dev');

Error: Macro BackLinks(None) failed
'Environment' object has no attribute 'get_db_cnx'

Note: See TracWiki for help on using the wiki.