mercredi 2 décembre 2015

Are some Codeception modules incompatible?

I am using Codeception to make acceptance tests for Symfony project. I need to test everything, this means testing pages (html content) as well as the ajax calls they perform (JSON content).

I have enabled the Symfony2 module in my suite settings but I find few methods in it to check JSON strings, so I guess I'm supposed to enable the REST module as well. However, if I do so, other previously existing tests fail.

For instance, this simple test:

public function privateExtranetHome(AcceptanceTester $I)
{
    $I->wantTo('test something');
    $I->amOnRoute('acme_site_home.es');
    $I->assertEquals(
        'container',
        $I->grabAttributeFrom('#container-slider', 'class')
    );
}

This is not a JSON testing test, just an already existing test in my Cest class, that passed when I only had the Symfony2 module enabled, and fails now that I added the REST module. The error message is :

Scenario:
* I am on route "acme_site_home.es"

  [Page] http://localhost/es
  [User] anon. []
* I grab attribute from "#container-slider","class"

Fatal error: Call to a member function hasAttribute() on null in [...]\Codeception\Module\REST.php on line 993

Maybe the amOnRoute() method is incompatible with the REST module, because when the latter is enabled, I get an empty response. But therefore my question is: is there some documentation, somewhere which states which modules are incompatible and should not be enabled together? Or should I take as a rule of thumb to use a separate suite for each module?


Just in case, my acceptance suite settings are as follows:

class_name: AcceptanceTester
modules:
    enabled:
        - Asserts
        - Db
        - Symfony2
        - Doctrine2
        - \Tests\Helper\Acceptance

And my Codeception settings:

namespace: Tests
actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
extensions:
    enabled: [ Codeception\Extension\RunFailed ]
modules:
    config:
        Db:
            dsn: 'mysql:host=localhost;dbname=acme_test'
            user: 'root'
            password: 'blahblah'
            dump: 'tests/_data/dump.sql'
            populate: false
            cleanup: false
        Doctrine2:
            depends: Symfony2
            cleanup: false
        PhpBrowser:
            url: http://acme.com
        WebDriver:
             browser: firefox
             url: http://acme.com
        REST:
            depends: Symfony2
            url: http://acme.com

Aucun commentaire:

Enregistrer un commentaire