An example on running Behat from Jenkins

Time for a very short article. I just want to share a little trick that helped me run my Behat testsuite from a Jenkins build.
Most of the articles that I found on Google did not really cut to the chase. Here it is:

1) Create an “execute shell” build step that executes Behat, and outputs it’s results to a jUnit format:

2) Create a post-build “Publish JUnit test result report” action that reads the build/ directory for the jUnit files.

That’s it! If you want to know more about the formatting features that Behat provides, click here.

Screen Shot 2013-05-10 at 00.47.42

Share this post:
    • Vishal Khialani

      I tried it but it failed on mine

      [BehatGherkinExceptionParserException]

      Expected Examples token, but got Text on line: 12 in file: /home/vishal/Dropbox/sites/drupal_test/behat/vendor/behat/gherkin/tests/Behat/Gherkin/Fixtures/features/ru_division.feature

      not sure what went wrong. Any ideas ?

      • TddDoctor

        check in your ru_division.feature file on line 12;

        you either have a typo example Give instead of Given a wrong URL in one of your scenario or

    • Stefan van Gastel

      Nice short example. Bedankt ;)

    • Imre Bertalan

      when I add the post-build parameter you’ve told, I get the following error:
      ‘build/*.xml’ doesn’t match anything: even ‘build’ doesn’t exist

      Any idea why?

      • Perhaps the “build” directory does not exist. Try creating it manually, does that help?

        • Imre Bertalan

          Sorry, my bad. :)

    • Sidigum Channel

      Hi,
      I am unable to setup Behat in Jenkins.
      Can you help me out.