Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 9, 2025

This PR implements comprehensive unit testing infrastructure for the Godot template using the Gut testing framework and adds automated code quality checks via GitHub Actions.

Changes Made

Testing Infrastructure

  • Gut Framework Integration: Added Gut v9.4.0 as an addon for unit testing Godot code
  • Test Configuration: Created .gutconfig.json with optimized settings for automated testing
  • Test Runner: Added test_runner.sh script for local test execution
  • Project Configuration: Updated project.godot to enable the Gut addon

Comprehensive Test Suite

Created 5 test files covering all major components:

  • test_game_manager.gd - Tests GameManager singleton functionality, signals, and Score class
  • test_main.gd - Tests main scene loading, input actions, and project settings
  • test_menu.gd - Tests menu UI components and signal handling
  • test_ui_components.gd - Tests scene loading for all UI components (keybindings, mixer, high scores, credits)
  • test_integration.gd - Integration tests for game flow, autoload initialization, and component interactions

GitHub Actions Workflow

Added .github/workflows/code-checks.yml with two jobs:

  • Tests: Runs all unit tests using Gut framework
  • Lint: Performs code quality checks and script validation

Documentation

  • Updated main README.md with testing section and updated project structure
  • Created test/README.md with comprehensive testing documentation
  • Added instructions for running tests locally and in CI

Testing Coverage

The test suite validates:

  • ✅ GameManager singleton functionality and game_over signal
  • ✅ Scene loading and instantiation for all components
  • ✅ Menu UI signal handling and methods
  • ✅ Input action configuration
  • ✅ Autoload singleton initialization
  • ✅ Resource loading (themes, bus layouts, scenes)
  • ✅ Integration between components

Running Tests

Locally:

./test_runner.sh

In Godot Editor:

  1. Open Project → Tools → Gut
  2. Click "Run All"

CI/CD:
Tests run automatically on push/PR to main branch alongside existing build workflow.

Fixes #9.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 9, 2025 01:23
Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] add unit testing for godot code with Gut and add code checks github action workflow Add unit testing with Gut framework and GitHub Actions code checks workflow Jun 9, 2025
@Copilot Copilot AI requested a review from saebyn June 9, 2025 01:25
Copilot finished work on behalf of saebyn June 9, 2025 01:25
@saebyn
Copy link
Owner

saebyn commented Jun 9, 2025

@copilot can you troubleshoot the test failure?

…functionality

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
@Copilot
Copy link
Contributor Author

Copilot AI commented Jun 9, 2025

@copilot can you troubleshoot the test failure?

Fixed the test failures! The issue was with signal testing in the integration tests. I replaced the manual signal connection approach with Gut's built-in signal watching functionality (watch_signals() and assert_signal_emitted()). All 26 tests now pass successfully. Commit: 0cac51e

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
Copilot finished work on behalf of saebyn June 9, 2025 01:35
@saebyn saebyn requested a review from Copilot June 9, 2025 01:38
@saebyn saebyn marked this pull request as ready for review June 9, 2025 01:38
Copy link
Contributor

@Copilot 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 introduces a comprehensive unit testing infrastructure for the Godot template using the Gut framework and integrates GitHub Actions workflows to run tests and perform code quality checks.

  • Integrated Gut v9.4.0 with test configuration and a test runner script.
  • Added several new scripts, configuration files, and UID assets to support the testing framework and CLI tools.
  • Updated project documentation and added a GitHub Actions workflow for tests and linting.

Reviewed Changes

Copilot reviewed 220 out of 220 changed files in this pull request and generated no comments.

Show a summary per file
File Description
addons/gut/collected_script.gd Adds a meta-information container for parsed test scripts.
addons/gut/cli/* Introduces CLI support files (including uid assets and option parsing for tests).
addons/gut/awaiter.gd and addons/gut/autofree.gd Implements asynchronous waiting and free management logic for test operations.
addons/gut/UserFileViewer.tscn and UserFileViewer.gd Implements a new file viewer scene and corresponding script.
addons/gut/GutScene.tscn and GutScene.gd Provides the GUI wrapper for the test-runner interface.
README.md, .gutconfig.json, .github/workflows/code-checks.yml Updates documentation and CI/CD configuration for testing and linting support.
Comments suppressed due to low confidence (1)

addons/gut/collected_script.gd:35

  • The property 'name' returns the file path, which might be misleading. Consider renaming the property or updating its getter to clarify its purpose.
var name = '' :	get: return path

@saebyn saebyn merged commit 6bd0c23 into main Jun 9, 2025
5 checks passed
@saebyn saebyn deleted the copilot/fix-9 branch June 9, 2025 01:39
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.

add unit testing for godot code with Gut and add code checks github action workflow

2 participants