Skip to content

Instantly share code, notes, and snippets.

@karlseguin
karlseguin / test_runner.zig
Last active October 4, 2026 03:09
Custom Zig Test Runner, better ouput, timing display, and support for special "tests:beforeAll" and "tests:afterAll" tests
// This is for the Zig 0.17.
// Zig 0.16: https://gist.github.com/karlseguin/c6bea5b35e4e8d26af6f81c22cb5d76b/8e82642093d2f4341fb870d18d1fe5b213b2fd11
// Zig 0.15.2: https://gist.github.com/karlseguin/c6bea5b35e4e8d26af6f81c22cb5d76b/eb15512d6ae49663fa9df6c7a9725b20dab43edd
// Zig 0.14.1: https://gist.github.com/karlseguin/c6bea5b35e4e8d26af6f81c22cb5d76b/1f317ebc9cd09bc50fd5591d09c34255e15d1d85
// in your build.zig, you can specify a custom test runner:
// const tests = b.addTest(.{
// .root_module = $MODULE_BEING_TESTED,
// .test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },