NTest is a lightweight, two-header unit testing framework for C++17 projects.
Minimal, dependency-free, and CI-friendly.
- Dual-header design
- Automatic test registration
- Fatal (
REQUIRE) and non-fatal (EXPECT) assertions - Expected-failure support (for framework self-testing)
- Robust exception handling (std + non-std)
- ANSI-colored terminal output (no external dependencies)
- Cross-platform: Linux + Windows (MinGW-tested)
NTest follows a simple model:
| Macro | Behavior |
|---|---|
REQUIRE |
Fails the current test immediately (fatal) |
ASSERT_* |
Alias for REQUIRE (backward compatibility) |
EXPECT |
Logs failure but continues test execution |
All exceptions thrown inside tests are caught by the runner. Failures never stop the test suite.
#define NTEST_MAIN
#include "NTest.h"
TEST(MyFirstTest) {
REQUIRE(1 + 1 == 2);
EXPECT(false); // logs but continues
}Compile and run:
g++ -std=c++17 my_tests.cpp -o tests
./testsNTest supports marking tests as expected to fail:
TEST_EXPECT_FAIL(MyFailureTest) {
REQUIRE(false);
}Expected failures do not cause the test run to fail in CI.
compile_commands.jsonexported for clang tooling- Linux and Windows builds validated via CI
- MinGW cross-compilation supported on Linux
NTest aims to remain:
- Header-only
- Deterministic
- Minimal
- Easy to vendor
- CI-stable
It intentionally avoids advanced meta-programming and heavy DSLs.
MIT
