Skip to content

Add automated unit testing infrastructure with Google Test#4

Merged
Berkay2002 merged 10 commits into
mainfrom
copilot/add-automated-unit-tests
Jan 6, 2026
Merged

Add automated unit testing infrastructure with Google Test#4
Berkay2002 merged 10 commits into
mainfrom
copilot/add-automated-unit-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 6, 2026

Implements comprehensive unit testing to eliminate manual validation of core engine components. Tests run in <10ms and integrate with CI/CD.

Changes

Test Framework

  • Google Test 1.15.2 via CMake FetchContent
  • tests/ directory structure mirroring core/ and world/
  • Test target builds with main project, shares dependencies

Test Coverage (26/42 passing, 61.9%)

Fully validated:

  • test_ray.cpp (9/9): Ray transformations, normalization, point calculations
  • test_chunk.cpp (17/17): Block storage, heightmaps, bounds checking, state transitions

Partial coverage:

  • test_block_registry.cpp (4/11): Registry lookups, configuration loading
  • test_voxel_raycast.cpp (2/12): DDA algorithm, collision detection

Failing tests require texture mocks and async chunk loading synchronization - infrastructure works, dependencies need handling.

CI/CD Integration

  • GitHub Actions workflow runs tests on push/PR
  • Build status badge in README
  • Test results auto-published to PRs

Documentation

  • TESTING.md: Developer guide for writing tests
  • TEST_SUMMARY.md: Coverage metrics and status report
  • README updated with testing commands

Example

// tests/world/test_chunk.cpp
TEST(ChunkTest, HeightmapWithGaps) {
    Chunk chunk;
    chunk.SetBlock(5, 10, 5, BlockType::Stone);
    chunk.SetBlock(5, 30, 5, BlockType::Stone);
    chunk.RebuildHeightmap();
    
    EXPECT_EQ(chunk.GetHeightAt(5, 5), 30);  // Returns highest solid block
}

Run tests:

cmake --build build --target VoxelTests && ./build/tests/VoxelTests

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https /lib64/ld-linux-x86-64.so.2 -pie -z (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

I want to do some kind of unit testing of sorts that automates the testing so I dont have to do any manual testing by starting the game and trying myself. How can we do this? I want to have these tests to also ensure everytime I commit, all is working as intended and so on.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Jan 6, 2026
Copilot AI and others added 3 commits January 6, 2026 06:48
Co-authored-by: Berkay2002 <90407224+Berkay2002@users.noreply.github.com>
Co-authored-by: Berkay2002 <90407224+Berkay2002@users.noreply.github.com>
Co-authored-by: Berkay2002 <90407224+Berkay2002@users.noreply.github.com>
Copilot AI changed the title [WIP] Add automated unit testing for the game Add automated unit testing infrastructure with Google Test Jan 6, 2026
Copilot AI requested a review from Berkay2002 January 6, 2026 06:54
@Berkay2002 Berkay2002 marked this pull request as ready for review January 6, 2026 14:54
Copilot AI review requested due to automatic review settings January 6, 2026 14:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a comprehensive automated unit testing infrastructure using Google Test to eliminate manual validation of core engine components. The tests execute in under 10ms and integrate with CI/CD pipelines through GitHub Actions.

Key Changes:

  • Integrated Google Test framework via CMake FetchContent with automated test discovery
  • Created 42 unit tests across 4 test suites covering ray calculations, chunk storage, block registry, and voxel raycasting
  • Added GitHub Actions workflow for automated testing on every push and pull request with test result publishing

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
CMakeLists.txt Adds Google Test dependency and test subdirectory integration
tests/CMakeLists.txt Configures test executable with source files and dependencies
tests/core/test_ray.cpp Tests ray construction, normalization, and point calculations (9 tests, all passing)
tests/world/test_chunk.cpp Tests chunk block storage, bounds checking, and heightmap generation (17 tests, all passing)
tests/world/test_block_registry.cpp Tests block configuration loading and property queries (11 tests, 4 passing)
tests/world/test_voxel_raycast.cpp Tests DDA raycasting algorithm and collision detection (12 tests, 2 passing)
.github/workflows/tests.yml GitHub Actions workflow for automated test execution on push/PR
TESTING.md Comprehensive developer guide for writing and running tests
TEST_SUMMARY.md Test coverage metrics and status report (26/42 tests passing, 61.9%)
README.md Updated with testing section, commands, and build status badge

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/tests.yml Outdated
Comment thread README.md Outdated
Comment thread tests/world/test_block_registry.cpp Outdated
Berkay2002 and others added 6 commits January 6, 2026 15:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 6, 2026

Unit Test Results

42 tests   42 ✅  0s ⏱️
 4 suites   0 💤
 1 files     0 ❌

Results for commit 9a4bffc.

@Berkay2002 Berkay2002 merged commit 05923a7 into main Jan 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants