2

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

2
  • 2
    Have you enabled Asserts module in functional.suite.yml?
    – Naktibalda
    Aug 29, 2018 at 8:13
  • and I do not... well thats embarrassing. Please put as answer and I will accept.
    – keeg
    Aug 31, 2018 at 2:55

2 Answers 2

6

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

modules:
    enabled:
        - Asserts
0

In addition to @Naktibalda answer - in latest version of Codeception expectException was deprecated and replaced with expectThrowable: https://codeception.com/docs/modules/Asserts#expectThrowable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.