Skip to content

Adding some documentation for Cucumber-Clojure #864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion clojure/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,77 @@
# Cucumber-Clojure

This module needs documentation. The only documentation so far is the following examples:
Cucumber-Clojure is a Cucumber implementation for [Clojure](http://www.clojure.org/).

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

Please see the [general reference](https://cucumber.io/docs/reference) for features that are common to all Cucumber implementations.

## Step Definitions

Clojure step definitions are defined by using the provided [macros](http://clojure.org/macros). For example:

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

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

You can use a [DataTable](https://cucumber.io/docs/reference#data-table) 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:

```clojure
(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

```clojure
[{: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](http://leiningen.org/) uses [clojure.test](TODO) to run Cucumber. All you need is a single entry point:

```clojure
(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 `[lein-cucumber "1.0.2"]` 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](https://cucumber.io/docs/reference/jvm#junit-runner)

## Miscellaneous

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

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