Back to course

Unit Testing

Full Course: Zig Programming From Zero to Hero

Testing in Zig

Zig has built-in support for unit testing. You define tests using the test keyword.

zig test "basic addition" { try std.testing.expect(1 + 1 == 2); }

Run tests using zig test filename.zig. The compiler will run your tests and report any failures.