如何在 Godot 引擎中编写测试
How to write Tests in Godot engine
Soo 我正在使用 Godot 引擎开发游戏,我想为代码创建一些测试以确保一切正常,我无法通过简单的操作测试游戏,这需要 5-10 分钟.有没有办法写测试???
看看GUT, the Godot unit test framework, or WAT。
两者的区别,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.
还有GdUnit3 https://github.com/MikeSchulze/gdUnit3 ;)
它将在即将发布的 2.0.0 版本中发布,支持 c#-beta。
GdUnit3 完全集成在 Godot 编辑器中,带有 UI 检查器以浏览您的测试结果。
还支持通过在 Github-Action
中使用命令行工具进行自动化测试
欢迎尝试 ;)
Soo 我正在使用 Godot 引擎开发游戏,我想为代码创建一些测试以确保一切正常,我无法通过简单的操作测试游戏,这需要 5-10 分钟.有没有办法写测试???
看看GUT, the Godot unit test framework, or WAT。
两者的区别,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.
还有GdUnit3 https://github.com/MikeSchulze/gdUnit3 ;)
它将在即将发布的 2.0.0 版本中发布,支持 c#-beta。
GdUnit3 完全集成在 Godot 编辑器中,带有 UI 检查器以浏览您的测试结果。 还支持通过在 Github-Action
中使用命令行工具进行自动化测试欢迎尝试 ;)