Member-only story
An Architecture for Behaviour-Driven Development in Swift
This article will show you how we can do behaviour-driven development (BDD) in Swift — frictionless
Behavior-driven development (BDD) is a software development process that encourages collaboration among developers, quality assurance experts, and customer representatives in a software project.
It encourages teams to use conversation and concrete examples to formalize a shared understanding of how the application should behave. It emerged from test-driven development (TDD).
Behavior-driven development combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software development and management teams with shared tools and a shared process to collaborate on software development. [Wikipedia]
BDD is a variant of TDD where the goal of testing is to increase confidence for stakeholders through evidence, as Dan North — who coined the phrase “Behaviour-Driven Development” — puts it.
I think that in this context it makes more sense to talk about “specifications” rather than “tests”.
In this article, I will show how my architecture “Khipu” plays along nicely with the BDD tools Quick and Nimble.
Quick is a dedicated BDD framework. Nimble is a matcher framework, enabling tests that read like English sentences.
Let’s assume we build a point of sale (POS) app for taking and managing orders in a restaurant.
We meet with our product owner, and he shares his specifications (short: specs) with us.
- the app will be centred around
Tables
Tables
have a name and contain anOrder
- a order can be empty or contain a number of
Positions
Positions
contain anArticle
and a quantity
We prepare the specs in Quick using the following code:
import Quick
import Nimble
final class TableSpecifications:QuickSpec {
override class func spec() {
describe("Table") {
context("creation") {
it("has an identifier") {…