-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Unit Tests #11420
Comments
And what about this one? https://godotengine.org/asset-library/asset/1709 |
have no C# support, I also try this another asset for c#: https://godotengine.org/asset-library/asset/2100 However, I think this is a kind of think that should be in the engine and not in a extension. edit: what all the assets in the library store actually do is create auxiliary test functions, but it is still necessary to compile, run and load the engine and the entire game. |
@ayslan-gamedev try https://github.com/MikeSchulze/gdUnit4Net |
Describe the project you are working on
I would like it to be possible to write unit tests to test Godot scripts (both in GDScript and C#). This feature is very useful when developing more complex systems, especially in C#, as seen with Unity. In Unity, it is possible to write unit tests: you write a test, click to run it, and the engine compiles, opens, and closes the game quickly.
Unit tests automate the testing process. Instead of the developer needing to open the game and manually test every change, they can create several unit tests, making the process more efficient and less error-prone.
Describe the problem or limitation you are having in your project
I am working on a procedural generation script in C# where I manually created several chunks for testing purposes, and now I want to test the logic of connecting them. I have written the following function to generate rooms and establish connections between them:
However, I want to test this logic without having to open the Godot editor, or at least not execute the game manually each time. My goal is to run a generic test with some sample data to check if everything is working as expected.
While I understand that I could use GD.Print() to log information, this approach has its drawbacks:
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The proposal is to integrate native support for unit testing in Godot, both for GDScript and C#. This would allow developers to write automated tests for their scripts and systems. The ability to run these tests without launching the full game would significantly improve workflow efficiency, especially for complex projects. It would enable rapid feedback on code changes, ensuring that functionality is not broken by new modifications and promoting better code quality. This is particularly useful for larger projects where manual testing can be time-consuming and error-prone.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The feature would provide an easy-to-use API for writing and executing unit tests. Below is a simple example in GDScript:
Test class to handle unit tests
Test runner that would run all tests
If this enhancement will not be used often, can it be worked around with a few lines of script?
While unit tests can be written using scripts manually, writing a custom testing framework would require extra setup and time, and would not be as convenient as having a native solution in Godot. Perhaps a plugin would solve this, but native support would be better. Having built-in support allows for simplified testing and better integration with the editor, making it much more accessible to all developers, not just advanced users.
Is there a reason why this should be core and not an add-on in the asset library?
This will improve code debugging and is a useful resource that another engines have in your core (just like unity engine), furthermore, there is no plugin on asset store that do it.
The text was updated successfully, but these errors were encountered: