-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double a PackedScene created via code #666
Comments
I'm not sure I follow what you are trying to do. Sounds like:
If that's the case you could do something like:
|
I was afraid I wasn't clear enough, but what you wrote is similar. The difference is that in my code there's a third class (which is what I'm testing) that does the instantiating and that call foo, something like
I changed my test to be somewhat close to your suggestion, but the test crashes saying that instance is null when calling
But with your response, I've either done something wrong (most likely) or stumbled upon a bug, I'm unsure if I should close this and create a new issue. |
Any other errors in the log? |
The engine error is:
The method then returns null which results in this test error:
|
I've been able to replicate the error in my own game that has a similar setup. I have a scene that spawn resources could use:
If you remove the type ( One way to work around this might be to create a method on your resource to instantiate the scene with an optional parameter for the scene to be used. This way you could test the method with anything and not be restricted by this issue.
|
I'm glad you were able to replicate it! I think I'll use the workaround you suggested. Thank you! |
Versions
What versions of Godot do you want to use this feature in?
4.3
The Feature
In my code I have a resource that has a PackedScene, and I want to test if some code gets that resource, instantiates the PackedScene, and calls some methods from the instance. I've tried to double an empty packed scene and stub return the double of the class in the PackedScene instantiate method like the code below, but that breaks the
get_scene_script_object
from GUT utils. I'm not sure if I'm doing it correctly, but if this isn't possible, it would be nice.The text was updated successfully, but these errors were encountered: