MikeSchulze / gdUnit4

A Godot Unit Test Framework. Support for GDScript and C# unit testing
MIT License
565 stars 30 forks source link

Allow initialization methods to be called before a scene is added to the Scene Tree #495

Closed taylor-nightingale closed 3 months ago

taylor-nightingale commented 3 months ago

Is your feature request related to a problem? Please describe. ISceneRunner.Load automatically adds the loaded Node to the SceneTree, causing _Ready to be called before any initializing functions can be run

Describe the solution you'd like Overloaded the ISceneRunner.Load method to accept a Node or a resource path.

Describe alternatives you've considered ISceneRunner could be changed to have a a Start method and only add the scene once this is called, but this would be a breaking change requiring a major version update.

MikeSchulze commented 3 months ago

Overloaded the ISceneRunner.Load method to accept a Node or a resource path.

It accepts already resource path or the scene instance.

You can solve this already by just override the scene_runner function by

func scene_runner(scene :Variant, verbose := false) -> GdUnitSceneRunner:
        # do your custom init stuff
        scene.init();
    return auto_free(GdUnitSceneRunnerImpl.new(scene, verbose, true))