Php Codeception-在_beforeSuite上进行API调用
我试图在每个测试套件开始时进行API调用,但没有找到方法。在我的模块中,我重载了Php Codeception-在_beforeSuite上进行API调用,php,testing,codeception,Php,Testing,Codeception,我试图在每个测试套件开始时进行API调用,但没有找到方法。在我的模块中,我重载了\u beforeSuite方法,但是当我试图从REST模块调用sendPost时,我得到了错误。我的模块类如下所示: class CoolApi extends \Codeception\Module { public function _beforeSuite(array $settings) { $I = $this->getModule('REST'); $I-
\u 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()
/..…/vendor/codeception/codeception/src/codeception/Module/REST.php:476
如何在“beforeSuite”中发送post请求?您必须在连接模块(PhpBrowser或您的框架)方法和REST模块之前调用“U”,以初始化客户端对象。您必须在连接模块(PhpBrowser或您的框架)方法和REST模块之前调用“U”,以初始化客户端对象