Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans-PHPUnit "No tests executed" error

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.

enter image description here

Output window shows nothing useful :

enter image description here

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.

like image 677
Geek Avatar asked Jul 18 '13 07:07

Geek


2 Answers

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
like image 170
Geek Avatar answered Oct 17 '22 10:10

Geek


I had suffered the same problem. However, perseverance paid.

1) Create the sample project using NB samples.

2) The directory structure should be:

  • Source Files
    • Calculato.php
  • Test Files
  • Include Path

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.

like image 37
user3388664 Avatar answered Oct 17 '22 11:10

user3388664