Skip to content

Commit 04a7eef

Browse files
committed
initial version
1 parent 1e9d1d5 commit 04a7eef

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

clojure/README.md

+72-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,77 @@
11
# Cucumber-Clojure
22

3-
This module needs documentation. The only documentation so far is the following examples:
3+
Cucumber-Clojure is a Cucumber implementation for [Clojure](http://www.clojure.org/).
4+
5+
This document is the reference for features that are specific to Cucumber-Clojure.
6+
7+
Please see the [general reference](https://cucumber.io/docs/reference) for features that are common to all Cucumber implementations.
8+
9+
## Step Definitions
10+
11+
Clojure step definitions are defined by using the provided [macros](http://clojure.org/macros). For example:
12+
13+
```clojure
14+
(use 'clojure-cukes.core)
15+
(use 'clojure.test)
16+
17+
(Given #"^I have (\d+) big cukes in my belly$" [cukes]
18+
(println cukes))
19+
```
20+
21+
You can use a [DataTable](https://cucumber.io/docs/reference#data-table) to define a list:
22+
23+
```
24+
Given I have a table with its keys in a header row:
25+
| id | name | created-at |
26+
| 55 | "foo" | 1293884100000 |
27+
| 56 | "bar" | 1293884100000 |
28+
```
29+
30+
Simply declare the following:
31+
32+
```clojure
33+
(Given #"^I have a table with its keys in a header row:$" [data]
34+
(reset! most-recent (table->rows data)))
35+
```
36+
37+
In this case, the DataTable is flattened to a vector of hashes
38+
39+
```clojure
40+
[{:id 55, :name "foo", :created-at 1293884100000}
41+
{:id 56, :name "bar", :created-at 1293884100000}]
42+
```
43+
44+
before invoking the step definition.
45+
46+
## Running
47+
48+
There are several ways to run scenarios with Cucumber-Clojure:
49+
* lein-cucumber
50+
* JunitRunner
51+
52+
### lein-cucumber
53+
54+
[Leiningen](http://leiningen.org/) uses [clojure.test](TODO) to run Cucumber. All you need is a single entry point:
55+
56+
```clojure
57+
(ns clojure-cukes.test.core
58+
(:use [clojure-cukes.core])
59+
(:use [clojure.test]))
60+
61+
(deftest run-cukes
62+
(. cucumber.api.cli.Main (main (into-array ["--plugin" "pretty" "--glue" "test/features/step_definitions" "test/features"]))))
63+
64+
```
65+
66+
You then need to add `[lein-cucumber "1.0.2"]` to `:plugins` in your project.clj. This allows you to run all Cucumber features with `lein cucumber`
67+
68+
### JUnitRunner
69+
70+
The instructions for the JUnitRunner can be found [here](https://cucumber.io/docs/reference/jvm#junit-runner)
71+
72+
## Miscellaneous
73+
74+
This module needs further documentation. The following examples show supported features:
475

576
* [examples/clojure_cukes](https://github.com/cucumber/cucumber-jvm/tree/master/examples/clojure_cukes)
677
* [clojure/src/test/resources/cucumber/runtime/clojure](https://github.com/cucumber/cucumber-jvm/tree/master/clojure/src/test/resources/cucumber/runtime/clojure).

0 commit comments

Comments
 (0)