mirror of
https://github.com/c0ffeeartc/nim-sections
synced 2026-01-02 07:44:45 +00:00
No description
| tests | ||
| README.md | ||
| sections.nim | ||
| sections.nimble | ||
nim-sections
Provides Section macro and its Given, When, Then aliases. Nested Section blocks are converted into separate local branches of execution.
Inspired by C++ Catch Test Framework sections
Installation
nimble install sections
Example
Following
Section:
var s = ""
s &= "a"
Section:
s &= "b"
Section:
s &= "c"
echo s
Will be converted to
block:
var s = ""
s &= "a"
block:
s &= "b"
echo s
block:
var s = ""
s &= "a"
block:
s &= "c"
echo s
BDD style example
import unittest
import sections
test "For README.md":
Given:
var s:string = ""
s &= "a"
When:
s &= "b"
Then:
echo s
check s=="ab"
When:
s &= "c"
Then:
echo s
check s=="ac"
Tested with
- nim v 0.12
ToDo
- allow optional string argument
- current implementation works only when
Sectionblocks are in direct parent/child structures, deep nesting support is planned in future