I want to run PHPUnit tests from within my IDE - and I know Karin G. has created excellent directions for PHPStorm, but I use Netbeans 8.2. What can I do?

1 Answer 1


[This all assumes you have civicrm-buildkit already working and that you can run CiviCRM phpunit tests successfully from the command line.]

1. Tell Netbeans which phpunit executable you're using.

  • Go to Tools » Options, then PHP tab, PHPUnit subtab.
  • Set the path of your PHPUnit script. See screenshot:

enter image description here

2. Create a shell script with your environment variable.

Copy this script into a file anywhere on your filesystem:

env CIVICRM_UF=UnitTests /path/to/your/phpunit5 $@

3. Tell Netbeans where to find your tests.

  • Go to File menu » Project Properties, Testing tab.
  • Click Add Folder and select the <civiroot>/tests/phpunit folder. See screenshot:

enter image description here

4. Tell Netbeans the CiviCRM-specific info it needs.

  • Go to File menu » Project Properties, PHPUnit tab.
  • Check the Use XML Configuration box.
  • Set the XML Configuration path to <civiroot>/phpunit.xml.dist.
  • Check the Use Custom PHPUnit Script box.
  • Set the PHPUnit Script to the path of the file from step 2.

enter image description here

5. You're ready to go!

From any PHP file in the main codebase, press Ctrl-F6 (or Run menu » Test File) to start your tests. You can also re-run only failed tests.


If PHPUnit isn't working, bring up the "Output" window (Window menu » Output). This will show you the exact command Netbeans tried to run. You can run it on your command line to compare results and tweak it.

  • Following onto this, it's also possible to get breakpoints working with a few tweaks to Jon G's instructions, by specifying an alternate port in Netbeans and in the bash script. See here: docs.google.com/document/d/…
    – TwoMice
    Commented Apr 8, 2019 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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