我试图在每个测试套件的开始进行API调用,但我没有找到一种方法来做到这一点。在我的模块中,我已经重载了_beforeSuite
方法,但当我尝试从REST模块调用sendPost
时,我得到了错误。我的模块类看起来像这样:
class CoolApi extends 'Codeception'Module
{
public function _beforeSuite(array $settings) {
$I = $this->getModule('REST');
$I->sendPost('my-url-yay/', [
'ids' => '1,2,3',
]);
}
这给了我PHP错误:
在非对象上调用成员函数request()/…/供应商/codeception/codeception/src/codeception/模块/REST.php: 476
我如何在_beforeSuite中发送post请求?
你必须调用连接模块(PhpBrowser或你的框架)和REST模块的_before方法来初始化客户端对象。