创建单元测试用例时 PHPUnit 错误
我有控制器类“UserController”
(在控制器文件夹中),它扩展了BaseController
(存在于应用程序文件夹中),
当我右键单击并选择选项“创建PHPUnitTests”时
它给了我以下错误:
phpunit Fatal error: Class 'Base Controller' not found
谁能告诉我为什么会收到此错误以及我必须为此配置什么。
我使用自定义 php 框架
i have controller class "UserController"
(in controller folder) which extends BaseController
(present in app folder),
when i right click and select option "Create PHPUnitTests"
it gives me following error:
phpunit Fatal error: Class 'Base Controller' not found
can ayone tell me why i get this error and what i have to configure for the same.
I using custom php framework
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的包含路径可能没有为您的 IDE 正确配置。对于 Netbeans,请按照 Netbeans 用户手册中给出的说明进行操作:
如果您没有使用
include
语句来包含要在 UnitTests 中测试的文件,您还必须引导环境。从 IDE 执行单元测试可能不会运行常规引导文件。考虑将 phpunit.xml 文件添加到您的测试中:有关详细信息,请参阅 PHPUnit 手册中的附录:
按照 Netbeans 用户手册中给出的说明进行操作,使 IDE 在运行测试时自动考虑该文件:
Your Include Path is likely not configured correctly for your IDE. For Netbeans, follow the instructions given in the Netbeans User Manual:
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:See the Appendix in the PHPUnit Manual for more information:
Follow the instructions given in the Netbeans User Manual to make the IDE consider the file automatically when tests are run: