Search code examples
phpclojurecucumberbehat

Clojure version of Behat?


In the past, for PHP project's, I have used Behat in conjunction with the api-extension to write component level tests. Behat shares a common philosophies with cucumber. I would therefore like to known if there is an equivalent api extension I could use for cucumber in a Clojure project?

This is the kind of test I would like to create:

Feature: MyFeature
Scenario: do somthing
      Given the request body is:
      """
      {
        "key": "val"
      }
      """
      And the "Content-Type" request header is "application/json"
      When I request "/route" using HTTP POST
      Then the response code is 200
      Then the response body contains JSON:
      """
      {
          "meta": {
              "status": "@variableType(string)"
          },
          "data": {
              "key": "@variableType(integer)"
          }
      }
      """

Solution

  • So I think what you are looking for is a BDD framework that implements Gherkin in some way (as Behat does). The Cucumber framework, which you mention, does just that, and there exists a Clojure implementation which you can see here: https://github.com/cucumber/cucumber-jvm-clojure

    I think this is basically what you are looking for.