简体   繁体   English

在yii2中自动化代码接收测试

[英]Automate the codeception Testing in yii2

I wanted to automate the functional codeception testing in yii2,I am able to test the login API using the following code 我想自动化yii2中的功能代码接收测试,我能够使用以下代码测试登录API

use tests\codeception\backend\FunctionalTester;
$I = new FunctionalTester($scenario);
$I->wantTo('Check when authenticated');
$I->sendPOST('/login', ['password' => '11111111', 'email'=>'check@check.com']);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"result"');
$I->seeResponseContains('"message"');
$I->haveHttpHeader('Accept','application/json');
$I->seeResponseContains('"message":"OK"');

In Login API I return the auth_token which can be used for further processing,So Where do I save the result of login API and use it for testing the further API's 在登录API中,我返回可用于进一步处理的auth_token,因此,我在哪里保存登录API的结果并将其用于测试其他API的

We can store the response using the following function.and check it further for API's 我们可以使用以下函数存储响应,并进一步检查API是否

$check = $I->grabResponse();
$check = json_decode($check,true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM