unittest2

unittest fork focused on parallel test execution


Keywords
tests, unit-testing
License
MIT
Install
nimble install unittest2

Documentation

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