helios includes a comprehensive test suite to verify functionality. This guide covers how to run tests, interpret results, and debug failures.
Tests are built automatically when you build the project with CMake.
cd build
ctest -C Release --output-on-failurecd build
ctest --output-on-failureYou can run tests matching a specific pattern:
# Run all math-related tests
ctest -R "Math" --output-on-failure
# Run a specific test
ctest -R "Vector3Test" --output-on-failure
# List all available tests without running them
ctest -NTests are built in the same configuration as the main project:
# Debug build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --config Debug
cd build
ctest -C Debug --output-on-failure
# Release build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cd build
ctest -C Release --output-on-failureCTest provides several options to control output:
| Flag | Description |
|---|---|
--output-on-failure |
Show detailed output only for failed tests |
-V or --verbose |
Show all test output (useful for debugging) |
--rerun-failed |
Re-run only tests that failed in the previous run |
-N |
List all tests without running them |
-R <regex> |
Run tests matching the regex pattern |
-E <regex> |
Exclude tests matching the regex pattern |
--timeout <seconds> |
Set a timeout for each test |
Here's what a successful test run looks like:
$ cd build
$ ctest -C Release --output-on-failure
Test project F:/thorstensuckow/helios/build
Start 1: Vector3Test
1/12 Test #1: Vector3Test ...................... Passed 0.02 sec
Start 2: Vector4Test
2/12 Test #2: Vector4Test ...................... Passed 0.02 sec
Start 3: Matrix4Test
3/12 Test #3: Matrix4Test ...................... Passed 0.03 sec
Start 4: TransformTest
4/12 Test #4: TransformTest .................... Passed 0.01 sec
Start 5: CameraTest
5/12 Test #5: CameraTest ....................... Passed 0.02 sec
Start 6: SceneGraphTest
6/12 Test #6: SceneGraphTest ................... Passed 0.04 sec
Start 7: RenderingTest
7/12 Test #7: RenderingTest .................... Passed 0.05 sec
Start 8: MaterialTest
8/12 Test #8: MaterialTest ..................... Passed 0.03 sec
Start 9: InputTest
9/12 Test #9: InputTest ........................ Passed 0.02 sec
Start 10: GuidTest
10/12 Test #10: GuidTest ......................... Passed 0.01 sec
Start 11: FileReaderTest
11/12 Test #11: FileReaderTest ................... Passed 0.02 sec
Start 12: LoggerTest
12/12 Test #12: LoggerTest ....................... Passed 0.01 sec
100% tests passed, 0 tests failed out of 12
Total Test time (real) = 0.28 secIf a test fails, use verbose mode to see detailed output:
ctest -R "FailedTestName" -VYou can also run test executables directly for more control:
# Debug build
.\tests\helios\math\Debug\Vector3Test.exe
# Release build
.\tests\helios\math\Release\Vector3Test.exe# Run test directly
./tests/helios/math/Vector3Test
# With valgrind for memory leak detection
valgrind ./tests/helios/math/Vector3TestFailed tests will show:
- Expected vs. Actual values - What the test expected and what it got
- Stack trace - Where the failure occurred in the code
- Test name - Which specific test case failed
Example of a failed test:
Test project F:/thorstensuckow/helios/build
Start 1: Vector3Test
1/1 Test #1: Vector3Test ......................***Failed 0.02 sec
Running main() from gtest_main.cc
[==========] Running 5 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 5 tests from Vector3
[ RUN ] Vector3.Addition
[ OK ] Vector3.Addition (0 ms)
[ RUN ] Vector3.Subtraction
[ OK ] Vector3.Subtraction (0 ms)
[ RUN ] Vector3.Multiplication
F:/thorstensuckow/helios/tests/helios/math/Vector3Test.cpp:42: Failure
Expected equality of these values:
result.x
Which is: 2.5
2.0
Which is: 2
[ FAILED ] Vector3.Multiplication (1 ms)
helios tests are organized by module:
tests/
├── helios/
│ ├── math/ # Math library tests
│ │ ├── Vector3Test.cpp
│ │ ├── Vector4Test.cpp
│ │ ├── Matrix4Test.cpp
│ │ └── TransformTest.cpp
│ ├── scene/ # Scene graph tests
│ │ ├── SceneTest.cpp
│ │ └── CameraTest.cpp
│ ├── rendering/ # Rendering tests
│ │ ├── MaterialTest.cpp
│ │ └── RenderPassTest.cpp
│ ├── input/ # Input system tests
│ │ └── InputManagerTest.cpp
│ └── util/ # Utility tests
│ ├── GuidTest.cpp
│ └── LoggerTest.cpp
└── ext/ # External library tests
└── glfw/
Tests run automatically on every push and pull request via GitHub Actions. The workflow tests on:
- Windows (MSVC) - Debug & Release
- Linux (GCC 13 & Clang 17) - Debug & Release
- macOS (Apple Clang) - Debug & Release
See the Test Workflow for the complete CI configuration.
The test workflow runs when:
- Code is pushed to
mainordevelopbranches - Pull requests are created targeting
mainordevelop - Changes are made to source files (
src/,include/,tests/) - CMake configuration is modified
- Go to the Actions tab in the GitHub repository
- Click on a workflow run to see detailed results
- Failed tests will show error logs and stack traces
- Test artifacts are uploaded for failed builds
If you're contributing to helios, please include tests for new features and bug fixes. See the Contributing Guide for guidelines on writing tests.
helios uses Google Test (gtest) for unit testing. Example:
#include <gtest/gtest.h>
#include "helios/math/Vector3.h"
TEST(Vector3Test, Addition) {
helios::math::Vector3f a(1.0f, 2.0f, 3.0f);
helios::math::Vector3f b(4.0f, 5.0f, 6.0f);
auto result = a + b;
EXPECT_FLOAT_EQ(result.x, 5.0f);
EXPECT_FLOAT_EQ(result.y, 7.0f);
EXPECT_FLOAT_EQ(result.z, 9.0f);
}Tests not found:
# Make sure you're in the build directory
cd build
ctest -N # List all testsCMake configuration errors:
# Reconfigure and rebuild
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseMissing test executables:
# Rebuild the project
cmake --build build --config Release --target all- Ensure you specify the configuration (
-C Releaseor-C Debug) - Test executables are in
build/tests/.../Release/orDebug/
- Use
lddto check for missing shared libraries:ldd ./tests/helios/math/Vector3Test
- Getting Started - Initial setup and build instructions
- Contributing Guide - How to contribute tests
- API Reference - Detailed API documentation