MikeSchulze / gdUnit4

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

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

Open MikeSchulze opened 1 year ago

MikeSchulze commented 1 year ago

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.

Godot Issues: https://github.com/godotengine/godot/issues/55024 https://github.com/godotengine/godot/issues/67461

pennyloafers commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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

lbragile commented 6 months ago

@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 commented 6 months ago

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.