Search code examples
codeception

Codeception: Call to undefined method FunctionalTester::expectException


According to the Codeption documentation I should be able to catch an HttpException by running the following:

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

However instead I get en error:

[RuntimeException] Call to undefined method FunctionalTester::expectException

I am using Codeception 2.4.3


Solution

  • In order to make expectException method available in the tests, Assert module must be enabled in functional.suite.yml file:

    modules:
        enabled:
            - Asserts