f48fd9a3d673dde3ded66de80808ed133ea2a44a
TinyTest
TinyTest is a lightweight C++ testing framework designed to simplify unit testing, with focus on ease of use and flexibility.
Key Features
- Simple API for creating and running test suites
- Support for test setup and teardown functions
- Custom comparison functions for complex objects
- Detailed test results reporting
- Ability to skip tests conditionally
- Integration with CMake build system
Examples
Several examples demonstrating how to use TinyTest in different environments are provided in the examples/ directory:
- Standalone Example: Uses CMake's FetchContent to automatically download TinyTest
- Preinstalled Example: Uses find_package to locate a system-installed TinyTest
- Sample Project: Minimal example showing basic TinyTest usage
Each example includes detailed instructions for building and running on both Windows and Linux/macOS systems.
Building with CMake
TinyTest can be built using CMake:
# Create a build directory
mkdir build && cd build
# Configure
cmake ..
# Build
cmake --build .
# Run tests
ctest
Usage Overview
Here's a simple example of how to use TinyTest:
#include <tinytest/tinytest.h>
// Function to test
int add(int a, int b) {
return a + b;
}
int main() {
// Create a test suite
auto suite = TinyTest::MakeTestSuite(
"AddFunction",
add,
{
TinyTest::MakeTest("should add two positive numbers",
5, // Expected result
std::make_tuple(2, 3)) // Input parameters
}
);
// Execute the suite and get results
auto results = TinyTest::ExecuteSuite(suite);
// Print results
TinyTest::PrintResults(std::cout, results);
return (results.Failed() > 0 || results.Errors() > 0) ? 1 : 0;
}
Integration Options
TinyTest can be integrated into your project in multiple ways:
- Using FetchContent - automatically downloads and builds TinyTest
- Using find_package - uses a pre-installed version of TinyTest
- Direct inclusion - directly adding TinyTest as source files
See the examples/ directory for detailed instructions on each approach.
License
TinyTest is released under the MIT License. See LICENSE file for details.
Description
Languages
C++
90.3%
Starlark
9.7%