Skip to content
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

GD-42: Rewrite doubler to allow double core functions #42

Open
MikeSchulze opened this issue Nov 20, 2022 · 6 comments
Open

GD-42: Rewrite doubler to allow double core functions #42

MikeSchulze opened this issue Nov 20, 2022 · 6 comments
Assignees
Labels
refactoring Mark to refactoring a implementation
Milestone

Comments

@MikeSchulze
Copy link
Owner

MikeSchulze commented Nov 20, 2022

Describe What
GdUnit4 no longer works to mock/spy on core functions.

Describe Why
With Godot 4 it is no longer allowed to override core functions which breaks the current doubler implementation.

Dev hints
Follow the new double prototype to allow double core functions.

  • Disable override errors by @warning_ignore("native_method_override")

Godot Issues:
godotengine/godot#55024
godotengine/godot#67461

@MikeSchulze MikeSchulze added the refactoring Mark to refactoring a implementation label Nov 20, 2022
@MikeSchulze MikeSchulze self-assigned this Nov 20, 2022
@MikeSchulze MikeSchulze changed the title Rewrite doubler to allow double core functions GD-42: Rewrite doubler to allow double core functions Nov 20, 2022
@MikeSchulze MikeSchulze added this to the V4.1.0 milestone Nov 20, 2022
@MikeSchulze MikeSchulze removed this from the V4.1.0 milestone Feb 27, 2023
@MikeSchulze MikeSchulze added this to the V4.2.0 milestone Apr 15, 2023
@pennyloafers
Copy link

I'm having a lot of behavior issues with mocks even with custom functions of my classes. is this expected?
I can verify events on mock functions, but cannot override the default return value.

I don't see signals using the double code, but I also have issues with getting that to work.

@MikeSchulze
Copy link
Owner Author

Hello, I am back from vacation.

As the issue describes, core functions are current not possible to override, this is how GDScript 2.0 now works.

Custom functions should still be mockable.
Can you add your test as an example to reproduce please.

@pennyloafers
Copy link

Oh man, I just realized Im talking to the same person from Godot engine GitHub issue page about event propagation. :) i apologize if I'm clouding the water over there I am using your unit test framework and removing the check to run headless for my ci.

Anyway, I've done a little more trouble shooting and I think there is an issue with returning a custom value and using the "any" matchers. If I setup the do_return on the mock with the same argument values expected, values passed by the tested class, then it will return the custom value. If I use the any matchers then I will only get the default return.

This issue may be different then this one, if I have time I can create a separate issue.

Thanks

@MikeSchulze
Copy link
Owner Author

if you found such issues about mocking please create an new bug issue with steps to reproduce, this will help me to shedule the fix.

Thanks

@MikeSchulze MikeSchulze modified the milestones: V4.2.0, v4.2.1 Sep 29, 2023
@lbragile
Copy link

lbragile commented Dec 9, 2023

@MikeSchulze Discovering GdUnit4 was exciting, offering a valuable solution for testing my C# Godot4 game through its sleek test runner and plugin. However, my enthusiasm was tempered upon realizing that the mocking/spying feature is exclusively available for GdScript, as illustrated in this example. This limitation presents a significant drawback for me, given that mocking and spying are fundamental concepts in testing, and their absence in C# testing diminishes the utility of GdUnit4 for my specific needs.

I acknowledge the positive step in addressing this concern with the statement:

GdUnit4 no longer works to mock/spy on core functions.

However, I believe that rectifying this limitation for C# should be given higher priority.
Additionally, it would be beneficial to communicate this more prominently in the documentation. Presently, users only become aware of this restriction when exploring the Advanced Testing section, and bringing attention to it more prominently can help manage expectations and guide users effectively.

@MikeSchulze
Copy link
Owner Author

Thanks for your feedback, that is very valuable for me.
Mocking and Spy is not offered by GdUnit for the C# version because there are already enough mock frameworks for C#. You should be able to integrate and use other mock frameworks without any problems.
The C# support is currently also limited, as I have received little to no feedback on the C# version.
But the API is expandable, and feature requests can be created at any time.

@MikeSchulze MikeSchulze modified the milestones: v4.2.1, v4.3.0 Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Mark to refactoring a implementation
Projects
Status: No status
Development

No branches or pull requests

3 participants