1

In cmdline everything is OK:

d:\xampp\htdocs\PhpProject1\Tests>phpunit TestStub.php
PHPUnit 3.6.10 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 2.75Mb

OK (1 test, 1 assertion)

Called in NetBeans7.1:

Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Could not find class "" in "D:\Program Files (x86)\NetBeans 7.1\php\phpunit\NetBeansSuite.php".' in D:\xampp\php\PEAR\PHPUnit\Util\Skeleton\Test.php:123
Stack trace:
0 D:\xampp\php\PEAR\PHPUnit\TextUI\Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('', 'D:\Program File...')
1 D:\xampp\php\PEAR\PHPUnit\TextUI\Command.php(130): PHPUnit_TextUI_Command->run(Array, true)
2 D:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
3 {main}
thrown in D:\xampp\php\PEAR\PHPUnit\Util\Skeleton\Test.php on line 123

I think this is a NetBeans issue. If I run:

d:\Program Files (x86)\NetBeans 7.1\php\phpunit>phpunit NetBeansSuite.php run=d:\xampp\htdocs\PhpProject1\Tests\TestStub.php
PHPUnit 3.6.10 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 2.75Mb

OK (1 test, 1 assertion)

It's OK. But if I give the test directory, it fails.

d:\Program Files (x86)\NetBeans 7.1\php\phpunit>phpunit NetBeansSuite.php run=d:\xampp\htdocs\PhpProject1\Tests\

Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Could not find class "" in "D:\Program Files (x86)\NetBeans 7.1\php\phpunit\NetBea
nsSuite.php".' in D:\xampp\php\PEAR\PHPUnit\Util\Skeleton\Test.php:123
Stack trace:
0 D:\xampp\php\PEAR\PHPUnit\TextUI\Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('', 'D:\Program File...')
1 D:\xampp\php\PEAR\PHPUnit\TextUI\Command.php(130): PHPUnit_TextUI_Command->run(Array, true)
2 D:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
3 {main}
thrown in D:\xampp\php\PEAR\PHPUnit\Util\Skeleton\Test.php on line 123

Any temporary solution?

shuttle
  • 153
  • 1
  • 11
  • Grrr.. line 118 in "d:\Program Files (x86)\NetBeans 7.1\php\phpunit\NetBeansSuite.php" shows the solution `return self::rglob("*[Tt]est.php", $run.DIRECTORY_SEPARATOR);` Test filename must be ended ...Test.php – shuttle Feb 25 '12 at 11:35
  • 1
    Did you point NetBeans to your `bootstrap.php` and/or `phpunit.xml` files? – David Harkness Feb 25 '12 at 20:25
  • I've personally found that the PHPUnit support in NetBeans is problematic at best and have ditched it in favor of running unit tests at the command line instead. – Hades Feb 25 '12 at 12:06

1 Answers1

3

When running PHPUnit against a single file it will always open the file and look for a test case inside of it.

When running it against a directory (what netbeans does) it will only look into files that end in *Test.php (unless something else is specified in the phpunit.xml).

If it can't find any Tests it will try to look into the $TestSuiteName folder and {$TestSuiteName}.php files hence the error message:

Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Could not find class ""

as it is looking for a "not named" test suite in the netbeans phpunit harness. The error message is really not helping you out there :)

The general suggestion would be to create a phpunit.xml and point Netbeans to it.

On a more personal note: From the phpunit support in the major IDEs Netbeans does quite a lot of things right and works well for a lot of people so don't let this bump discourage you from using it from the IDE if thats what you want.

edorian
  • 38,542
  • 15
  • 125
  • 143