22<img src =" logo.png " height =" 128 " width =" 128 " />
33</p >
44
5- # Sprout: BDD Testing for F#
5+ # 🌱 Sprout: BDD Testing for F#
66
7- > * Write your tests like your thoughts. Sprout is a lightweight F# test DSL with a clean, composable structure built on computation expressions.*
7+ > * Sprout is a lightweight F# test DSL with a clean, composable structure built on computation expressions. This allows your test suites to grow almost organically - i.e. sprout .*
88
99[ ![ Build] ( https://github.com/dlidstrom/Sprout/actions/workflows/build.yml/badge.svg )] ( https://github.com/dlidstrom/Sprout/actions/workflows/build.yml )
1010
1111## ✅ Features
1212
1313* Minimalist & expressive BDD-style syntax
14- * Nestable ` describe ` blocks
14+ * Nestable ` describe ` blocks for organizing tests to any depth or complexity
1515* Computation expressions for ` it ` , ` beforeEach ` , ` afterEach `
16- * Pending tests supported by omission
17- * Logging for improved tracing
16+ * Pending tests support
17+ * Logging for improved traceability
18+ * Built-in assertions: ` shouldEqual ` , ` shouldBeTrue ` , ` shouldBeFalse `
19+ * These go along way to making your tests readable and expressive due to the
20+ descriptive text that goes along with each ` describe ` block and ` it ` test
21+ case. Note that you may use any exception-based constraints library if
22+ desired ([ FsUnit.Light] ( https://github.com/Lanayx/FsUnit.Light ) works
23+ beautifully).
24+ * Support for parameterized tests using normal F# loops within ` describe ` blocks
1825* Pluggable reporters (console, silent, TAP, JSON)
19- * Built for F# — no extra syntax or matchers
26+ * Built for F# — simple and idiomatic
27+ * No need for ` <| ` or functions wrapped in parentheses!
28+ * No need for complex combination of attributes - it's just all F# code!
29+
30+ Sprout provides a clean API for structuring tests. There are a minimum of
31+ abstractions. ` describe ` blocks may be nested to any suitable depth. It is all
32+ just a matter of * composing* the building blocks. Just like you would expect
33+ coming from a functional programming background.
2034
2135---
2236
2640dotnet add package Sprout
2741```
2842
43+ > Sprout is currently only available from [ GitHub Packages] ( https://github.com/dlidstrom/Sprout/pkgs/nuget/Sprout ) .
44+
2945---
3046
3147### 🧪 Example Test
@@ -100,6 +116,31 @@ Output:
100116
101117---
102118
119+ ### 📦 Blocks
120+
121+ | Name | Usage | Supported Expressions |
122+ | -| -| -|
123+ | ` describe ` | Declarative | ` it ` , ` beforeEach ` , ` afterEach ` , ` it ` , ` Info ` , ` Debug ` |
124+ | ` it ` | Imperative | Any F# expressions, but typically exception-based assertions |
125+ | ` beforeEach ` , ` afterEach ` | Imperative | Hook functions that run before and after test cases, respectively |
126+
127+ * ** ` describe ` ** - used to define a test suite, or a group of tests. Use the
128+ descriptive text to create descriptive sentences of expected behaviour.
129+ * ** ` it ` ** - used to define test assertions, along with a descriptive text to
130+ define the expected behaviour
131+ * ** ` beforeEach ` /` afterEach ` ** - hook functions that run before and after test
132+ cases, respectively
133+ * ** ` pending ` ** - used to denote a pending test case
134+ * ** ` info ` /` debug ` ** - tracing functions that may be used inside hook functions
135+ and ` it ` blocks
136+ * ** ` Info ` /` Debug ` ** - constructor functions that provide tracing inside
137+ ` describe ` blocks
138+
139+ > Tracing works slightly different in ` describe ` blocks due to limitations of me
140+ > (most likely) and/or F# computation expressions.
141+
142+ ---
143+
103144### 🧩 Extending Sprout
104145
105146You can plug in your own reporter:
@@ -115,29 +156,20 @@ type MyCustomReporter() =
115156 member _.End(testResults) = ...
116157```
117158
118- ---
159+ Use it like this:
119160
120- ### 🎯 Philosophy
121-
122- Sprout is built on:
123-
124- * ** F# idioms** — computation expressions
125- * ** Extensibility** — pluggable reporters and hooks
126-
127- ### Blocks
128-
129- | Name | Usage | Supported Expressions |
130- | -| -| -|
131- ` describe ` | Declarative | ` it ` , ` beforeEach ` , ` afterEach ` , ` it ` , ` Info ` , ` Debug ` |
132- | ` it ` | Imperative | Any F# expressions, but typically exception-based assertions |
161+ ``` fsharp
162+ let reporter = MyCustomReporter()
163+ let results = runTestSuiteWithContext reporter suite
164+ ```
133165
134166---
135167
136168### 📦 Package Info
137169
138170| | |
139171| ------- | --------------------------- |
140- | NuGet | ` Sprout ` |
172+ | NuGet | [ ` Sprout ` ] ( https://github.com/dlidstrom/Sprout/pkgs/nuget/Sprout ) |
141173| Target | .NET Standard 2.0. |
142174| License | MIT |
143175| Author | Daniel Lidström |
0 commit comments