Snaipe/Criterion logo

Snaipe/Criterion

Free

A cross-platform C and C++ unit testing framework for the 21st century

FreeFree tier
Type
Open Source

About Snaipe/Criterion

Criterion is a dead-simple, yet extensible, C and C++ unit testing framework that follows the KISS principle. It is C99 and C++11 compatible and requires minimal boilerplate: tests are automatically registered when declared, and a default entry point is provided, so no need to write a main() unless special handling is needed. The framework implements a xUnit structure, runs tests in isolated processes to report crashes and signals, and provides a unified interface between C and C++. It supports parameterized tests and theories, real-time progress via report hooks, TAP output format, and runs on Linux, FreeBSD, macOS, and Windows (MinGW GCC and Visual Studio 2015+). Built with boxfort, debugbreak, libffi, klib, libcsptr, nanomsg, and nanopb.

Key Features

Tests automatically registered when declared
Default entry point provided — no need to write a main()
Tests isolated in their own process (crashes and signals reported)
Unified interface between C and C++
Supports parameterized tests and theories
Real-time progress and statistics via report hooks
TAP output format supported
Cross-platform: Linux, FreeBSD, macOS, Windows (MinGW GCC and Visual Studio 2015+)
C99 and C++11 compatible
xUnit framework structure

Pros & Cons

Pros
  • Minimal boilerplate: test registration is automatic
  • No need to manually define a main() entry point
  • Test isolation ensures crashes don't break the entire suite
  • Supports both C and C++ with a single include
  • Rich feature set including parameterized tests and TAP output
  • Cross-platform with package availability on major systems
  • Actively maintained with regular releases
Cons
  • C and C++ only; not applicable to other languages
  • Requires compilation of test code (like most unit testing frameworks)
  • Limited to xUnit style (may not suit all testing philosophies)
  • Documentation is external (ReadTheDocs) and may not cover advanced usage deeply

Best For

Unit testing C and C++ libraries and applicationsCross-platform test automation in CI/CD pipelinesTesting code that may involve signals or crashesParameterized testing for data-driven test casesWriting minimal-boilerplate test suites for open-source projects