Skip to main content

๐Ÿงช ZUnit

ZUnit is a unit testing framework for Zsh projects, maintained by the Z-Shell organization. It brings a concise @test syntax inspired by Bats, a rich assertion library, per-test @setup/@teardown hooks, TAP output, HTML reports, and a zunit init scaffolding command.

ZUnit: write @test blocks, run assertions, see results
Scaffold in seconds

Run zunit init --github-actions to generate a ready-to-use GitHub Actions workflow alongside the project scaffold โ€” CI from day one.

Documentationโ€‹

InstallationManual install, build from source, dependencies, and Zi integration.Install โ†’
Test Syntax@test, @setup/@teardown hooks, and helper functions.Learn syntax โ†’
AssertionsAll ~25 assertion functions with examples โ€” equals, contains, match, status.See assertions โ†’
Running TestsCLI usage, flags, TAP output, HTML reports, and filtering.Run tests โ†’
Configuration.zunit.yml key reference โ€” directories, TAP, HTML, time limits.Configure โ†’
CI IntegrationGitHub Actions and Travis CI workflow examples ready to drop in.Set up CI โ†’

Quick startโ€‹

# 1. Install
git clone https://github.com/z-shell/zunit.git
cd zunit && ./build.zsh && cp ./zunit /usr/local/bin

# 2. Scaffold a new project
cd my-project
zunit init

# 3. Write a test (tests/example.zunit)
# #!/usr/bin/env zunit
# @test 'addition works' {
# assert 2 equals 2
# }

# 4. Run
zunit