Better HN
topnewbestaskshowjobs
Log inSign up

AlexAndThunder

17 karma · joined Mar 25, 2018 (8y ago) · 4 submissions

Submissions

comment 6y ago · link · parent

I never ran into this issue myself but I do know the recent 3.2.3 version should have fixed it. With that said I love godot but GDScript does need more love.

comment 6y ago · link · parent

GDScript has not been enough for the size of my project. I swear to god if I get another "cyclic reference" error I'm going do something drastic! So I decided to eventually switch to C#.

However I ran into issues when trying to use established C# Unit Testing Frameworks like x or n Unit. I don't understand the absolute specifics but the gist is that these established systems don't work well (if at all sometimes) with Godot's Managed API.

So being the dev that works far too much on their own tools instead of their game, I ended up adding a C# Wrapper around WAT (My GDScript Unit Testing Plugin).

Installing WAT-Sharp

    Add "addons/WAT" from the Github to your addons folder

    Include the following files in your csproj file

        addons\WAT\core\assertions\Assertions.cs

        addons\WAT\core\test\Recorder.cs

        addons\WAT\core\test\Test.cs
C# API Differences

    You still inherit from WAT.Test

    Use the [Test] Attribute instead of prefixing your method names with test

    Use public override String Title() instead of func title()

    Use public override Start() instead of func start()

    Use public override Pre() instead of func pre()

    Use public override Post() instead of func post()

    Use public override End() instead of func end()

    Use Describe() instead of describe()

    Assertions are PascalCase (Check addons/WAT/core/assertions/Assertions.cs if you're stuck)

    Use await ToSignal(until_timeout/signal) to use Yield Methods

    Use the [RunWith(args)] Attribute for parameterized tests (and pass them via the call)

    PoolArray Assertions were removed

    TestSuiteOfSuites doesn't exist (yet)

    Test Doubles don't exist in C# (I'm not as familler with C# enough to do this properly)
Examples

You can find examples of tests in WAT-Sharp's own test suite at https://github.com/CodeDarigan/WATSharp/tree/master/tests which should hopefully help clear up any confusion.

3.

Wat-Sharp: A C# Wrapper Around Wat to Unit Test Your C# Godot Games(github.com ↗)

27 points · by AlexAndThunder · 6y ago · 3 comments

comment 8y ago · link · parent

From: http://docs.godotengine.org/en/3.0/getting_started/scripting...

' Memory management

If a class inherits from Reference, then instances will be freed when no longer in use. No garbage collector exists, just simple reference counting. By default, all classes that don’t define inheritance extend Reference. If this is not desired, then a class must inherit Object manually and must call instance.free(). To avoid reference cycles that can’t be freed, a weakref function is provided for creating weak references. '