【发布时间】:2017-09-16 20:52:21
【问题描述】:
我正在为我目前正在进行的项目编写 API 测试套件。
我可以使用成功运行套件
codecept run api
并且所有测试都成功通过了,但是每当我尝试使用
运行单个测试时codecept run api Tests\Users\Get
抛出以下错误:
PHP 致命错误:在第 12 行的 /Users/Username/Programming/PHP/Project/tests/api/Tests/Users/GetCest.php 中找不到类“Tests\ApiCest”
这是我正在使用的文件夹结构:
ApiCest.php 仅用于快速引导其他测试。这是它的内容:
namespace Tests;
/*
* This class is extended by the API tests.
*/
use ApiTester;
class ApiCest
{
public function _before(ApiTester $I)
{
$I->prepareRequest();
}
public function _after(ApiTester $I)
{
// All API responses must be in a JSON format.
$I->seeResponseIsJson();
}
}
这就是它在GetCest.php中的使用方式:
namespace Tests\Users;
use ApiTester;
use Codeception\Util\HttpCode;
use Tests\ApiCest;
/*
* Tests for the GET /users API endpoint.
*/
class GetCest extends ApiCest
{
// Tests methods are here but omitted
}
【问题讨论】:
标签: php composer-php codeception