Skip to content

[QA] Fuel System Test Plan (GUT) #533

Description

@ikostan

Fuel System Test Plan (GDUnit4)

This test plan validates the Fuel System behavior across core logic, edge cases, signals, persistence, and UI integration.

Scope Definition

  • Unit Tests: Fuel calculations, clamping, scaling (no scene tree)
  • Integration Tests: Interaction with Globals.gd, signal emission
  • UI Tests: Reactive updates only (no logic validation)

All time-based behavior must use deterministic delta simulation (no real-time dependency).


Test Name Objective Setup / Method Expected Result
test_fuel_initialization Verify fuel initializes to max capacity Instantiate resource with config values fuel == max_capacity
test_fuel_consumption_static_exact Validate deterministic fuel consumption Apply fixed delta over N steps using constant rate fuel == start - (rate * total_time) (within tolerance)
test_fuel_consumption_with_scaling Verify increased consumption during acceleration Simulate normal vs "speed_up" states with same delta Accelerated consumption > base consumption
test_fuel_not_negative Ensure fuel is clamped at zero Simulate consumption beyond depletion fuel == 0.0 (never negative)
test_fuel_exact_zero_transition Validate correct behavior at exact zero boundary Reduce fuel to exactly 0.0 No float drift; value equals 0.0
test_fuel_depletion_signal_emitted_once Ensure signal fires exactly once on depletion Observe signal while crossing from >0 → 0 fuel_depleted emitted once only
test_multiple_depletion_signal_not_emitted_twice Prevent repeated signal spam Continue consumption after depletion No additional signals after first emission
test_refuel_basic Verify refuel increases fuel correctly Apply refuel amount within capacity fuel == previous + amount
test_refuel_clamped_to_max Ensure refuel does not exceed capacity Refuel beyond max capacity fuel == max_capacity
test_refuel_negative_input Validate handling of invalid refuel input Call refuel(-X) Value unchanged OR safely clamped
test_persistence_valid_config Ensure config values are loaded correctly Load from valid user://settings.cfg Runtime values match config
test_persistence_missing_keys_fallback Verify fallback behavior for missing config fields Load config with missing keys Defaults applied for missing values
test_persistence_invalid_types_fallback Ensure robustness against invalid config data Load config with wrong types Invalid values ignored; defaults used
test_ui_updates_on_fuel_change_signal Validate UI reacts to fuel updates Bind UI element to fuel change signal UI reflects updated fuel value

Notes

  • Use assert_almost_eq(..., tolerance) for float comparisons
  • Avoid frame/time dependency; simulate with explicit delta
  • Signals must be tested using observers/spies
  • UI tests should validate binding, not internal logic
  • Persistence tests should isolate filesystem (mock or temp config)

Metadata

Metadata

Assignees

Labels

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions