Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeception 2.1.1 environment configs issue #2229

Closed
alex3190 opened this issue Jul 29, 2015 · 7 comments
Closed

Codeception 2.1.1 environment configs issue #2229

alex3190 opened this issue Jul 29, 2015 · 7 comments

Comments

@alex3190
Copy link

I am trying to run a test suite using configs from two environments (this is a feature implemented in 2.1 - http://codeception.com/docs/07-AdvancedUsage#Environments) and when I run bin/codecept suite --env env1,env2 it just runs full resolution on chrome, which is the default setting in codeception.yml. Here is the contents of env1 and env2:

env2:

modules:
    config:
        WebDriver:
            window_size: 320x450
            capabilities: []

env1:

modules:
    config:
        WebDriver:
            browser: 'firefox'

env1.yml and env2.yml are correctly placed in the _envs forlder, and the path to this folder is specified in codeception.yml.

The yml of the suite I am trying to run is:

class_name: AcceptanceTester
modules:
    enabled:
        - \Helper\Acceptance
        - WebDriver

This is codeception.yml

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    helpers: tests/_support
    envs: tests/_envs
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
modules:
    enabled:
        - \Helper\Acceptance
        - WebDriver
    config:
        WebDriver:
            url: 'http://myurl.com/'
            browser: 'chrome'
            host: 127.0.0.1
            port: 4444
            window_size: 1920x1080
@alex3190
Copy link
Author

It worked without using the yml files in _envs, i just specified the envs i wanted to use in codeception.yml and both settings were accounted for.

Still couldn't manage to solve the initial problem , but maybe there's a setting that i'm missing or haven't filled out properly.

@DavertMik
Copy link
Member

I didn't manage to reproduce it. My files:

_envs/normal.yml:

modules:
    config:
        WebDriver:
            browser: 'firefox'

_envs/mobile.yml

modules:
    config:
        WebDriver:
            window_size: 320x450
            capabilities: []

running --env normal,mobile executed firefox in 320x450 resolution. (there is no browser set in acceptance.yml)

@sjableka
Copy link

sjableka commented Aug 8, 2015

There was a bug with loading env configuration files (only .dist.yml files were loaded), but it has already been fixed 18c8313
@alex3190 Please update your Codeception if you still have this issue (it's not yet in any tagged release, so you have to use 2.1 branch)

@oparoz
Copy link

oparoz commented Aug 11, 2015

Confirmed as working in 2.1.2, using the new config syntax (docs should be updated),

acceptance.suite.yml

modules:
    enabled:
         - \Helper\Acceptance
         - WebDriver:
             url: http://localhost:8000
             browser: phantomjs
             window_size: 960x1080
             capabilities:
                 unexpectedAlertBehaviour: 'accept'

_envs/firefox.yml

modules:
    enabled:
         - WebDriver:
             browser: firefox

php vendor/bin/codecept run --env firefox get me a test with Firefox

@LoopKarma
Copy link

In addition to this issue I want to ask about possibility of storing config of some Codeception modules in separate file outside VSC. e.g: I have a project and everybody have different urls to project on their local machines and I think it would be nice to set url for PhpBrowser outside common config file.

common config in functional.suite.yml:
class_name: FunctionalTester
modules:
    enabled:
        - PhpBrowser
        - Yii2
        - REST
        - ApiHelper
    config:
      Yii2:
        configFile: 'codeception/config/functional.php'
      REST:
        depends: PhpBrowser
personal config e.g project-name.yml:
modules:
    enabled:
        - PhpBrowser
        - REST
    config:
      PhpBrowser:
        url: http://local.dev/v1/
      REST:
        url: http://local.dev/v1/
        depends: PhpBrowser

But it won't work because while build codeception looking for a PhpBrowser url config in functional.suite.yml
Any ideas?

@VoidWalker
Copy link

Still got this problem.
My acceptance.suite.yml:

class_name: AcceptanceTester
modules:
    enabled:
        - \Helper\Acceptance
        - \Helper\ISMWebDriver
    config:
        \Helper\ISMWebDriver:
            url: 'http://website.alpha.com/'
            browser: firefox
            window_size:1460x900

I have additional configuration _envs\beta.yml:

modules:
   config:
      \Helper\ISMWebDriver:
        url: 'https://website.beta.com/'

And configuration _envs\mobile.yml:

modules:
   config:
      \Helper\ISMWebDriver:
        window_size: 360x640

By running: php codecept.phar run acceptance --env beta,mobile I got my tests launched with mobile resolution but on http://website.alpha.com/.
with php codecept.phar run acceptance --env mobile,beta I got them on https://website.beta.com/ but with windows size from default config (1460x900)

What I see through debug, is that custom config files are merged with default config before merging together, that is why some configurations are overwritten

@alxvallejo
Copy link

@VoidWalker I believe you're still using old syntax as @oparoz already mentioned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants