【发布时间】:2017-11-07 06:37:56
【问题描述】:
我是 PHP 和 Codeception 以及单元测试整个概念的新手。到目前为止,我已经遵循 Codeception 的快速入门指南 (http://codeception.com/quickstart) 并阅读了他们的文档 (http://codeception.com/docs/05-UnitTests)。
我已经成功搭建了测试环境,并且
- 创建单元测试文件 (
php codecept.phar generate:test unit ExampleTest) - 运行测试命令(
php codecept.phar run unit ExampleTest),返回错误:
有 1 个错误:
1) ExampleTest: Validation Test tests\unit\ExampleTest.php:testValidation [Error] Class 'User' not found #1 ExampleTest->testValidation #2 C:\laragon\www\kario\vendor\bin\codecept.phar:5
我不明白的是,测试文件如何知道要在哪个 PHP 文件上运行测试?
我的 laragon 项目名为kario,位于C:\laragon\www\kario\resources\views\pages\orders,而测试单元文件位于C:\laragon\www\kario\vendor\bin\tests\unit。
【问题讨论】:
-
您的应用程序代码中有自动加载功能吗?自动加载是您最好的选择,但如果您不使用它,那么您将不得不单独要求每个文件。
标签: php unit-testing codeception laragon