【问题标题】:Codeception doesn't override parameter in GitlabCodeception 不会覆盖 Gitlab 中的参数
【发布时间】:2022-08-18 16:29:59
【问题描述】:

我有这个问题

*********** codeception.yml ***************

paths:
    tests: tests

    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs

actor_suffix: Tester

#amount customer per product

amountPerProduct: 1

wishCountry: 1

wishProduct: 0

我正在使用这样的参数:

$countryIndex = Configuration::config()[\'wishCountry\'];

但在控制台上我这样调用测试:

codecept run tests/acceptance/ChangeCest.php --env chrome --xml --html -o \"wishProduct:55\"

我收到此错误:

enter image description here

问题: 如何在 Gitlab 中覆盖这个配置?

谢谢

    标签: gitlab codeception


    【解决方案1】:

    不完全确定这是否能解决您的问题,但对于 Codeception v5(也是我当前的本地版本 v4.2.1),该选项以: 展开,即附加空格。我注意到在您的屏幕截图中,异常确实显示了键/值之间没有空格,但您没有指定您使用的是哪个版本的 Codeception。

    来自Config.php

    foreach ($configOptions as $option) {
        $keys = explode(': ', $option);
        //                ^ notice the space here
        if (count($keys) < 2) {
            throw new \InvalidArgumentException('--override should have config passed as "key: value"');
        }
    

    https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Command/Shared/ConfigTrait.php

    【讨论】:

    • 我正在使用 V4.1.21
    • @ctine我的答案对v4.1仍然有效,您是否尝试过在键和值之间添加空间来运行?即-o "wishProduct: 55"
    【解决方案2】:

    我找到了我的问题的答案。 我将参数存储在一个新文件 params.yml

    参数.yml

    parameters:
        WISH_PRODUCT: 55
    

    密码接收.yml

    params:
        - params.yml
    

    验收套件.yml

    config:
        custom_params:
            wishProduct: %WISH_PRODUCT%
    

    AcceptanceTester.php

    所以在 AcceptanceTester 我可以读取这样的值

    $custom_params = Configuration::suiteSettings('acceptance', Configuration::config())['modules']['custom_params'];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-21
      相关资源
      最近更新 更多