As the documentation wasn’t precisely clear to me, I decided to write a hands-on for future use. I hope someone will find it useful :-)

 

First of all, you need to require codeception in your Laravel project. This can be done by putting the line in your composer.json;

"require-dev": {
        "codeception/codeception": "^2.2"
    },

and then composer update of course. Or you could just enter in the console;

composer require "codeception/codeception:*"

Next up, bootstrap codeception.

./vendor/bin/codecept bootstrap

If all worked well, your tests folder will contain a lot more folders and your root will have an codeception.yml. Check it out! :-)

Open up the codeception.yml and add the following code between the actor and the paths

coverage:
    enabled: true
    include:
        - app/Http/*
        - app/Post.php
        - app/User.php
    exclude:
        - app/Http/routes.php
        - app/Http/Kernel.php

Remove

    envs: tests/_envs

And add beneath the modules the Laravel 5 module;

enabled:
        - Laravel5:
            environment_file: .env.testing

Which will give you in total the following yaml file (couldn’t I just post that directly and not let you do all the work? Yes I could. But I didn’t)

actor: Tester
coverage:
    enabled: true
    include:
        - app/Http/*
        - app/Post.php
        - app/User.php
    exclude:
        - app/Http/routes.php
        - app/Http/Kernel.php
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        Db:
            dsn: ''
            user: ''
            password: ''
            dump: tests/_data/dump.sql
    enabled:
        - Laravel5:
            environment_file: .env.testing

Now, duplicate your .env and name it .env.testing.

We’re almost there, just need to add some Laravel specific code to the _bootstrap.php file directly in the tests folder. So not inside of the suites or whatever, just there! Open it up and (yayy, a copy-paste action!) change the contents of the file to the following:

<?php
// This is global bootstrap for autoloading
require 'bootstrap/autoload.php';
$app = require 'bootstrap/app.php';
$app->loadEnvironmentFrom('.env.testing');
$app->instance('request', new \Illuminate\Http\Request);
$app->make('Illuminate\Contracts\Http\Kernel')->bootstrap();

Well, thats about it…

CodeCeption is ready to be build!

Console it:

./vendor/bin/codecept build

Thats about it, everything is in place to get started. Although documentation is not that clear after this, you can work with it now. In your console you can find some commands,

./vendor/bin/codecept

Which will show you some options. To generate a test you can use the following command:

./vendor/bin/codecept generate:cept unit App/Controllers/HomeController

For all the test possibilities in CodeCeption and L5, check it this url 

I hope this worked for you, if you have any questions, leave them here, I will try to help you out.