Answers.Body: <p>[This all assumes you have <code>civicrm-buildkit</code> already working and that you can run CiviCRM phpunit tests successfully from the command line.]</p>
  
  <h2>1. Tell Netbeans which phpunit executable you're using.</h2>
  
  <ul>
  <li>Go to <strong>Tools » Options</strong>, then <strong>PHP</strong> tab, <strong>PHPUnit subtab</strong>.</li>
  <li>Set the path of your PHPUnit script.  See screenshot:</li>
  </ul>
  
  <p><a href="https://i.sstatic.net/1Hpj2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1Hpj2.png" alt="enter image description here"></a></p>
  
  <h2>2. Create a shell script with your environment variable.</h2>
  
  <p>Copy this script into a file anywhere on your filesystem:</p>
  
  <pre><code>#!/bin/sh
  env CIVICRM_UF=UnitTests /path/to/your/phpunit5 $@
  </code></pre>
  
  <h2>3. Tell Netbeans where to find your tests.</h2>
  
  <ul>
  <li>Go to <strong>File menu » Project Properties</strong>, <strong>Testing</strong> tab.</li>
  <li>Click <strong>Add Folder</strong> and select the <code>&lt;civiroot&gt;/tests/phpunit</code> folder.  See screenshot:</li>
  </ul>
  
  <p><a href="https://i.sstatic.net/qcIOm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qcIOm.png" alt="enter image description here"></a></p>
  
  <h2>4. Tell Netbeans the CiviCRM-specific info it needs.</h2>
  
  <ul>
  <li>Go to <strong>File menu » Project Properties</strong>, <strong>PHPUnit</strong> tab.</li>
  <li>Check the <strong>Use XML Configuration</strong> box.</li>
  <li>Set the XML Configuration path to <code>&lt;civiroot&gt;/phpunit.xml.dist</code>.</li>
  <li>Check the <strong>Use Custom PHPUnit Script</strong> box.</li>
  <li>Set the <strong>PHPUnit Script</strong> to the path of the file from step 2.</li>
  </ul>
  
  <p><a href="https://i.sstatic.net/rx4Zb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rx4Zb.png" alt="enter image description here"></a></p>
  
  <h2>5. You're ready to go!</h2>
  
  <p>From any PHP file in the main codebase, press <code>Ctrl-F6</code> (or <strong>Run menu » Test File</strong>) to start your tests.  You can also re-run only failed tests.</p>
  
  <h2>Troubleshooting</h2>
  
  <p>If PHPUnit isn't working, bring up the "Output" window (<strong>Window menu » Output</strong>).  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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-08T13:53:27.823Z
Answers.Text: 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: https://docs.google.com/document/d/18qsvcwuoga2nGmUVd__l8TcqaMO368PTrsgJfpESpl8/edit#heading=h.b5svm5gmgfpq
Answers.UserDisplayName: TwoMice
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-21T05:48:48.727Z
Answers.LastActivityDate: 2018-11-21T05:48:48.727Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I want to run PHPUnit tests from within my IDE - and I know Karin G. has created <a href="https://civicrm.stackexchange.com/q/16489/12">excellent directions</a> for PHPStorm, but I use Netbeans 8.2.  What can I do?</p>
  
Tags: <developer><unit-testing><phpunit>
Title: How do I run CiviCRM PHPUnit tests from within Netbeans?
ThreadText: # How do I run CiviCRM PHPUnit tests from within Netbeans?
  
  (Asked by: username_0 on 2018-11-21)
  
  I want to run PHPUnit tests from within my IDE - and I know Karin G. has created [excellent directions](https://civicrm.stackexchange.com/q/16489/12) for PHPStorm, but I use Netbeans 8.2. What can I do?
  
  **Tags:** developer, unit-testing, phpunit
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-11-21. Score: 4 | Accepted answer
  
  [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:
  
  
  2. Create a shell script with your environment variable.
  Copy this script into a file anywhere on your filesystem:
  #!/bin/sh
  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 /tests/phpunit folder.  See screenshot:
  
  
  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 /phpunit.xml.dist.
  Check the Use Custom PHPUnit Script box.
  Set the PHPUnit Script to the path of the file from step 2.
  
  
  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.
  Troubleshooting
  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.
  
  > **Comments:**
  > **username_1**: 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: https://docs.google.com/document/d/18qsvcwuoga2nGmUVd__l8TcqaMO368PTrsgJfpESpl8/edit#heading=h.b5svm5gmgfpq  
  
  ---
  
  