14

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 ???

2 Answers2

12

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.
Thomas
  • 174,939
  • 50
  • 355
  • 478
  • 3
    There's also WAT: https://github.com/CodeDarigan/WAT I see it mentioned less, for some reason, but they both look roughly on pair. WAT integrates with the editor window (Gut didn't do it when I looked at it), Gut seems to be better to use for automated testing? Haven't really used either a lot. – fede s. Aug 18 '20 at 07:30
  • 2
    @fedes. Thanks, added some info on WAT! – Thomas Aug 18 '20 at 07:47
3

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 ;)

  • I gotta say gdUnit ended up being way more impressive than I expected. Thanks for mentioning it! – Syndog Aug 19 '22 at 10:25