创建单元测试用例时出现PHPUnit错误 [英] PHPUnit error while creating unit test cases

查看:203
本文介绍了创建单元测试用例时出现PHPUnit错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有控制器类"UserController"(在控制器文件夹中),该类扩展了BaseController(在应用程序文件夹中),

i have controller class "UserController"(in controller folder) which extends BaseController (present in app folder),

当我右键单击并选择选项"Create PHPUnitTests"时,出现以下错误:

when i right click and select option "Create PHPUnitTests" it gives me following error:

phpunit Fatal error: Class 'Base Controller' not found 

Ayone可以告诉我为什么会出现此错误,以及我必须为此配置什么吗.
我使用自定义php框架

can ayone tell me why i get this error and what i have to configure for the same.
I using custom php framework

推荐答案

您的包含路径"可能没有为您的IDE正确配置.对于Netbeans,请遵循《 Netbeans用户手册》中给出的说明:

Your Include Path is likely not configured correctly for your IDE. For Netbeans, follow the instructions given in the Netbeans User Manual:

如果不使用include语句在UnitTests中包含要测试的文件,则还必须引导环境.从IDE中执行UnitTests可能不会运行您的常规引导文件.考虑将phpunit.xml文件添加到测试中:

If you are not using include statements to include the files to be tested in the UnitTests, you also have to bootstrap the environment. Executing the UnitTests from the IDE will likely not run your regular bootstrap file. Consider adding a phpunit.xml file to your tests:

<phpunit backupGlobals="true"
     backupStaticAttributes="false"
     <!--bootstrap="/path/to/bootstrap.php"-->
     colors="false"
     …
<php>
    <includePath>.</includePath>

有关更多信息,请参见PHPUnit手册中的附录:

See the Appendix in the PHPUnit Manual for more information:

按照《 Netbeans用户手册》中给出的说明,使IDE在运行测试时自动考虑该文件:

Follow the instructions given in the Netbeans User Manual to make the IDE consider the file automatically when tests are run:

这篇关于创建单元测试用例时出现PHPUnit错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆