为什么功能测试的代码接受如此缓慢?

时间:2018-11-29 08:25:05

标签: yii2 codeception

我正在尝试通过代码接收来测试我的Yii2应用程序。
这是一个简单测试的代码:

public function tryToTest(FunctionalTester $I)
{
    $I->amOnRoute('call/wait-for-answer', ['callId' => 1]);
    $I->see('Conntect', 'title');
}

public function anotherTest(FunctionalTester $I)
{
    $I->amOnRoute('call/wait-for-answer', ['callId' => 1]);
    $I->click('Answer', '.btn');
    $I->see('Answer', 'title');
}

这是测试结果:

Functional Tests (1) -----------------------------------------------------
✔ TestCest: Try to test (6.13s)
✔ TestCest: Another test (6.48s)
--------------------------------------------------------------------------

Time: 12.61 seconds, Memory: 18.00MB

12秒-非常慢!

我检查了它在浏览器中的工作方式,这就是我看到的:

第一次,浏览器中的该页面在5秒钟内加载并具有32个数据库查询,但是第二次该页面仅在300ms内加载并且具有11个数据库查询。

但是我的每个测试都在大约5秒钟内加载。 我怎样才能解决这个问题?

P.s。在我的基本设置中,

'enableSchemaCache' => true,
'schemaCacheDuration' => 1200,

但在测试中不起作用:(

0 个答案:

没有答案