The Art of Runnable Specification
The thing is NOBODY reads the fucking paperwork afterwards
Let's not even talk about maintaining it
Test Automation you'll actually like
Simple. Collaborative. Adaptable.
Terminology
Specification
# Specification name
Specification name
==================
Or
Describes a feature
Scenario
Scenario name
-------------
## Scenario name
Or
Describes a acceptance criteria
Tags
Specification Level
===================
Tags: login, admin
Scenario Level
--------------
Tags: login-success, admin
Used to group runnable documentation
Concept
Concept Heading
===============
# Concept Heading
Or
Our reusable documentation
Steps
* Step Name
Our core elements
Parameters
* Check "product" exists
* Check <product> exists
<Dynamic Arg>
Steps arguments
"Static Arg"
* Step that takes a table
| id | name |
|-----|---------|
| 123 | John |
| 456 | Mcclain |
|Table Parameter|
Special Parameters
<prefix:value>
* Check if <file:/work/content.txt> is visible
file
Used as:
* Check if the users exist <table:/Users/john/work/users.csv>
table
Comments
Im a comment!!!
Comment has no syntax. Any normal line of text is treated as comment.
Markdown
Java
C#
Example
Markdown
Specification Heading
=====================
This is an executable specification file. This file follows markdown syntax.
Every heading in this file denotes a scenario. Every bulleted point denotes a step.
To execute this specification, run
gauge specs
* Vowels in English language are "aeiou".
Vowel counts in single word
---------------------------
tags: single word
* The word "gauge" has "3" vowels.
Vowel counts in multiple word
-----------------------------
This is the second scenario in this specification
Here's a step that takes a table
* Almost all words have vowels
|Word |Vowel Count|
|------|-----------|
|Gauge |3 |
|Mingle|2 |
|Snap |1 |
|GoCD |1 |
|Rhythm|0 |
Java
public class StepImplementation {
private HashSet<Character> vowels;
@Step("Vowels in English language are <vowelString>.")
public void setLanguageVowels(String vowelString) {
vowels = new HashSet<>();
for (char ch : vowelString.toCharArray()) {
vowels.add(ch);
}
}
@Step("The word <word> has <expectedCount> vowels.")
public void verifyVowelsCountInWord(String word, int expectedCount) {
int actualCount = countVowels(word);
assertEquals(expectedCount, actualCount);
}
@Step("Almost all words have vowels <wordsTable>")
public void verifyVowelsCountInMultipleWords(Table wordsTable) {
for (TableRow row : wordsTable.getTableRows()) {
String word = row.getCell("Word");
int expectedCount = Integer.parseInt(row.getCell("Vowel Count"));
int actualCount = countVowels(word);
assertEquals(expectedCount, actualCount);
}
}
}
What we get
We'll do it live
Just Code It
Thanks!
The Art of Runnable Specification
By Boaz Berman
The Art of Runnable Specification
Why runnable specifications frameworks will be the next big thing. Gauge as an example.
- 218