doudandui1592 2013-02-06 23:58
浏览 68
已采纳

PHPUnit:在<ClassNameTest> .php中找不到类<ClassName>

I'm at my wit's end. I must have read every SO question on the same topic, but no joy.

I can't get phpUnit working properly. I've successfully installed phpUnit and it's dependencies using PEAR. I've also modified my php.ini file and added the path to phpUnit to the include path: (".:/php/includes:usr/lib/php/pear").

To test phpunit is working, I've copied this simple class, so MyClassTest.php is as follows:

class MyClassTest extends PHPUnit_Framework_TestCase
{
    public function testCalculate()
    {
        $this->assertEquals(2, 1 + 1);
    }
}

Running "phpunit MyClassTest" produces the following output: (running "phpunit MyTestClass MyTestClass.php" produces the same result);

class MyClassTest extends PHPUnit_Framework_TestCase
{
    public function testCalculate()
    {
        $this->assertEquals(2, 1 + 1);
    }
}
PHPUnit 3.7.13 by Sebastian Bergmann.

Class 'MyClassTest' could not be found in 'MyClassTest.php'.

I can't think what's wrong. I've tried uninstalling and reinstalling phpunit/PHPUnit, but no joy. Can you identify what's wrong? If you need any more info, let me know and I'll edit this post. Thanks in advance.

  • PHP 5.3.15
  • PHPUnit 3.7.13
  • OSX 10.8.2
  • 写回答

1条回答 默认 最新

  • douye2111 2013-02-07 00:20
    关注

    Your source code gets printed to the console, so it seems like you forgot <?php at the beginning.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无源定位系统的时差估计误差标准差
  • ¥15 请问这个代码哪里有问题啊
  • ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库
  • ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
  • ¥15 openpcdet自制数据集评估bev精度和3d精度相同
  • ¥15 excel 上下按钮 显示行
  • ¥20 云卓h12pro 数传问题