NixTest: a tiny unit testing framework written in pure nix

Hi all,

As part of the work we’ve been doing with devbox, we needed a unit testing framework to test some of our nix code. Unfortunately we had some use cases where we did not want to introduce a dependency on nixpkgs (and therefore we couldn’t use runTests).

So we ended up writing NixTest: a tiny unit testing framework, written in pure nix. It’s completely self-contained and has no external dependencies (not even to nixpkgs).

Sharing it with the community in case anyone else has a need for a similar unit testing framework.

15 Likes

There are projects which just expose lib https://github.com/nix-community/nixpkgs.lib/blob/367c0e1086a4eb4502b24d872cea2c7acdd557f4/lib/debug.nix#L236

1 Like

Notably, there’s also namaka with (in my experience) unprecedented testing productivity levels.

2 Likes