This directory contains the unit tests and benchmarks for the glTF renderer.
Tests are disabled by default to keep the build clean. To enable them:
# Configure with testing enabled
cmake -B build -DBUILD_TESTING=ON
# Build everything including tests
cmake --build build
# Or build just the tests
cmake --build build --target vk_gltf_renderer_tests
cmake --build build --target vk_gltf_renderer_benchmarkscd build
ctest -C Release --output-on-failure# Run all tests
_bin/Release/vk_gltf_renderer_tests.exe
# Run with color output
_bin/Release/vk_gltf_renderer_tests.exe --gtest_color=yes
# Run specific test
_bin/Release/vk_gltf_renderer_tests.exe --gtest_filter=BasicTests.RoundTrip
# Run with verbose output
_bin/Release/vk_gltf_renderer_tests.exe --gtest_color=yes --gtest_print_time=1# Run all benchmarks
_bin/Release/vk_gltf_renderer_benchmarks.exe
# Run specific benchmark
_bin/Release/vk_gltf_renderer_benchmarks.exe --benchmark_filter=SceneLoad
# Run with repetitions for statistical accuracy
_bin/Release/vk_gltf_renderer_benchmarks.exe --benchmark_repetitions=10tests/
├── CMakeLists.txt # Test build configuration
├── README.md # This file
├── test_main.cpp # Test entry point
├── test_basic.cpp # Basic scene loading tests
├── benchmark_main.cpp # Benchmark entry point
└── common/
├── test_utils.hpp # Test utilities header
└── test_utils.cpp # Test utilities implementation
- Create a new test file (e.g.,
test_mynewfeature.cpp) - Add to
CMakeLists.txt:set(TEST_SOURCES ${TEST_COMMON_SOURCES} test_basic.cpp test_mynewfeature.cpp # Add here )
- Write tests using GoogleTest:
#include <gtest/gtest.h> #include "common/test_utils.hpp" TEST(MyFeature, BasicTest) { ASSERT_TRUE(true); }
Add to benchmark_main.cpp:
static void BM_MyOperation(benchmark::State& state) {
for (auto _ : state) {
// Your code to benchmark
benchmark::DoNotOptimize(result);
}
}
BENCHMARK(BM_MyOperation);Test dependencies (GoogleTest, Benchmark) are organized into the External/ folder in the Solution Explorer to keep the main project clean.
- GoogleTest v1.14.0 - Unit testing framework
- Google Benchmark v1.8.3 - Performance benchmarking
Both are automatically downloaded via CMake FetchContent when BUILD_TESTING=ON.
For continuous integration, add to your workflow:
- name: Configure with testing
run: cmake -B build -DBUILD_TESTING=ON
- name: Build tests
run: cmake --build build --config Release
- name: Run tests
run: ctest --test-dir build -C Release --output-on-failure