-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
added ability to use custom params from console in tests #3978
Conversation
} | ||
|
||
return $updatedParams; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Line indented incorrectly; expected 4 spaces, found 5
- Closing brace indented incorrectly; expected 4 spaces, found 5
src/Codeception/Configuration.php
Outdated
return $res; | ||
} | ||
|
||
public static function getParam($key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening brace should be on a new line
The implementation is pretty ok but we already have Params concept so it would be confusing to have them in different places. I think what you trying to achieve can be implemented using environment configuration and a custom helper: namespace Helper;
class Acceptance extends \Codeception\Module
{
protected $config = ['site_id' => null];
function enterSiteId($field)
{
$this->getModule('WebDriver')->fillField($field, $this->config['site_id']);
}
} this helper cna be configured in modules:
- WebDriver:
url: localhost
browser: chrome
- \Helper\Acceptance:
site_id: 1 and reconfigured with environments. Probably this way is a bit complcated than your params, but to me it looks cleaner and more reliable, as it moves the params to configuration. |
Thank you @DavertMik for fast review. Params concept that you currently have looks pretty solid and flexible. Also environment concept sounds great for this case. But there is some difference why neither is suitable for me. I will explain why.
Using this script we should test functionality on different sites (without updating test for specific site) Then lets imagine that we have 50 new sites per day. And we need to test all of them. Using current 'Params concept' or environment configuration with helpers, as you described above, require as to change (update) config file each time when we need to test new site. Am I right or I missed something. Using dynamic params directly from the console should:
Also some explanation in the issue #3974 |
We have Just put your site_id to Helper's config as shown above and change them on run |
this was cool PR, It's really problem to get user parameter from terminal in codeception now.... |
@Naktibalda yes, but there I've only red about params from .env/config (as I understand), not from command line (terminal). |
It is very easy to set environment variables in command line: URL=https://example.org ./vendor/bin/codecept run |
@Naktibalda thank you! |
This happens in the Cmder console emulator on Windows 10. Is there any other way to pass in an environment variable? |
Try |
|
It is small test plan for this.
In the test it should be available like following:
Also I updated file tests/_support/Helper/Acceptance.php like so
And I was able to use this:
It probably is better way how to use params in the tests, and if you have ideas how to do it better let me know.