1

私は symfony2 プロジェクトで phpunit を netbeans で動作させるために非常に努力しています。

プロジェクトルートにサブフォルダーテストを作成しました。プロジェクトをphpunit.xml.distとbootstrap.php.cashにリンクしてみました。そのテストフォルダーに MyProjectTestSuite.php を作成し、それをプロジェクトのプロパティに入れました。

しかし、これはすべてエラーになります:

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

テストは実行されません。

myprojectetstsuite.php は次のようになります。

<?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;
    }

}
4

1 に答える 1

1

わかりました..テストスイートがテストを見つけられない場合、netbeansはそこでデフォルトのテストスイートを取り上げます。コードを少し調整して、いくつかのテスト(正規表現をコメントアウト)を見つけたと確信できるようにしました。

于 2012-07-06T07:27:58.430 に答える