Giter VIP home page Giter VIP logo

jukebox's Introduction

Jukebox - A Clojure BDD Testing Library

Clojars Project

This is a simple library that hooks clojure into BDD frameworks such as cucumber.

Here's an example feature.

Feature: Belly

  Scenario: 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:

(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.)

(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.

(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:

(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 the jukebox aliases:

჻ 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] <features dir>

Options:
  -h, --help        Additional cucumber help.
  -t, --tags <tags> Only run scenarios with matching tags.

჻ aka describe :jukebox/snippets
Generate code snippets for scenarios.

Usage: clj -A:jukebox/snippets <features dir>

License

Copyright © 2019 Funding Circle

Distributed under the BSD 3-Clause License.

jukebox's People

Contributors

abtiddle avatar andreacrotti avatar bliof-fc avatar edwardsjones avatar katyaessina95 avatar markjhollands avatar matthias-margush avatar sgerrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.