There should be a way to pass environment variables into our global and suite configs. That's useful to pass credentials using them. I'm sure this is important feature and should be landed in 2.2
But I have some doubts about syntax on using variables:
password: {{PASSWORD}}
# vs
password: %PASSWORD% #Symfony-style
# vs
password: $PASSWORD # php style
# vs you name it...
what would you prefer?
I like the Symfony style best.
Symfony-style is for parameters, not for environment variables.
What symfony do to pass environment variables to symfony is to convert SYMFONY__MY_ENV_VAR to parameter my.env.var. May be we should take the same aproach ...
@raistlin
There is a related PR https://github.com/Codeception/Codeception/pull/1692
But I don't like its implementation, it is related only to symfony and probably is useless for others.
What symfony do to pass environment variables to symfony is to convert SYMFONY__MY_ENV_VAR to parameter my.env.var. May be we should take the same aproach ...
Could you provide a code sample. How that configuration may look like?
Symfony does it here: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Kernel.php#L521
So we can export env vars with export SYMFONY__MY_VARIABLE and Symfony will convert to parameters accessible from the application.
But now I think you don't want to apply same behaviour. May be you want to configure on codeception.yml what environment variables will exist when just to launch kernel framework?
Symfony-style is for parameters, not for environment variables.
What symfony do to pass environment variables to symfony is to convert SYMFONY__MY_ENV_VAR to parameter my.env.var. May be we should take the same aproach ...
Ok, looks like I got the point now. But I don't like to prefix all environment vars with CODECEPTION. Also I don't see real point why parameters defined in parameters.yml should be different from environment vars.
I think we should have a new configuration option:
params:
- env # loading from env
- params.yml # loading from yml file
by changing order you can override parameters. And add more providers...
The current implementation only allows for parameters to be used inside suite config files. The codeception config should also be a candidate, many people put all configs in the codeception config and then only enable the right modules in the suites (and possibly override a restrained amount of settings)
Added a PR regarding the preceding comment
https://github.com/Codeception/Codeception/pull/3255
Hey there, I have a question about environments. For now, I set my env in acceptance.suite.yml like this:
env:
stage:
modules:
config:
WebDriver:
url: http://stage.site.ro
live:
modules:
config:
WebDriver:
url: https://site.ro/
For each environment I need a corresponding file which contains, for example, different log in credentials that I will use in acceptance tests. (the template of these files will be the same, it will only differ the values of the variables. eg: LOGIN_EMAIL = value)
Can I load these files into acceptance.suite.yml? Or, is there any other way to pass a certain file to be used only by one environment? +How can I get the values from those files into my code/tests?
I hope I've made myself clear... can you please help?
Most helpful comment
Hey there, I have a question about environments. For now, I set my env in acceptance.suite.yml like this:
For each environment I need a corresponding file which contains, for example, different log in credentials that I will use in acceptance tests. (the template of these files will be the same, it will only differ the values of the variables. eg: LOGIN_EMAIL = value)
Can I load these files into acceptance.suite.yml? Or, is there any other way to pass a certain file to be used only by one environment? +How can I get the values from those files into my code/tests?
I hope I've made myself clear... can you please help?