justblackbird / codeception-config-module
从配置中加载参数到Codeception场景。
1.0.0
2016-11-05 11:12 UTC
Requires
- php: >=5.4.0 <8.0
Requires (Dev)
- codeception/codeception: ^2.2
- phpunit/phpunit: ^4.8
- squizlabs/php_codesniffer: ^2.7
This package is not auto-updated.
Last update: 2024-09-24 08:29:34 UTC
README
从Codeception配置中加载参数并传递给测试场景。
安装
将包添加到你的composer.json文件中
{ "require-dev": { "codeception/codeception": "^2.2", "justblackbird/codeception-config-module": "^1.0" } }
更新依赖关系以下载包
php composer.phar update
然后在你的acceptance.suite.yml
配置中启用模块,以及任何你想传递给测试场景的配置
class_name: AcceptanceTester modules: enabled: - Config: # You can use any configs in the list. There no limitations on # the parameters names. foo: 'Foo value' bar: 'Bar value' cookies_price: '$3.50' - PhpBrowser: url: 'https://example.com/' - \Helper\Acceptance
此外,你需要重新构建你的演员类
php codecept.phar build
使用方法
首先,你需要在Codeception配置中指定你想要传递到测试场景的参数。假设我们需要使用username
和password
来测试登录过程。acceptance.suite.yml
文件可能如下所示
class_name: AcceptanceTester modules: enabled: - Config: username: 'john_doe' password: 'foobarbaz123' - PhpBrowser: url: 'https://example.com/' - \Helper\Acceptance
在配置文件中设置参数后,你可以在接受场景中使用它们。以下是一个示例
<?php $I = new AcceptanceTester($scenarion); $I->fillField('Username', $I->grabFromConfig('username')); $I->fillField('Password', $I->grabFromConfig('password')); $I->click('Log in'); $I->see('You\'ve just logged in!');
API
grabFromConfig($parameter)
从模块配置中检索指定的参数。如果没有指定参数,则抛出异常。
许可证
MIT (c) Dmitriy Simushev