在codeception功能测试中,请参见laravel提供的数据库不工作

在codeception功能测试中,请参见laravel提供的数据库不工作,laravel,laravel-5,codeception,laravel-5.2,Laravel,Laravel 5,Codeception,Laravel 5.2,我正在使用codeception在laravel 5.2中进行测试 这是我的codeception.yml文件: actor: Tester paths: tests: tests_codecept log: tests_codecept/_output data: tests_codecept/_data support: tests_codecept/_support envs: tests_codecept/_envs settings: b

我正在使用
codeception
laravel 5.2
中进行测试
这是我的
codeception.yml
文件:

actor: Tester
paths:
    tests: tests_codecept
    log: tests_codecept/_output
    data: tests_codecept/_data
    support: tests_codecept/_support
    envs: tests_codecept/_envs
settings:
    bootstrap: _bootstrap.php
    colors: false
    memory_limit: 1024M
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        Db:
            dsn: 'mysql:host=localhost;dbname=kartice_test'
            user: '*******'
            password: '*******'
            dump: tests_codecept/_data/dump.sql
            populate: true
            cleanup: true
            reconnect: true
下面是
functional.suite.yml
文件:

class_name: FunctionalTester
modules:
    enabled:
        # add framework module here
        - \Helper\Functional
        - Asserts
        - Laravel5:
            environment_file: .env.testing
        - Db
这是我的
测试方法

public function provera_dodavanja_novog_klijenta(FunctionalTester $I)
{

    $this->authenticate($I);

    $I->amOnPage('/kancelarija/komitenti/create');
    $I->see('Kreiranje novog komitenta');
    $I->fillField('input[name=komitent_code]', 'kom1');
    $I->fillField('input[name=komitent_name]', 'Komitent 1');
    $I->click('btnSave');
    $I->seeInDatabase('komitenti', ['code' => 'kom1', 'name' => 'Komitent 1']);
    $I->see('Komitent Komitent 1 je uspešno kreiran.');

}
运行功能测试失败,消息为:

 Step  I see in database "komitenti",{"code":"kom1","name":"Komitent 1"}
 Fail  No matching records found for criteria {"code":"kom1","name":"Komitent 1"} in table komitenti
Failed asserting that 0 is greater than 0.
我做错了什么


我看到了这个问题,但这对我没有帮助。

您可能应该使用
查看记录
方法,而不是
查看数据库
。我不知道为什么,但对我来说,第一个有效,第二个无效。

我使用gulp tdd,当测试表单遇到此错误时。 请检查:

  • 您已将此添加到请求中

    使用App\Http\Requests\

  • 确保表格的模型是可分配质量的

    protected$filleble=['tableField1','tableField2']


  • 很难说,但在文档中没有信息表明它不能在Laravel中工作。大约一年前,为了解决这个问题,我浪费了很多时间,只是改用
    seerect
    方法