MikeSchulze / gdUnit4

A Godot Unit Test Framework. Support for GDScript and C# unit testing
MIT License
565 stars 30 forks source link

GD-4.2.2: First time user. Tests run with many error messages #516

Closed SamuelAsherRivello closed 3 months ago

SamuelAsherRivello commented 3 months ago

The used GdUnit4 version

GdUnit4 4.3.2

The used Godot version

v4.2.2-stable-mono

Operating System

Windows 11

Describe the bug

Hiya,

Great work on a great tool. I'm experiencing some issues. I'm using the latest public windows 11, the latest public godot, the latest version of your tool (From asset lib) that then updated itself. I am using the latest public version of rider and had to follow your docs and manually edit the csjproject. All compiles. The tests run.

Something unique in my project setup is that the "RMC Mingle" and "RMC Mini Mvcs" in my addons folder are local windows simlinks to improve my addon development workflow. I doubt that causes issues per below, but thought I'd mention it.

--

I'm a game dev with over 20 years of XP, the last decade in Unity.

I have created Mvcs architectures (https://bit.ly/mvc-architecture-for-unity-on-udemy) and Unit Testing courses (https://bit.ly/unit-testing-for-unity-course) for Unity.

I'm playing with Godot and enjoying it. I'd like to do a free YouTube video on "Unit Testing in Godot" and have tried several C#-friendly Godot unit testing pathways including yours.

I'd love some help with these bugs.

-Sam!

Feel free to say hi - https://www.linkedin.com/in/samuelasherrivello/

Happy to have a video chat too.

SETUP

Here is my godot version 2024-06-24_13-05-47

My default CS Project shows errors. 2024-06-24_13-21-38

I updated to this and the errors go away. The rest of the images assume this setup 2024-06-24_13-22-05

BUGS

The tests do indeed run properly. None of the tests appear in the "GDUnit" tab on the left which I assume is unexpected. 2024-06-24_13-06-01

The output is full of errors 2024-06-24_13-06-07

And I cannot edit any shortcuts 2024-06-24_13-06-36

And I see some warnings 2024-06-24_13-18-10

Steps to Reproduce

See images

Minimal reproduction project

See images

MikeSchulze commented 3 months ago

Hi and welcome to GdUnit4.

Seems to me to be a wrong project setup, please check your C# project settings.

<PropertyGroup>
    <TargetFrameworks>net8.0</TargetFrameworks>
    <LangVersion>11.0</LangVersion>
    <!--Force nullable warnings, you can disable if you want-->
    <Nullable>enable</Nullable>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <!--Disable warning of invalid/incompatible GodotSharp version-->
    <NoWarn>NU1605</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <!--Required for GdUnit4-->
    <PackageReference Include="gdUnit4.api" Version="4.2.*" />
  </ItemGroup>

https://mikeschulze.github.io/gdUnit4/csharp_project_setup/csharp-setup/#gdunit4-c-test-setup

SamuelAsherRivello commented 3 months ago

Thanks!

I appreciate the help. Its improving, but my issues continue.

SETUP

I tried your csproject as is. I deleted my csproject and solution. Added your snippet. closed/opened godot. Rebuild the project. And run the testing. Issues continue.

Then I tried a custom version from the snippet below for less warnings. I deleted my csproject and solution. Added your snippet. closed/opened godot. Rebuild the project. And run the testing. Issues continue. The following images are with my snippet here.

<Project Sdk="Godot.NET.Sdk/4.2.2">
  <PropertyGroup>
    <TargetFrameworks>net8.0</TargetFrameworks>
    <LangVersion>11.0</LangVersion>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <!--Disable warning of invalid/incompatible GodotSharp version-->
    <NoWarn>NU1605</NoWarn>

    <!--Disable warnings. SamR preferences-->
    <!-- <Nullable>enable</Nullable> -->
    <NoWarn>CS8601</NoWarn>
    <NoWarn>CS8618</NoWarn>
    <NoWarn>CS8601</NoWarn>
    <NoWarn>CS8632</NoWarn>

  </PropertyGroup>
  <ItemGroup>
    <!--Required for GdUnit4-->
    <PackageReference Include="gdUnit4.api" Version="4.2.*" />
  </ItemGroup>
</Project>

BUGS

I have one test class. Its the default from the docs. The test 'works' but does not appear in the GDUnit window in the upper left and it shows errors in the console. 2024-06-24_13-59-23

And I cannot adjust any shortuts. 2024-06-24_13-59-43

MikeSchulze commented 3 months ago

hm thats strange, can you close Godot delete the .godot folder restart godot two time and rebuild the project

SamuelAsherRivello commented 3 months ago

Thanks!

Overall, the C#-compatibility is someone unique in the unit testing space, and the API for testing (asserts) are very nice. I'd love to use this for some upcoming videos if I can get it working. Not too urgent. But this week, I'll record with whatever testing setup I find that works best.

I tried that in my main repo. Same Results.

I'm new to Godot (< 100 hours). I'm new to addons. Perhaps I'm doing something silly and incorrect.

Below is a new fresh public repo (without the complexity of simlinks I mentioned earlier) and no gitignore so you see all the files. I tried your suggestions in this new temp repo. Same Results.

Again, I can right click the *.cs and run the tests and see valuable pass/fail results. But the upper-left window seems to be broken, the output seems to be too-full of errors, and (while many non-shortcut GDUnit4 settings appear to 'work') the GDUnit4 settings for shortcuts do not appear interactive/clickable/changeable.

If you have any ideas, or find something simple I'm missing, please send a PR request with the change. I'll use it immediately. Thanks so much!

https://github.com/SamuelAsherRivello/godot-unit-test-temporary

MikeSchulze commented 3 months ago

Hi, I'll take a look at your repository and hopefully figure out what's going wrong here. It would help me if you give a full list of steps to reproduce, sounds like if you are having various issues.

Kind regards Mike

Update

Ok, with your project, I'm able to see the errors now. I still investigate what happens, first issue is the test itself is not found by the test discovery.

The test discover can't find your tests because of misleading test root folder. The default folder is test but your tests are located under Tests You need to change your test root folder to enable finding tests. image But it should work also when using the context menu to run/debug tests

When you develop with C# I guess you are using a different IDE to edit your classes. You know about the gdunit4.test.adapter? e.g. on Rider image

Checkout the gdUnit4Net project and supported IDE's

You need to extend your project by the this lines.

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
    <PackageReference Include="gdUnit4.api" Version="4.2.*" />
    <PackageReference Include="gdUnit4.test.adapter" Version="1.*" />
  </ItemGroup>

issues

https://github.com/MikeSchulze/gdUnit4/issues/517 https://github.com/MikeSchulze/gdUnit4/issues/518