Problems & Solutions
This section lists known problems and possible solutions/workarounds.
Problems
- Script/Resource Errors after the plugin is installed
- Modifying the Game Engine State ‘mainLoop.Paused = true’ during Tests
Script/Resource Errors after the plugin is installed
When installing the GdUnit4 plugin and activating it, you may encounter a lot of script and resource loading errors. These errors occur due to a cache problem in the Godot Engine.
Solution
To solve the errors, you need to restart the Godot Editor. If this does not help, you may need to manually delete the Godot cache folder:
- Close the Godot Editor.
- Delete the
.godot
folder from your working directory. - Start the Godot Editor (you may still see loading errors).
- Close and restart the Godot Editor. The loading errors should no longer occur.
Modifying the Game Engine State ‘mainLoop.Paused = true’ during Tests
When a test modifies the game engine state Paused
on the SceneTree
, it can affect the test execution. Setting the main loop to paused will stop the engine running, including the test execution running in the main loop, causing the GdUnit4 test window to remain open even after tests are complete.
Solution
When you modify engine states during tests, ensure you restore them to their previous values when the test is finished. You can achieve this by adding an “after test” stage to your test suite.
-
# Reset the paused mode back to false after each test func after_test() -> void: Engine.get_main_loop().paused = false # Simple example test to modify the game state func test_game_paused() -> void: var mainLoop :SceneTree = Engine.get_main_loop() assert_that(mainLoop.paused).is_false() # The following lines cause the GdUnit4 test window to remain open even after tests are complete mainLoop.paused = true assert_that(mainLoop.paused).is_true()
-
// Reset the paused mode back to false after each test [AfterTest] public void TearDown() => ((SceneTree)Engine.GetMainLoop()).Paused = false; [TestCase] public void GamePaused() { var mainLoop = (SceneTree)Engine.GetMainLoop(); AssertThat(mainLoop.Paused).IsFalse(); // The following lines cause the GdUnit4 test window to remain open even after tests are complete mainLoop.Paused = true; AssertThat(mainLoop.Paused).IsTrue(); }