3

我尝试在我的 behat.yml 中并将模板放在我的 /support 目录中,但没有帮助。

    default:
      formatter:
        name:  html
        parameters:
          template_path: html.tpl

有任何想法吗?

4

1 回答 1

3

您可以从现有扩展自定义类HtmlFormatter以显式设置您的 html 模板。

PHP

namespace Behat\Behat\Formatter;
use Behat\Behat\Formatter\HtmlFormatter;

class MyHtmlFormatter extends HtmlFormatter {

    /**
     * The HTML template to use for formatting.
     * @return string
     */
    protected function getHtmlTemplate()
    {
        return '
          <div id="behat">
            {{content}}
          </div>
        ';
    }

    // You can override any other methods of HtmlFormatter that you want
    // to define custom behavior.
}

然后更新您的behat.yml文件以指向您的自定义类。

behat.yml(可选 - 仅当您不在--formatbehat 命令行中使用时才需要。)

default:
    formatter:
        name: Behat\Behat\Formatter\MyHtmlFormatter

贝哈特

最后,behat使用以下命令运行:

behat --out out.html your_feature.feature

如果要直接指定此格式化程序,请执行以下操作:

behat --format Behat\\Behat\\Formatter\\MyHtmlFormatter --out o.html

请注意,您需要\\正确发送类名。

于 2012-11-12T17:41:13.200 回答