Override / Extend behat ProgressStepPrinter



我正在尝试创建一个扩展来识别进度输出步骤格式化程序。

目标只是将每个传递的方案步骤的.更改为*

behat

文档甚至没有提到创建自定义格式化程序的能力,但是我找到了一个 GitHub 存储库来执行此 behat-format-progress-fail

但是没有关于如何实现这一目标的清晰/简单的概述,我尝试复制和修改它们。 有没有一个简单的例子或明确的文档?

通过创建一个非常精简的ProgressStepPrinter.php版本,然后将其包含在autoload-dev中,composer.json优先使用它而不是来自Behat的版本。

进度步骤打印机.php

namespace BehatBehatOutputNodePrinterProgress;
use BehatBehatOutputNodePrinterHelperResultToStringConverter;
use BehatBehatOutputNodePrinterStepPrinter;
use BehatBehatTesterResultStepResult;
use BehatGherkinNodeScenarioLikeInterface as Scenario;
use BehatGherkinNodeStepNode;
use BehatTestworkOutputFormatter;
final class ProgressStepPrinter implements StepPrinter {
    private $resultConverter;
    public function __construct(ResultToStringConverter $resultConverter) {
        $this->resultConverter = $resultConverter;
    }
    public function printStep(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result) {
        //custom logic to print per step here
    }
}

作曲家.json

"autoload-dev": {
    "files": [
        "features/bootstrap/ProgressStepPrinter.php",
    ]
},

相关内容

  • 没有找到相关文章

最新更新