I am newbie to any kind of testing. I just installed pear and PHPUnit using this doc. I use netbeans 7.3.1. I also installed skeletongenerator
running this command : pear install phpunit/PHPUnit_SkeletonGenerator
.
I Followed the steps listed in this testing with PHPUnit to integrate PHPUnit to netbeans.
As described in Installing PHPUnit
section of that doc, by clicking search
button under Netbeans->preferences->unit testing
my netbeans recognizes PHPUnit installation.
I followed all the steps to add sample Calculator
project and generate test class. I did that. But when I run the tests by right clicking Calculator.php file and selecting Test
I get following result.
Output window shows nothing useful :
I have no idea of what can be the problem and how to solve that.
Few doubts that may be causing the above problem :
What should I add in Global include path
under Netbeans->preferences->general
?
Do I need to add require_once
statement in Calculator.php file?
Do I need to create php projects under some particular folder only or is it immaterial where I place projects?
How do I check that PHPUnit is installed properly and is working?
There can be many other symptoms that I am not even able to think of.
Thank you.
Solved by adding below line to Calculatortest.php
file.
require_once dirname(__FILE__) . '/../Calculator.php';
The test class is placed in a subdirectory, so I needed to declare the path relative to the Calculator.php.
Also, I had to change php.ini file so that errors are displayed in case there are.
I set following variables in php.ini.
error_reporting = E_ALL | E_STRICT
display_errors = On
I had suffered the same problem. However, perseverance paid.
1) Create the sample project using NB samples.
2) The directory structure should be:
3) Right click on Calculator.php and choose Tools > Create Tests
4) Add require_once '../src/Calculator.php';
immediately after the top <?php
5) Select Calculator.php
and select Test
It worked for me. Let me know if it works for you. I hope, your configuration is ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With