b9b61cfe4a | ||
---|---|---|
.github/workflows | ||
tests | ||
.gitignore | ||
LICENSE.txt | ||
README.md | ||
config.nims | ||
nim.cfg | ||
nimdoc.out.css | ||
unittest2.html | ||
unittest2.nim | ||
unittest2.nimble |
README.md
Introduction
unittest2
is a library for writing unit tests for your Nim programs in the spirit of xUnit.
Features of unittest2
include:
- Parallel test execution
- Test separation with each test running in its own procedure
- Strict exception handling with support for exception tracking
unittest2
started as a pull request to evolve the unittest module in Nim and has since grown into a separate library.
Installing
nimble install unittest2
or add a dependency in your .nimble
file:
requires "unittest2"
Usage
See unittest2.html documentation generated by nim buildDocs
.
Create a file that contains your unit tests:
import unittest2
suite "Suites can be used to group tests":
test "A test":
check: 1 + 1 == 2
Compile and run the unit tests:
nim c -r test.nim
See the tests for more examples!
Porting code from unittest
- Replace
import unittest
withimport unittest2
unittest2
places each test in a separateproc
which changes the way templates inside tests are interpreted - some code changes may be necessary
Testing unittest2
# this calls a task in "config.nims"
nim test
License
MIT
Credits
-
original author: Zahary Karadjov
-
fork author: Ștefan Talpalaru <stefantalpalaru@yahoo.com>