Beautiful and efficient unit testing for Nim evolved from the standard library unittest module
Go to file
Tanguy fe3650ceea
fix for 1.6
2023-02-10 11:13:45 +01:00
.github/workflows move -d:nimRawSetjmp to nim.cfg (#14) 2022-07-25 22:06:27 +03:00
tests fix stand-alone "check" for <Nim-1.4.0 2021-03-22 20:01:37 +01:00
.gitignore Update gitignore (#15) 2022-07-12 23:31:12 +03:00
LICENSE.txt initial commit - from https://github.com/nim-lang/Nim/pull/9724 2019-05-19 23:11:17 +02:00
README.md Generate documentation in CI (#13) 2022-05-12 18:23:28 +03:00
config.nims CI: test with Nim-1.6 and C++ (#11) 2022-01-14 04:15:45 +01:00
nim.cfg move -d:nimRawSetjmp to nim.cfg (#14) 2022-07-25 22:06:27 +03:00
nimble.lock Update gitignore (#15) 2022-07-12 23:31:12 +03:00
nimdoc.out.css change define prefix and update docs (#7) 2021-04-29 14:20:03 +02:00
unittest2.nim fix for 1.6 2023-02-10 11:13:45 +01:00
unittest2.nimble Bump version 2023-01-04 15:52:46 +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 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 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