'How to write Tests in Godot engine

Soo I'm developing a game with the Godot engine and I want to create some test for the code to be sure that everything is working, I can't test the game with simple actions it takes 5-10 minutes. Is there a way to write tests ???



Solution 1:[1]

Have a look at GUT, the Godot unit test framework, or WAT.

Differences between the two, quoting WAT's author:

  • GUT runs in a scene. WAT runs in the editor itself.
  • GUT (last I checked) cannot handle creating Test Doubles that take constructor dependencies (as in it uses the _init method with arguments).
  • WAT has parameterized testing (so you can do the same test multiple times only needing to define the different set of arguments per run through).
  • WAT has a much larger range of asserts (I think)
  • WAT can intentionally crash a test script if one method fails (this isn't documented yet though).
  • WAT cleans up after itself with regards to memory. GUT doesn't. (Note: This was largely thanks to the recent method print_stray_nodes builtin to Godot that GUT didn't have during its initial creation).
  • GUT allows for inner test classes. WAT doesn't. However WAT has the "context" attribute attached to every asserts call so you can add sub-context to your describe() method context of the parent method.

Solution 2:[2]

There is also GdUnit3 https://github.com/MikeSchulze/gdUnit3 ;)

It will release in upcoming version 2.0.0 with c#-beta support.

GdUnit3 is full integrated in the Godot editor with a UI inspector to navigate over your test results. Supports also automated testing by using the command line tool in a Github-Action

Feel free to give a try ;)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Mike Schulze