Codeception重定向到所有请求的登录


Codeception redirects to login for all requests

我刚刚开始使用codeception,并且我遇到了登录脚本只为单个测试运行的问题。因此,对于所有其他必须记录用户的测试,都会失败。

验收''核心''登录接受:

$I = new AcceptanceTester($scenario);
$I->wantTo('login as a Admin');
$I->amOnPage('/login');
$I->fillField('email', 'test@gmail.com');
$I->fillField('password', 'test123');
$I->click('input[type=submit]');
$I->seeCurrentUrlEquals('/dashboard');
$I->see('Dashboard');

验收''核心''CreateUserCept:

$I = new AcceptanceTester($scenario);
$I->wantTo('Create a new user');
$I->amOnPage('/users/create');
$I->see('Please fill in the form to create a new user');

LoginCept测试通过,但CreateUserCept失败,并在用户重定向到登录页面时出错。

我的问题是每次测试都必须登录吗?还是它的工作方式类似于一个普通的基于web的用户,用户从会话中获得授权

其次,我认为必须有一个优先级系统,首先调用logincept,然后调用CreateUserCept和其他AdminCept。

是的,每个测试都应该是独立的,因此与浏览器会话不同,会话不会持久化。如果你真的需要这样做,你可以按照codeception网站上"会话快照"下的建议解决方案。