Getting Started
AceUnit is a comfortable, test-discovery-based unit test framework for C, in the tradition of xUnit frameworks like JUnit. It targets developers writing firmware, drivers, operating systems, and other C programs — including in resource-constrained environments where most other frameworks don’t fit.
The idea
Section titled “The idea”Write plain C functions. Name them by convention. AceUnit finds and runs them — no annotations, no macro-heavy test-registration boilerplate.
#include "leapyear.h"#include <assert.h>
void testLeapYears(void) { assert(isLeapYear(0)); assert(isLeapYear(4)); assert(isLeapYear(400));}
void testNonLeapYears(void) { assert(!isLeapYear(1)); assert(!isLeapYear(100));}For each fixture (an object file with test cases), AceUnit looks for functions starting with:
beforeAll()— one-time setup (0–1)beforeEach()— setup per test case (0–1)test()— test cases (n)afterEach()— teardown per test case (0–1)afterAll()— one-time teardown (0–1)
See Core Concepts for the full discovery model, including custom prefixes.
Install it
Section titled “Install it”git clone https://github.com/christianhujer/aceunit.gitcd aceunitmake && sudo make installFull details, prerequisites, and platform notes: Installation.
Run your first test
Section titled “Run your first test”# Build your object files and test object filescc -I /usr/local/include -c *.c
# Run aceunit on the test object files to generate fixture sourceaceunit *_test.o >testcases.c
# Build the fixtures object filecc -I /usr/local/include -c testcases.c
# Link against a runner and runcc *.o -laceunit-abort./a.outAceUnit: 2 test cases, 2 successful, 0 failed.That’s the whole workflow. Next: Core Concepts for how discovery and runners work, or Mocking if you need to test code with side effects.