Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fundingcircle/jukebox
All the best songs. Discuss in #jukebox on Clojurians Slack.
https://github.com/fundingcircle/jukebox
acceptance-tests bdd-framework clojure-library gherkin
Last synced: 3 days ago
JSON representation
All the best songs. Discuss in #jukebox on Clojurians Slack.
- Host: GitHub
- URL: https://github.com/fundingcircle/jukebox
- Owner: FundingCircle
- License: bsd-3-clause
- Created: 2019-01-04T23:19:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-18T08:13:56.000Z (3 months ago)
- Last Synced: 2024-12-11T18:54:02.432Z (11 days ago)
- Topics: acceptance-tests, bdd-framework, clojure-library, gherkin
- Language: Clojure
- Homepage:
- Size: 196 KB
- Stars: 18
- Watchers: 61
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Jukebox - A Clojure BDD Testing Library
[![Clojars Project](https://img.shields.io/clojars/v/fundingcircle/jukebox.svg)](https://clojars.org/fundingcircle/jukebox)
This is a simple library that hooks clojure into BDD frameworks such
as cucumber.Here's an example feature.
```
Feature: BellyScenario: a few cukes
Given I have 42 cukes in my belly
When I wait 2 hours
Then my belly should growl
```Clojure functions can be mapped to each step by tagging it with `:scene/step`:
```clojure
(defn i-have-cukes-in-my-belly
"Returns an updated `board`."
{:scene/step "I have {int} cukes in my belly"}
[board cukes]
;; Write code here that turns the phrase above into concrete actions
(throw (cucumber.api.PendingException.)))(defn i-wait-hours
"Returns an updated `board`."
{:scene/step "I wait {int} hours"}
[board hours]
;; Write code here that turns the phrase above into concrete actions
(throw (cucumber.api.PendingException.)))(defn my-belly-should-growl
"Returns an updated `board`."
{:scene/step "my belly should growl"}
[board]
;; Write code here that turns the phrase above into concrete actions
(throw (cucumber.api.PendingException.)))
```Functions with multiple arities can also be tagged. (Clojure allows metadata to be placed after the function body. This example uses that style.)
```clojure
(defn i-wait-hours
"Returns an updated `board`."
([board]
;; Write code here that turns the phrase above into concrete actions
(throw (cucumber.api.PendingException.)))
([board hours]
;; Write code here that turns the phrase above into concrete actions
(throw (cucumber.api.PendingException.))){:scene/steps ["It felt like forever"
"I wait {int} hours"]})
```Functions can be registered to run before or after a scenario by
tagging them with `:scene/before` or `:scene/after` (or both).
A list of tags can also be provided.
```clojure
(defn ^:scene/before setup
"Initializes systems under test."
{:scene/tags ["tag-a" "tag-b"]}
[board scenario])(defn ^:scene/after teardown
"Tears down the test system."
[board scenario])
```A function can be registered to be run before or after each step by
tagging it with `:scene/before-step` or `:scene/after-step`:
```clojure
(defn ^:scene/before-step before-step
"Runs before each scenario step."
[board])(defn ^:scene/after-step after-step
"Runs after each scenario step."
[board])
```## Usage
[Tap](https://github.com/matthias-margush/aka) the jukebox aliases:
``` shell
჻ aka tap -o deps.edn :jukebox https://raw.githubusercontent.com/FundingCircle/jukebox/master/aliases.edn
Tapped :jukebox/cucumber
Tapped :jukebox/snippets჻ aka describe :jukebox/
:jukebox/cucumber - Execute scenarios with the cucumber runner.
:jukebox/snippets - Generate code snippets for scenarios.჻ aka describe :jukebox/cucumber
Execute scenarios with the cucumber runner.Usage: clj -A:jukebox/cucumber [options]
Options:
-h, --help Additional cucumber help.
-t, --tags Only run scenarios with matching tags.჻ aka describe :jukebox/snippets
Generate code snippets for scenarios.Usage: clj -A:jukebox/snippets
```## License
Copyright © 2019 Funding Circle
Distributed under the BSD 3-Clause License.