Skip to content

fix: normalize test harness style#197

Merged
itsmiso-ai merged 1 commit into
mainfrom
saffron-normal/fix-test-style-normalize
Jun 10, 2026
Merged

fix: normalize test harness style#197
itsmiso-ai merged 1 commit into
mainfrom
saffron-normal/fix-test-style-normalize

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes #182

  • Replace extends TestSuite with extends SceneTree in test_food_upkeep.gd (stale reference)
  • Remove stale Globals.get_node("/root/Main") calls in test_resource_trends.gd (9 occurrences replaced with load()+new() instantiation)
  • Rewrite test_food_upkeep.gd to call actual Main methods instead of static helpers that mirrored implementation without importing it
  • Add harness helpers (_assert, _assert_eq, etc.) matching the test_runner pattern

- Replace extends TestSuite with extends SceneTree in test_food_upkeep.gd

- Remove stale Globals.get_node("/root/Main") calls in test_resource_trends.gd (9 occurrences replaced with load()+new() instantiation)

- Rewrite test_food_upkeep.gd to call actual Main methods instead of static helpers that mirrored implementation without importing it

- Add harness helpers (_assert, _assert_eq, etc.) matching test_runner pattern
@itsmiso-ai itsmiso-ai requested a review from joryirving as a code owner June 10, 2026 06:36

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI Automated Review

Full PR review.

Analysis engine: review@https://litellm.jory.dev/v1 (openai)

Recommendation

Approved. This PR successfully addresses the technical debt identified in issue PR 182 by normalizing the test harness style across the repository.

Change-by-Change Findings

tests/test_food_upkeep.gd

  • Harness Update: Changed extends TestSuite to extends SceneTree to avoid stale references.
  • Implementation Change: Replaced static helper functions (which mirrored implementation logic) with direct instantiation of Main via load("res://scripts/main.gd").new(). This ensures tests validate the actual game logic rather than a mock.
  • State Management: Tests now explicitly set main.state before execution, ensuring isolation and predictable test conditions.
  • Assertion Style: Introduced internal harness helpers (_assert, _assert_eq, _assert_lt, etc.) to match the pattern used in the repository's test_runner.gd.
  • Reporting: Added a summary output at the end of the test execution to report pass/fail counts.

tests/test_resource_trends.gd

  • Harness Update: Removed all Globals.get_node("/root/Main") calls, which relied on the Main singleton being present in the scene tree.
  • Implementation Change: Standardized on loading res://scripts/main.gd and instantiating a fresh Main instance for every test case, ensuring true unit testing of the trend logic without side effects from a global singleton.

Linked Issue Fit

This PR directly satisfies the requirements of PR 182 (Normalize generated test style):

  • One harness pattern: All tests now use SceneTree and a consistent _initialize pattern.
  • No stale Globals/TestSuite references: Removed TestSuite inheritance and Globals.get_node calls.
  • No tests mirroring implementation: Replaced static mocks with actual Main method calls on instantiated objects.

Standards Compliance

  • Repository Conventions: The implementation follows the established pattern of using SceneTree for headless tests and matches the assertion style found in tests/test_runner.gd and other existing test files.
  • Consistency: The use of load().new() for test isolation is consistent with the patterns seen in tests/test_dirty_state_tracking.gd and tests/test_colony_stance.gd.

@itsmiso-ai itsmiso-ai merged commit 4e74f7e into main Jun 10, 2026
4 checks passed
@itsmiso-ai itsmiso-ai deleted the saffron-normal/fix-test-style-normalize branch June 10, 2026 09:57
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.

Normalize generated test style

1 participant