Search code examples
yamlbehat

How to define multiple formatters in behat.yml?


The Behat command line configuration options support the definition of multiple formatters: http://docs.behat.org/guides/6.cli.html#format-options.

I want to define multiple formatters in a YAML configuration file instead, but I suck at YAML and don't seem able to get the syntax correct.

So far I have:

default:
  - formatter:
      name: junit
      parameters: 
        output_path: xml
  - formatter:  
      name: pretty
      parameters: ~

  extensions:
    Behat\MinkExtension\Extension:
      base_url:  'http://myurl.com'
      javascript_session: sahi
      browser_name: chrome
      goutte: ~
      sahi: ~

Which gives the error:

You cannot define a mapping item when in a sequence

I've also tried this defining the elements as a list within a single formatter, but says that the formatter cannot contain numbered indexes.


Solution

  • In Behat 3.x use:

    build:
      formatters:
        progress:
        junit: [./build/logs/behat]
        html: [./build/behat/index.html]
    

    In Behat 2.x, use a comma to separate the formatter names just like in the command line:

    default:
      formatter:
        name: progress,junit,html
        parameters:
          output_path: ,./build/logs/behat,./build/behat/index.html