Codeception: Override options does not work when a suite is specified

Created on 4 Apr 2017  路  2Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

Run codeception with a different port for Phantomjs, overriden on the command line.

What do you get instead?

The override made by -o does not work if the suite is specified.

Provide console output if related. Use -vvv mode for more details.

This should replace the ports from 4555 to 4556.

$ codecept config:validate acceptance -o 'env: phantom: modules: config: WebDriver: port: 4556' -o 'env: phantom: modules: config: AppHelper: port: 4556'
Validating acceptance config... Ok
------------------------------

acceptance Suite Config:

Array
(
    env => Array
        (
            phantom => Array
                (
                    modules => Array
                        (
                            config => Array
                                (
                                    AppHelper => Array
                                        (
                                            port => 4555
                                            browser => phantomjs
                                        )

                                    WebDriver => Array
                                        (
                                            port => 4555
                                            browser => phantomjs
                                        )


exact same command, but suite acceptance is not specified. Notice it works correctly:

$ codecept config:validate -o 'env: phantom: modules: config: WebDriver: port: 4556' -o 'env: phantom: modules: config: AppHelper: port: 4556' -o 'modules: config: WebDriver: port: 4556'  -vvv           
Validating global config... env: phantom: modules: config: WebDriver: port: 4556
env: phantom: modules: config: AppHelper: port: 4556
modules: config: WebDriver: port: 4556
Ok
------------------------------

Codeception Config:

Array
(
    env => Array
        (
            phantom => Array
                (
                    modules => Array
                        (
                            config => Array
                                (
                                    WebDriver => Array
                                        (
                                            port => 4556
                                        )

                                    AppHelper => Array
                                        (
                                            port => 4556

Details

  • Codeception version: 2.2.10
  • PHP Version: 7.0.5
  • Operating System: Linux
  • Installation type: Composer

This is _envs/phantom.yml

modules:
    config:
        AppHelper:
            port: 4555
            browser: 'phantomjs'
        WebDriver:
            port: 4555
            browser: 'phantomjs'

This is codeception.yml

paths:
    tests: tests
    log: tests/_log
    data: tests/_data
    helpers: tests/_helpers
    envs: _envs
settings:
    bootstrap: _bootstrap.php
    suite_class: \PHPUnit_Framework_TestSuite
    colors: true
    memory_limit: 1024M
    log: true
modules:
    enabled:
        - AppHelper
        - Asserts
    config:
        AppHelper:
            url: 'http://site.local'
            browser: firefox
            window_size: 1366x768
coverage:
    enabled: false
    remote: false

and finally tests/acceptance.suite.yml

class_name: WebGuy

I found https://github.com/Codeception/Codeception/issues/3740 in which @DavertMik says "Unfortunately it works for global config only. Suite configs are overriding global configs." Is it the same issue? If so, what is a possible fix or workaround? How can I change the phantomjs port on the command line?

question

Most helpful comment

I can confirm the original issue. On version 2.5.2, when I run a specific suite, the '-o' flag does nothing.

With shuffle not set in codeception.yml file...

codecept config:validate -o 'settings: shuffle: true'

Codeception Config:

Array
(
    settings => Array
        (
            shuffle => 1
            bootstrap => _bootstrap.php
            suite_class => \PHPUnit_Framework_TestSuite
            colors => 1
            memory_limit => 1024M
            log => 1
            strict_xml =>
            lint => 1
            backup_globals => 1
            log_incomplete_skipped =>
            report_useless_tests =>
            disallow_test_output =>
            be_strict_about_changes_to_global_state =>
        )
        ...

Works as expected.

codecept config:validate acceptance -o 'settings: shuffle: true'

...
    bootstrap => _bootstrap.php
    suite_class => \PHPUnit_Framework_TestSuite
    colors => 1
    memory_limit => 1024M
    log => 1
    strict_xml =>
    lint => 1
    backup_globals => 1
    log_incomplete_skipped =>
    report_useless_tests =>
    disallow_test_output =>
    be_strict_about_changes_to_global_state =>
    shuffle =>
    coverage => Array
...

No change.

All 2 comments

Why so complicated? Why don't you just use

codecept config:validate acceptance -o 'modules: config: WebDriver: port: 4556'

?

I can confirm the original issue. On version 2.5.2, when I run a specific suite, the '-o' flag does nothing.

With shuffle not set in codeception.yml file...

codecept config:validate -o 'settings: shuffle: true'

Codeception Config:

Array
(
    settings => Array
        (
            shuffle => 1
            bootstrap => _bootstrap.php
            suite_class => \PHPUnit_Framework_TestSuite
            colors => 1
            memory_limit => 1024M
            log => 1
            strict_xml =>
            lint => 1
            backup_globals => 1
            log_incomplete_skipped =>
            report_useless_tests =>
            disallow_test_output =>
            be_strict_about_changes_to_global_state =>
        )
        ...

Works as expected.

codecept config:validate acceptance -o 'settings: shuffle: true'

...
    bootstrap => _bootstrap.php
    suite_class => \PHPUnit_Framework_TestSuite
    colors => 1
    memory_limit => 1024M
    log => 1
    strict_xml =>
    lint => 1
    backup_globals => 1
    log_incomplete_skipped =>
    report_useless_tests =>
    disallow_test_output =>
    be_strict_about_changes_to_global_state =>
    shuffle =>
    coverage => Array
...

No change.

Was this page helpful?
0 / 5 - 0 ratings