Вопрос

I am trying very hard to get phpunit working in netbeans with my symfony2 project.

I've made sub folder test in my project root. Tried linked the project to the phpunit.xml.dist and to the bootstrap.php.cash. and made a MyProjectTestSuite.php in that test folder and put that in my project property's as wel.

but all this gets me the error:

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

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

and the test's don't get executed.

the myprojectetstsuite.php looks like this.

<?php

use Symfony\Component\Finder\Finder;

class MyProjectTestSuite extends PHPUnit_Framework_TestSuite
{

    public static function suite()
    {
        $suite = new MyProjectTestSuite();
        $finder = new Finder();

        // ---------- COMMENT OUT TO TEST A SPECIFIC FILE ----------
        // $suite->addTestFile('../src/<yourbundle>/DefaultBundle/Tests/Controller/SomeControllerTest.php');
        // return $suite;
        // ----------

        echo "Searching for test cases...\n\n";
        foreach ($finder->files()->in('../src/')->name('*Test.php') as $file) {
            if (preg_match('%\\Tests\\[\w-\\]+Test.php%i', $file->getPathName())) {
                echo 'Adding test : ' . $file->getPathName() . "\n";
                $suite->addTestFile($file->getPathName());
            }
        }
        echo "\n";

        return $suite;
    }

}
Это было полезно?

Решение

okey.. if the test suite does not find any tests netbeans takes up there default test suite it apears. i ajusted my code abit so that I was sure I found some tests (commented out the regex) and there they all where.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top