Codeception namespaces

2.2k Views Asked by At

Currently we have a large acceptance suite built using Codeception 2.0.16. We would like to upgrade to Codeception 2.2.5. However, after installing Codeception 2.2.5 (via phar), we cannot run our test suites at all.

The error we receive is (additional details at bottom):

[Codeception\Exception\ConfigurationException] Module WebHelper could not be found and loaded

Obviously the new version has loading changes that affect our suite.

I have searched for migration instructions to help us with this upgrade and don't see any.

Addtional Details

  • Codeception version: 2.016 ==> 2.2.5
  • PHP Version: 5.6.9
  • Operating System: CentOS
  • Installation type: Phar

Codeception PROJECT configuration

Note: After testing and changing several parts of the code i noticed that the main problem is related to namespaces. As you can se below we are using a namespace called "SM" and some how this os causing problems.

codeception.yml

namespace: SM
paths:
    tests: tests
    log: tests/_log
    data: tests/_data
    helpers: tests/_helpers
settings:
    bootstrap: _bootstrap.php
    suite_class: \PHPUnit_Framework_TestSuite
    colors: true
memory_limit: 1024M
    log: true
    strict_xml: true
modules:
    config:
        Db:
            dsn: 'mysql:host=xxxxxxxxxxxx;dbname=<DB_NAME>'
            user: 'USER'
            password: '********'
            dump: tests/_data/dump.sql
            populate: false
            cleanup : false

Acceptance Suite configuration

class_name: WebGuy
modules:
    enabled:
        - WebDriver
        - WebHelper
        - SistemWSClient
        - TestingSupportWSClient
        - Db
        - TempFileManager
        - Asserts

    config:
        WebDriver:
            url: 'http://xxxxxxxxxxxxxxxxxx/codeception'
            browser : firefox
            host: xxxxxxxxxxxxx
            port: 4444
            wait: 0
            restart: true
            capabilities:
                unexpectedAlertBehaviour: 'accept'

        SistemWSClient:
            url: xxxxxxx
        TestingSupportWSClient:
            url: 'http://x/codeception/rest.php'
        Db:
            dsn: 'mysql:host=xx;port=3306;dbname=x'
            user: 'xxxxxxx'
            password: 'xxxxxxx'
            dump: 'some/dump/file'
            populate: false
            cleanup: false

Notes:

a) I have added "namespace SM;" at the top of tests/_helpers/WebHelper.php (it did not work)

b) I also tried this: (it did not work)

modules:
    enabled:
        - \WebHelper (or \SM\WebHelper or any other combination)

c) I also installed a cleaned version of codeception from codeception's site:

  • Downloaded codeception (wget http://codeception.com/codecept.phar)
  • Installed it (codecept bootstrap)
  • Created simple test just for testing purposes (codecept generate:cept acceptance Welcome)

Added "namespace SM;" and Helpers accordingly and i get the same error, in this case:

Helper\Acceptance could not be found and loaded

d) I also tried to use codeception's "add-namespace" command without luck

Any idea will be appreciated.

Thanks,

1

There are 1 best solutions below

0
On

In Codeception, the 'helpers' have to be built. Try issuing the command:

codecept build

Then run it again.