Cakephp 3.0单元测试问题

时间:2016-01-14 12:18:29

标签: unit-testing cakephp cakephp-3.0

当我执行plugins / SamplePlugin测试用例时,除了与url相关的控制器函数外,它执行完美。 测试用例的功能类似于

public function testIndex()
    {
        $this->get('/sample-plugin /mycontroller/index');
        $this->assertResponseOk();
    }

当我执行上面的测试用例时,异常

There was 1 error:

1) SamplePlugin\Test\TestCase\Controller\MyControllerTest::test
Index
include(D:\xampp\htdocs\EATZ_V2_3.X\vendor\cakephp\cakephp\tests\test_app\config\routes.php): failed to open stream: No such file or directory

D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\Routing\Router.php:974
D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\Routing\Router.php:974
D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\Routing\Router.php:547
D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\TestSuite\IntegrationTestCase.php:451
D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\TestSuite\IntegrationTestCase.php:392
D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\TestSuite\IntegrationTestCase.php:312
D:\xampp\htdocs\MyApp\vendor\cakephp\cakephp\src\TestSuite\IntegrationTestCase.php:233
D:\xampp\htdocs\MyApp\plugins\SamplePlugin\tests\TestCase\Controller\MyControllerTest.php:29
D:\xampp\php\pear\PHPUnit\TextUI\Command.php:176
D:\xampp\php\pear\PHPUnit\TextUI\Command.php:129

FAILURES!
Tests: 30, Assertions: 42, Errors: 1.

请尽快解决问题。谢谢!

1 个答案:

答案 0 :(得分:0)

错误指出文件夹配置中缺少routes.php文件。请参阅CakePHP 3 Documentation以创建有意义的routes.php。