Skip to main content

๐Ÿงช ZUnit

ZUnit is a unit testing framework for Zsh projects, maintained by the Z-Shell organization for the wider Zi/Z-Shell ecosystem.

It provides 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 for fast project setup.

Documentation sectionsโ€‹

SectionWhat it covers
InstallationManual install, dependencies, Zi integration
Test Syntax@test, @setup/@teardown, helper functions
AssertionsAll ~25 assertion functions with examples
Running TestsCLI usage, flags, output modes
Configuration.zunit.yml key reference
CI IntegrationGitHub Actions and Travis CI workflows

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
tip

Run zunit init --github-actions to generate a ready-to-use GitHub Actions workflow in .github/workflows/zunit.yml alongside the project scaffold.