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



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

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

但是相反,我得到 en 错误:

[运行时异常] 调用未定义的方法 功能测试器::期望异常

我正在使用Codeception 2.4.3

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

modules:
enabled:
- Asserts

除了@Naktibalda答案 - 在最新版本的Codeception中,expectException已被弃用并替换为expectThrowable: https://codeception.com/docs/modules/Asserts#expectThrowable

相关内容

  • 没有找到相关文章

最新更新