Beautiful and efficient unit testing for Nim evolved from the standard library unittest module
Go to file
Jacek Sieka 133d86a58e
compat fixes
evaluate name once only
2021-04-27 20:29:59 +02:00
.github/workflows CI setup 2021-03-19 23:22:19 +01:00
tests fix stand-alone "check" for <Nim-1.4.0 2021-03-22 20:01:37 +01:00
.gitignore initial commit - from https://github.com/nim-lang/Nim/pull/9724 2019-05-19 23:11:17 +02:00
LICENSE.txt initial commit - from https://github.com/nim-lang/Nim/pull/9724 2019-05-19 23:11:17 +02:00
README.md CI setup 2021-03-19 23:22:19 +01:00
config.nims CI setup 2021-03-19 23:22:19 +01:00
nim.cfg initial commit - from https://github.com/nim-lang/Nim/pull/9724 2019-05-19 23:11:17 +02:00
unittest2.html -d:nimtestParallelDisabled 2019-05-29 16:33:25 +02:00
unittest2.nim compat fixes 2021-04-27 20:29:59 +02:00
unittest2.nimble CI setup 2021-03-19 23:22:19 +01:00

README.md

Introduction

unittest2 is a library for writing unit tests for your Nim programs in the spirit of xUnit.

Features of unittest2 include:

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 doc unittest2.nim.

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 with import unittest2
  • unittest2 places each test in a separate proc 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