How to stop Behat tests in the middle to run element inspector?

大憨熊 提交于 2019-12-02 08:51:16

You can use a breakpoint like this:

    /**
     * adds a breakpoints
     * stops the execution until you hit enter in the console
     * @Then /^breakpoint/
     */
    public function breakpoint()
    {
        fwrite(STDOUT, "\033[s    \033[93m[Breakpoint] Press \033[1;93m[RETURN]\033[0;93m to continue...\033[0m");
        while (fgets(STDIN, 1024) == '') {}
        fwrite(STDOUT, "\033[u");
        return;
    }

You can also declare it static an call it like ClassName::breakpoint();

As an alternative you could enable debugging in your IDE.

Barry

Use Behat step through extension which is a module that will allow you to easily to step through a certain feature without having to add specific code for it. This is the GitHub overview:

When debugging a particular scenario, use the --step-through flag at the CLI:

bin/behat --step-through features/my-failing-feature

After each step you will see the message

[Paused after "<step text>" - press enter to continue]

The Behat test suite will stay in this suspended state until a carriage return is received, to allow you to do any inspections necessary.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!