laravel中的代码在功能测试期间不显示异常

时间:2015-10-02 14:57:52

标签: php laravel-5 codeception

我正在尝试做BDD风格的项目。到目前为止,我已经完成了一切。问题是,如果我有这样的事情:

$I->amOnPage('/login');
$I->fillField('email', 'test@example.com');
$I->fillField('passord', 'secret');
$I->submitForm();
$I->assertTrue(Auth::check());

到目前为止我没有路线,所以我希望codecept run会向我显示异常。但它只显示了这一点:

1) Failed to test valid login in DemanderAuthorizationCest::testValidLogin (tests/functional/DemanderAuthorizationCest.php)

 Step  I fill field "email","test@example.com"
 Fail  Form field by Label or CSS 'email' was not found.

我认为这是因为Laravel的错误处理,但我不知道如何修复它。

我的functional.suite.yml看起来像这样:

class_name: FunctionalTester
modules:
  enabled:
    - \Helper\Functional
    - Asserts
    - Laravel5:
        environment_file: .env.testing

谢谢。

1 个答案:

答案 0 :(得分:0)

我解决了这个问题:

class Handler extends ExceptionHandler
{
    // ...
    public function report(Exception $e)
    {
        if (App::environment() == 'testing') {
            throw $e;
        }
        return parent::report($e);
    }
    // ...
}