dubbeltje
255
16
Testing

Failed asserting that exception of type "\Exception" is thrown.

Posted 1 week ago by dubbeltje

Hi,

I am running Laravel 5.8.27 and phpunit 7.5.13.

I have this test:

  /**
     * @test
     * @expectedException \Exception
     */
    public function an_exception_will_be_thrown_if_unknown_enum_is_requested()
    {
        $this->withExceptionHandling();
        $this->getJson('/api/enums/nonexistingenum');


    }

In my controller function I throw the exception right away:

public function show($enum)

    { 
   throw new \Exception('sfdsfd');
 }

However I get this error when running the test:

Failed asserting that exception of type "\Exception" is thrown.

Any suggestions?

Please sign in or create an account to participate in this conversation.