Cucumber Clojure
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
clojure
examples
.gitignore
README.md
pom.xml

README.md

Cucumber-Clojure

Maven Central

Cucumber-Clojure is a Cucumber implementation for Clojure.

This document is the reference for features that are specific to Cucumber-Clojure.

Please see the general reference for features that are common to all Cucumber implementations.

Step Definitions

Clojure step definitions are defined by using the provided macros. For example:

(use 'clojure-cukes.core)
(use 'clojure.test)

(Given #"^I have (\d+) big cukes in my belly$" [cukes]
       (println cukes))

You can use a DataTable to define a list:

Given I have a table with its keys in a header row:
  | id | name  | created-at    |
  | 55 | "foo" | 1293884100000 |
  | 56 | "bar" | 1293884100000 |

Simply declare the following:

(Given #"^I have a table with its keys in a header row:$" [data]
  (reset! most-recent (table->rows data)))

In this case, the DataTable is flattened to a vector of hashes

[{:id 55, :name "foo", :created-at 1293884100000}
{:id 56, :name "bar", :created-at 1293884100000}]

before invoking the step definition.

Installation

Maven

To use cucumber-jvm-clojure in your project, add the following dependency to your pom.xml:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-clojure</artifactId>
    <version>2.0.1</version>
    <scope>test</scope>
</dependency>

Running

There are several ways to run scenarios with Cucumber-Clojure:

  • lein-cucumber
  • JunitRunner

lein-cucumber

Leiningen uses clojure.test to run Cucumber. All you need is a single entry point:

(ns clojure-cukes.test.core
  (:use [clojure-cukes.core])
  (:use [clojure.test]))

(deftest run-cukes
  (. cucumber.api.cli.Main (main (into-array ["--plugin" "pretty" "--glue" "test/features/step_definitions" "test/features"]))))

You then need to add [com.siili/lein-cucumber "1.0.7"] to :plugins in your project.clj. This allows you to run all Cucumber features with lein cucumber

JUnitRunner

The instructions for the JUnitRunner can be found here

Miscellaneous

This module needs further documentation. The following examples show supported features:

Contributions are most welcome.