drwhut / tabletop-club

An open-source platform for playing tabletop games in a physics-based 3D environment for Windows, macOS, and Linux! Made with the Godot Engine.
https://tabletopclub.net
MIT License
1.27k stars 51 forks source link

Unittests Framework #153

Open elmodor opened 1 year ago

elmodor commented 1 year ago

Is your feature request related to a problem? Please describe. While testing the AssetDB change in #148 I was thinking about some sort of unit tests to test those core functions of tabletop-club.

Is something like this planned? I wouldn't mind write some tests myself - the question here is: Should (unit) tests be added? If so, how can we test gdscript?

Doing just a quick research I found following projects that should offer support for unit testing gdscripts. All with their own pros and cons. In order of popularity it seems:

Does anyone have experience with any of these unit test frameworks?

I guess spending time to write and tend to tests is a question that can't be answered with yes or no all the time. I do like having good tests (at least for core functionalities) but this decision should be made thoughtfully.

Describe the solution you'd like Adding one unit test framework so it is possible to add/write tests. The task here is not to write any tests it is to discuss if some sort of testing should be implemented - and if so that a framework is added that can be used for testing.

Describe alternatives you've considered Manual testing continues

drwhut commented 1 year ago

I had considered this in the past, but I have NO idea how to write unit tests for games - sure, for command line programs it's somewhat easy since you can precisely control what happens, but for games there are SO many variables, like the screen, mouse sensitivity, localisation, just to mention a few.

If anyone has experience, or knows of any guides, as to how unit tests are written for Godot, then please post links in this issue.

elmodor commented 1 year ago

I don't think that something like testing different mouse sensitivities are part of unit tests. That might be some form integration/software tests? I have no idea how you would do those software tests with godot / games as well.

Anyways, I was talking strictly about some sort of unit tests. These should be doable. Test a separate unit. E.g. AssetDB functionalities, maybe some core functionalities of Dice/Pieces/Cards etc. You start small and work your way up. Start with the core functions that should be rock solid.

The linked GUT and WAT should have some examples of how they are used. I have no experience with both so maybe someone does have some experience with UTs in godot?

drwhut commented 1 year ago

A quick update on this, I've decided to start writing unit tests for the game once I begin "the great rewrite" for v0.2.0. Plus, with #250 CI should be pretty easy since there will be an editor build for GitHub Actions to use without having to compile the whole engine again, and I've since learnt Godot 3.5 has a --headless argument for builds that allows us to use it in a CLI-only environment.