Skip to content
NoahGWoodPublic

About

NTest is Noah's testing framework for C++

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

NTest – Minimal C++ Unit Testing Framework

CI Issues C++17 Last Commit

NTest is a lightweight, two-header unit testing framework for C++17 projects.
Minimal, dependency-free, and CI-friendly.


Features

  • 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)

Assertion Semantics

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.


Basic Usage

#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
./tests

Expected-Fail Support (Framework Testing)

NTest 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.


Example Output

example.png


CI / Tooling

  • compile_commands.json exported for clang tooling
  • Linux and Windows builds validated via CI
  • MinGW cross-compilation supported on Linux

Philosophy

NTest aims to remain:

  • Header-only
  • Deterministic
  • Minimal
  • Easy to vendor
  • CI-stable

It intentionally avoids advanced meta-programming and heavy DSLs.


License

MIT

About

NTest is Noah's testing framework for C++

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages