Yii2 Codeception:[RuntimeException]调用未定义的方法ApiTester::sendDELETE

Yii2 Codeception:[RuntimeException]调用未定义的方法ApiTester::sendDELETE,yii2,codeception,Yii2,Codeception,我正在使用Yii2运行codeception的API测试。在tests文件夹中,我有另一个文件夹codeception,其中包含所有配置文件,这是我运行测试的地方 这是我的codeception.yml文件 paths: tests: tests output: tests/_output data: tests/_data support: tests/_support envs: tests/_envs actor_suffix: Tester ext

我正在使用Yii2运行codeception的API测试。在tests文件夹中,我有另一个文件夹codeception,其中包含所有配置文件,这是我运行测试的地方

这是我的codeception.yml文件

paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed
/**
 * Inherited Methods
 * @method void wantToTest($text)
 * @method void wantTo($text)
 * @method void execute($callable)
 * @method void expectTo($prediction)
 * @method void expect($prediction)
 * @method void amGoingTo($argumentation)
 * @method void am($role)
 * @method void lookForwardTo($achieveValue)
 * @method void comment($description)
 * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
 * 
 * @SuppressWarnings(PHPMD)
*/
class ApiTester extends \Codeception\Actor
{
    use _generated\ApiTesterActions;


    /**
     * @param string $name
     * @return mixed
     */
    public function loadFixture($name)
    {
        return include 'codeception/fixtures/' . $name . '.php';
    }

    /**

     */
    public function autoAuthenticate($key = '')
    {
        if ($key == '') {
            $key = '17sV24Ku83q-BxeNbXHUWNcBO5iVQxDK';
        }
        return $this->amBearerAuthenticated($key);
    }
}
这是我的api.suite.yml

class_name: ApiTester
    modules:
        enabled:
            - \Helper\Api
            - \Helper\FactoryHelper
            - REST:
                 depends: PhpBrowser
                 url: 'http://apitest.sb.dev/api/'
            - Db:
                 dsn: 'mysql:host=127.0.0.1;dbname=test'
                 user: 'root'
                 password: ''
                 dump: 'codeception/_data/dump.sql'
                 populate: true
                 cleanup: true
                 reconnect: true
            - Yii2:
               configFile: ../config/tests/unit.php
               part: [orm, email]
               cleanup: false
            - DataFactory:
               factories: codeception/_support/factories
               depends: Yii2
/**
 * Inherited Methods
 * @method void wantToTest($text)
 * @method void wantTo($text)
 * @method void execute($callable)
 * @method void expectTo($prediction)
 * @method void expect($prediction)
 * @method void amGoingTo($argumentation)
 * @method void am($role)
 * @method void lookForwardTo($achieveValue)
 * @method void comment($description)
 * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
 * 
 * @SuppressWarnings(PHPMD)
*/
class ApiTester extends \Codeception\Actor
{
    use _generated\ApiTesterActions;


    /**
     * @param string $name
     * @return mixed
     */
    public function loadFixture($name)
    {
        return include 'codeception/fixtures/' . $name . '.php';
    }

    /**

     */
    public function autoAuthenticate($key = '')
    {
        if ($key == '') {
            $key = '17sV24Ku83q-BxeNbXHUWNcBO5iVQxDK';
        }
        return $this->amBearerAuthenticated($key);
    }
}
我所做的一个典型测试将具有来自生成的文件apitestractions的函数。我的问题是,每当我运行一个测试时,我都会得到一个错误,表明ApiTesterActions文件完全看不见。例如:

Codeception:[RuntimeException]调用未定义的方法 ApiTester::sendDELETE

从我的测试中删除sendDelete并使用该文件中的任何其他方法也会出现错误

测试示例:

public function index(ApiTester $I) {
    $I->wantTo('view list via api');
    $I->sendGET($this->_getUrl(), ['client' => 10]);
    $I->seeResponseContainsJson(["data" => $this->menus]);
    $I->seeResponseCodeIs(200);
    $I->wantTo("try to view menus with client which doesn't exist");
    $I->sendGET($this->_getUrl(), ['client' => 150]);
    $I->seeResponseCodeIs(403);
    $I->seeResponseIsJson();
    $I->seeResponseContains(Yii::t('app', 'You need permission'));
}
我做错了什么

编辑:这是ApiTester.php
/**
 * Inherited Methods
 * @method void wantToTest($text)
 * @method void wantTo($text)
 * @method void execute($callable)
 * @method void expectTo($prediction)
 * @method void expect($prediction)
 * @method void amGoingTo($argumentation)
 * @method void am($role)
 * @method void lookForwardTo($achieveValue)
 * @method void comment($description)
 * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
 * 
 * @SuppressWarnings(PHPMD)
*/
class ApiTester extends \Codeception\Actor
{
    use _generated\ApiTesterActions;


    /**
     * @param string $name
     * @return mixed
     */
    public function loadFixture($name)
    {
        return include 'codeception/fixtures/' . $name . '.php';
    }

    /**

     */
    public function autoAuthenticate($key = '')
    {
        if ($key == '') {
            $key = '17sV24Ku83q-BxeNbXHUWNcBO5iVQxDK';
        }
        return $this->amBearerAuthenticated($key);
    }
}

尝试运行
codecept build
来重建重新生成的文件。尝试了一百万次。Codeception没有任何功能真正让人困惑。请显示一个测试文件的代码。我添加了一个文件,但我的观点是,我尝试了一百万种不同的方法,在第一次使用ApiteRestractions中的方法时,测试就会失败。好吧,我们必须找出你做错的唯一一件事:)