Codeception:调用未定义的方法FunctionalTester::expectException

kee*_*eeg 2 codeception

根据 Codeption文档,我应该能够HttpException通过运行以下命令来捕获:

$I->expectException(HttpException::class, function () {
    $I->amOnRoute('that-doesnt/exist');
});
Run Code Online (Sandbox Code Playgroud)

然而我却得到了错误:

[RuntimeException] 调用未定义的方法FunctionalTester::expectException

我在用Codeception 2.4.3

Nak*_*lda 6

为了使expectException方法在测试中可用,必须在 function.suite.yml 文件中启用 Assert 模块:

modules:
    enabled:
        - Asserts
Run Code Online (Sandbox Code Playgroud)