Book Image

Testing with F#

By : Mikael Lundin
Book Image

Testing with F#

By: Mikael Lundin

Overview of this book

Table of Contents (17 chapters)
Testing with F#
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up TickSpec


TickSpec is a lightweight Behavior-driven Design (BDD) framework for F#, influenced by SpecFlow from C#, which has its root in the Ruby testing framework, Cucumber. What is common between all these frameworks is that they implement a domain specific language called Gherkin, which is used to express the tests.

Let's start by adding TickSpec from the NuGet package manager to our application, as shown in the following screenshot:

Next up, we will write our first feature file. This file will specify what we expect of the feature and provide scenarios for us to verify. This file is written in Gherkin DSL to mimic the natural language.

Here is a feature file for Conway's Game of Life:

Feature: Conway's Game of Life

Scenario 1: Any live cell with fewer than two live neighbors dies, as if caused by under-population.
  Given a live cell
  And has 1 live neighbor
  When turn turns
  Then the cell dies

Scenario 2: Any live cell with two or three live neighbors lives on to the...