Skip to content

gphilipp/cucumber-jvm-clojure

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cucumber-Clojure

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.

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.

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 70.6%
  • Java 19.1%
  • Gherkin 10.3%