I'm trying to run CiviCRM's unit tests, but I hit on this error when running scripts/phpunit AllTests:

RuntimeException: Command failed (cv php:boot --level=settings) in ...tests\phpunit\CiviTest\bootstrap.php

This is on the master branch of CiviCRM on a local development machine.

  • Using Windows 7 with a XAMPP stack
  • PHP Version 5.6.15
  • The civicrm-core directory is up to date with the master branch
  • Hi John - can you please add some details on you dev environment; – KarinG - Semper IT Apr 20 '16 at 23:00
  • Sorry, I should know better, I've done that now. – John Apr 21 '16 at 10:27

I recommend you install and use buildkit: https://github.com/civicrm/civicrm-buildkit

It comes with lots of tools - including those you need to run tests.

I use it on MAMP but from what I understand this will work on Windows as well.

Alternatively - if you like you can also: https://github.com/civicrm/civicrm-buildkit-vagrant

  • Yup, it works OK on vagrant. Buildkit is good but I've had some trouble getting it up and running on Windows. I'm also not sure if the cv package runs well on Windows. – John Apr 27 '16 at 13:35

Just adding some steps to check if basic things are met correctly.

  1. Make sure you are in civicrm folder when you run the test.

    $ cd <site_name>/sites/all/modules/civicrm
    $ export CIVICRM_UF=UnitTests
    $ phpunit4 tests/phpunit/api/v3/ContactTest.php 
  2. Is your civicrm.settings.php file searchable? Add the below line to your ~/.bash_profile file.

    export CIVICRM_SETTINGS=/Users/jitendra/www/civicrm-master/sites/default/civicrm.settings.php
  3. If you have cv installed and cv vars:fill runs fine, check if civicrm.settings.php values are correct($civicrm_root, CMS_DSN etc).


cv is a command line tool that's not included with CiviCRM. The repo can be found here: https://github.com/civicrm/cv

This command line utility seems to be required to run phpunit tests in Civi. (Though I'm not sure yet whether it runs on Windows systems).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.