Code Monkey home page Code Monkey logo

gdunit4net's People

Contributors

adamlearns avatar mikeschulze avatar taylor-nightingale avatar van800 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gdunit4net's Issues

GD-1: Comparable: DynamicGodotObject not found

src\asserts\Comparable.cs

        private static List<Type> Excludes = new List<Type>() {
            typeof(IntPtr),
            typeof(Godot.DynamicGodotObject)
        };

Der Typ- oder Namespacename "DynamicGodotObject" ist im Namespace "Godot" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.) [gdUnit4Mono]

GD-52: Format the code to C# standard

Describe What
With introducing the .editorconfig we need to format the code to resolve the warnings

AC

  • format the code based on the C# standards
  • remove all warnings.

GD-86: Space in folder name prevents tests from running

The used Test Adapter version

1.2.0 (Pre Release/Master branch)

The used Godot version

v4.2.1.stable.mono.official [b09f793f5]

Operating System

Windows 11

Describe the bug

I expected the test runner to run the tests regardless of the folder path and give me results back. Instead the runner fails to run any tests and just opens the Godot editor with a modal window on top that is shown below

image

Steps to Reproduce

Download this repo to a folder path with no spaces in it, I downloaded it to C:\Temp\gdUnit4Net-master. Open the example scene in the Godot editor (I believe this was required?), then build the whole solution either from the command line or IDE. Add the GODOT_BIN to the .runsettings file and run the tests from commandline or IDE. Example shown below

PS C:\Temp\gdUnit4Net-master\example> dotnet test -s ..runsettings
Determining projects to restore...
All projects are up-to-date for restore.
exampleProject -> C:\Temp\gdUnit4Net-master\example.godot\mono\temp\bin\Debug\exampleProject.dll
Test run for C:\Temp\gdUnit4Net-master\example.godot\mono\temp\bin\Debug\exampleProject.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Failed failed [12 ms]
Error Message:
Expecting: 'True' but is 'False'
Stack Trace:
at Examples.ExampleTest.failed() in C:\Temp\gdUnit4Net-master\example\test\ExampleTest.cs:line 19

Html test results file : C:\Temp\gdUnit4Net-master\example\TestResults\test-result.html
WARNING: Overwriting results file: C:\Temp\gdUnit4Net-master\example\TestResults\test-result.trx
Results File: C:\Temp\gdUnit4Net-master\example\TestResults\test-result.trx

Failed! - Failed: 1, Passed: 1, Skipped: 0, Total: 2, Duration: 15 ms - exampleProject.dll (net8.0)

Change the folder path to contain a space and the test run fails with the modal window shown previously

PS C:\Temp\gdUnit4Net-master space\example> dotnet test -s ..runsettings
Determining projects to restore...
All projects are up-to-date for restore.
exampleProject -> C:\Temp\gdUnit4Net-master space\example.godot\mono\temp\bin\Debug\exampleProject.dll
Test run for C:\Temp\gdUnit4Net-master space\example.godot\mono\temp\bin\Debug\exampleProject.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in C:\Temp\gdUnit4Net-master space\example.godot\mono\temp\bin\Debug\exampleProject.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Html test results file : C:\Temp\gdUnit4Net-master space\example\TestResults\test-result.html
WARNING: Overwriting results file: C:\Temp\gdUnit4Net-master space\example\TestResults\test-result.trx
Results File: C:\Temp\gdUnit4Net-master space\example\TestResults\test-result.trx

Minimal reproduction project

No response

GD-48: `gdunit4.api` Some ArrayAssert methods request.

Is your feature request related to a problem? Please describe.
Check the state of items in a list is very frequent used, so I think we are lacking some methods:
AllTrue, AllFalse, AnyTrue, AnyFalse

Describe the solution you'd like

[TestCase]
public void TestArray()
{
    int[] numbers = Enumerable.Range(0, 10).ToArray();
    AssertArray(numbers).AllTrue(i => i % 2 == 0);
    AssertArray(numbers).AllFalse(i => i % 2 == 0);
    AssertArray(numbers).AnyTrue(i => i % 2 == 0);
    AssertArray(numbers).AnyFalse(i => i % 2 == 0);
}

Describe alternatives you've considered

Additional context

GD-46: Add support for test data points

Is your feature request related to a problem? Please describe.
The TestCase attribute allows defining parameterized tests but is not accepting struct types.

[TestCase(Vector2.One)] ends up in a compile error
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

Check the definition attribute parameter types

Describe the solution you'd like
Instead of using parameterized tests, we should add support for test data points.
This will allow the test writer to provide static test data:

        public static IEnumerable<object[]> StaticData()
        {
            yield return new object[] { Vector2.One, Vector2.One };
            yield return new object[] { Vector3.One, Vector3.One };
        }

        [TestCase]
        [TestDataPoint(nameof(StaticData))]
        public void TestWithDataPoint(Variant value, Variant expected)
        {
            AssertThat(value).IsEqual(expected);
        }

Or defining a test data generator:

        public static IEnumerable<object[]> DataGenerator(string name, int iterations)
        {
            for (int i = 0; i < iterations; i++)
            {
                yield return new object[] { name + "_" + i, $"{name}_{i}" };
            }
        }

        [TestCase]
        [TestDataPoint(nameof(DataGenerator), "aaa", 10)]
        public void TestWithDataGenerator(string value, string expected)
        {
            AssertThat(value).IsEqual(expected);
        }
        ....

Additional context
The TestDataPoint attribute could be defined like:

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class TestDataPoint : TestStageAttribute
    {
        internal string DataPointMethod { get; }
        internal object?[] DataPointParameters { get; } = Array.Empty<object?>();

        public TestDataPoint(string dataPointMethod, params object?[] dataPointParameters) : base("", -1)
        {
            DataPointMethod = dataPointMethod ?? throw new Exception("The parameter 'dataPointMethod' is not set!");
            DataPointParameters = dataPointParameters;
        }
    }

GD-22: Asserting on scene exceptions does not work

The used Godot version:
v4.2.stable.mono.official [46dc27791]

OS including version:
Windows 11 (10.0.22621 Build 22621)

Describe the bug
It is not possible to assert on exceptions that are thrown in a scene's script.

Steps to Reproduce

Given a blank/boilerplate .tscn scene with an attached script that contains the following method:

public void SomeMethodThatThrowsException()
{
    throw new System.Exception("Example message");
}

Example test 1:

[TestSuite]
public class prologue_test
{
    [TestCase]
    public async Task ExceptionIsThrown()
    {
        ISceneRunner runner = ISceneRunner.Load("res://Scenes/TestSceneWithException.tscn");

        var exception = GdUnit4.Assertions.AssertThrown(() =>
        {
            runner.Invoke("SomeMethodThatThrowsException");
        });

        exception.HasMessage("Example message");
    }
}

image

Example test 2:

using GdUnit4;
using System;
using System.Threading.Tasks;

[TestSuite]
public class prologue_test
{
    [TestCase]
    public async Task ExceptionIsThrown()
    {
        ISceneRunner runner = ISceneRunner.Load("res://Scenes/TestSceneWithException.tscn");
        Exception exception = null;

        try
        {
            runner.Invoke("SomeMethodThatThrowsException");
            var scene = runner.Scene();
            var variant = scene.Call("SomeMethodThatThrowsException");
        }
        catch (Exception ex)
        {
            exception = ex;
        }

        Assertions.AssertObject(exception).IsNotNull();
    }
}

image

I appreciate that this may not be an issue with GdUnit4, as it almost seems like the exception is somehow being swallowed by the engine (though in which case, what is the purpose of the AssertThrown assertion?)

Please note that when running the game, I can see that the exception is thrown in the debugger window as expected (provided that I call the exception-throwing method).

Any advice would be appreciated.

GD-87: Using `IsInstanceOf` results in `warning AD0001`

The used API version

4.2.2 (Latest Release)

The used Godot version

Godot Engine v4.2.1.stable.mono.official.b09f793f5

Operating System

ALL

Describe the bug

Using the AssertObject IsInstanceOf validation result into compiler warnings.

CSC: warning AD0001: Analyzer 'Godot.SourceGenerators.MustBeVariantAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [D:\development\workspace\gdUnit4Net\example\exampleProject.csproj::TargetFramework = net8.0]

Using temporary workaround

  <PropertyGroup>
    <!-- Hide Godot.SourceGenerators.MustBeVariantAnalyzer warnings -->
    <NoWarn>$(NoWarn);AD0001</NoWarn>
  </PropertyGroup>

l create an Godot issue godotengine/godot#91345

Steps to Reproduce

Example:

namespace Examples;

using GdUnit4;
using static GdUnit4.Assertions;

[TestSuite]
public class ExampleTest
{

    [TestCase]
    public void IsInstanceOf()
    {
        var a = AssertThat(Variant.From((sbyte)-1));
        AssertObject(a).IsInstanceOf<INumberAssert<int>>();
    }
}

Minimal reproduction project

No response

GD-10: Complete missing features from GdUnit4 GdScript asserts

Description

The API differs between GDScript and C# and needs to be reconciled.

Acceptance criteria

  • Review of GDScript assets and addition of missing functionalities

API differences

partial missing on C#

  • GdUnitDictionaryAssert vs IDictionaryAssert

    • contains_same_key_value
    • contains_same_keys
    • not_contains_same_keys
    • is_not_same
    • is_same
  • GdUnitArrayAssert vs IEnumerableAssert

    • contains_same
    • contains_same_exactly
    • contains_same_exactly_in_any_order
    • is_not_same
    • is_same
    • not_contains
    • not_contains_same
  • GdUnitFloatAssert vs INumberAssert

    • is_equal_approx

currently not planned to support on C#

  • GdUnitFileAssert
  • GdUnitFuncAssert
  • GdUnitGodotErrorAssert

GD-292: SimulateKeyPressed for SceneRunner not working

The used GdUnit4 version:
https://github.com/MikeSchulze/gdUnit4/releases/tag/v4.2.0

The used Godot version:
Godot Engine v4.2.stable.mono.official.46dc27791

OS including version:
Vulkan API 1.3.242 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 1650
Windows 10 - 10.0.19045 Build 19045

Describe the bug
First I show manual Space, which creates 2 nodes and passes.

Then I use the SimulateKeyPressed on the SceneRunner to automate the key press, which does not create a second node. Instead I see (no focus set):

ActivateTimeFactor: Engine.TimeScale=1, Engine.PhysicsTicksPerSecond=60
set time factor: 1
set physics iterations_per_second: 60
    no focus set
    process event <Node2D#81486939523> (PlayerTests) <- Space
    no focus set
    process event <Node2D#81486939523> (PlayerTests) <- Space

Steps to Reproduce
gdunit4_tests

Minimal reproduction project:
N/A since project is currently private

GD-47: `gdunit4.test.adapter` Timeout when attempting to run tests on addon project using .NET 8.0

The used GdUnit4 version:

The used Godot version:

OS including version:
Windows 10

Describe the bug
When attempting to run or view unit tests on my addon project, I receive the following error:

Failed to negotiate protocol, waiting for response timed out after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.

Steps to Reproduce

  1. Create a new Addons Project in Godot 4.2.1
  2. Upgrade your solution to .NET 8.0
  3. Add the following to the csproj:
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftSdkVersion)" />
    <PackageReference Include="gdUnit4.api" Version="4.2.1" />
    <PackageReference Include="gdUnit4.test.adapter" Version="1.0.0" />
  1. Create a unit test.
  2. Build the solution
  3. Error, and no tests appear in the test sln

Minimal reproduction project:

csproj:

<Project Sdk="Godot.NET.Sdk/4.2.1">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <EnableDynamicLoading>true</EnableDynamicLoading>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>
  <ItemGroup>
    <Content Include="icon.png" />
  </ItemGroup>
  <ItemGroup>
    <None Include=".runsettings" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftSdkVersion)" />
    <PackageReference Include="gdUnit4.api" Version="4.2.1" />
    <PackageReference Include="gdUnit4.test.adapter" Version="1.0.0" />
  </ItemGroup>
</Project>

.runsettings:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
    <RunConfiguration>
        <ResultsDirectory>./TestResults</ResultsDirectory>
        <TargetFrameworkVersion>net8.0</TargetFrameworkVersion>
        <TestSessionTimeout>180000</TestSessionTimeout>
        <TreatNoTestsAsError>true</TreatNoTestsAsError>
    </RunConfiguration>

    <LoggerRunSettings>
        <Loggers>
            <Logger friendlyName="console" enabled="True">
                <Configuration>
                    <Verbosity>detailed</Verbosity>
                </Configuration>
            </Logger>
            <Logger friendlyName="html" enabled="True">
                <Configuration>
                    <LogFileName>test-result.html</LogFileName>
                </Configuration>
            </Logger>
            <Logger friendlyName="trx" enabled="True">
                <Configuration>
                    <LogFileName>test-result.trx</LogFileName>
                </Configuration>
            </Logger>
        </Loggers>
    </LoggerRunSettings>

    <GdUnit4>
        <Parameters></Parameters>
        <DisplayName>FullyQualifiedName</DisplayName>
    </GdUnit4>
</RunSettings>

FileStructure:
image

HelloWorld.cs:

using GdUnit4;
using static GdUnit4.Assertions;

namespace GodotVoipNet.Tests;

[TestSuite]
public class HelloWorld
{
    [TestCase]
    public void Test()
    {
        AssertBool(true).IsTrue();
    }
}

To my knowledge, I have followed the steps required to correctly install the api and the test explorer. Additionally, I have taken the .runtime file, and set my csproj according to the example. If I missed something here I would be happy to try it, but currently my tests are unable to run.

GD-91: `SceneRunner.SimulateFrames` doesn't propagate exceptions

The used Test API version

4.2.3

The used Godot version

v4.2.2.stable.mono.official [15073afe3]

Operating System

Windows 11

Describe the bug

Loading a scene with ISceneRunner.Load and letting it run a little while with SimulateFrames doesn't propagate any possible exceptions so they can be asserted against in the test

Steps to Reproduce

Have any simple scene and attach the following script to any node

using Godot;
using System;

namespace GdUnitSetup;

public partial class Exceptor : Node {
	public override void _Process(double delta) {
		SeeIfBedtime((int)Time.GetTicksMsec());
	}

	public void SeeIfBedtime(int ticks) {
		if (ticks > 200) {
			throw new ArgumentException("Past my bedtime");
		}
	}
}

Then have a test class like

using GdUnit4;
using GdUnit4.Asserts;
using System.Threading.Tasks;

namespace GdUnitSetup.Tests;

[TestSuite]
public class ExceptionTest {
	[TestCase]
	public async Task Test1() {
		ISceneRunner runner = ISceneRunner.Load("res://Scenes/Scene1.tscn");

		IExceptionAssert exceptionAssert = await Assertions.AssertThrown(runner.SimulateFrames(100));
		//IExceptionAssert exceptionAssert = await Assertions.AssertThrown(runner.InvokeAsync("SeeIfBedtime", 500));

		Assertions.AssertObject(exceptionAssert).IsNotNull();
	}
}

Running the scene from the editor or running the tests in debug mode from Visual Studio will print the exceptions to console so they are thrown. But the test will always fail as the exceptionAssert will always be null. I found #22 from which the commented out line is from. If that is swapped to be running, then the test will pass.

Please advice if I'm trying to assert the SimulateFrames exceptions wrong somehow, I just think it would be exceedingly useful to be able to assert that no exceptions or a specific exception were thrown during the running of a scene

Minimal reproduction project

No response

GD-89: Add support for input actions on `SceneRunner`

A Task is not a bug or feature request

Description

  • with details are new functionality added to the GDScript variant and needs to be implemented to for the C# version

Acceptance criteria

add new input action methods to ISceneRunner API

ISceneRunner SimulateActionPressed(string action);

ISceneRunner SimulateActionPress(string action);

ISceneRunner SimulateActionRelease(string action);

GD-2: SignalAssert: fix signal connection

src\asserts\SignalAssert.cs

[{
"resource": "/d:/develop/workspace/gdUnit4Mono/src/asserts/SignalAssert.cs",
"owner": "csharp",
"code": "CS1501",
"severity": 8,
"message": "Keine Überladung für die IsConnected-Methode nimmt 3 Argumente an. [gdUnit4Mono]",
"source": "csharp",
"startLineNumber": 90,
"startColumn": 30,
"endLineNumber": 90,
"endColumn": 41
},{
"resource": "/d:/develop/workspace/gdUnit4Mono/src/asserts/SignalAssert.cs",
"owner": "csharp",
"code": "CS1501",
"severity": 8,
"message": "Keine Überladung für die Connect-Methode nimmt 4 Argumente an. [gdUnit4Mono]",
"source": "csharp",
"startLineNumber": 91,
"startColumn": 29,
"endLineNumber": 91,
"endColumn": 36
},{
"resource": "/d:/develop/workspace/gdUnit4Mono/src/asserts/SignalAssert.cs",
"owner": "csharp",
"code": "CS1501",
"severity": 8,
"message": "Keine Überladung für die IsConnected-Methode nimmt 3 Argumente an. [gdUnit4Mono]",
"source": "csharp",
"startLineNumber": 99,
"startColumn": 34,
"endLineNumber": 99,
"endColumn": 45
},{
"resource": "/d:/develop/workspace/gdUnit4Mono/src/asserts/SignalAssert.cs",
"owner": "csharp",
"code": "CS1501",
"severity": 8,
"message": "Keine Überladung für die Connect-Methode nimmt 4 Argumente an. [gdUnit4Mono]",
"source": "csharp",
"startLineNumber": 100,
"startColumn": 33,
"endLineNumber": 100,
"endColumn": 40
},{
"resource": "/d:/develop/workspace/gdUnit4Mono/src/asserts/SignalAssert.cs",
"owner": "csharp",
"code": "CS1501",
"severity": 8,
"message": "Keine Überladung für die Disconnect-Methode nimmt 3 Argumente an. [gdUnit4Mono]",
"source": "csharp",
"startLineNumber": 120,
"startColumn": 33,
"endLineNumber": 120,
"endColumn": 43
},{
"resource": "/d:/develop/workspace/gdUnit4Mono/src/asserts/SignalAssert.cs",
"owner": "csharp",
"code": "CS8600",
"severity": 4,
"message": "Das NULL-Literal oder ein möglicher NULL-Wert wird in einen Non-Nullable-Typ konvertiert. [gdUnit4Mono]",
"source": "csharp",
"startLineNumber": 244,
"startColumn": 55,
"endLineNumber": 244,
"endColumn": 146
}]

GD-78: Add Support for `.Net GDExtension` point

Is your feature request related to a problem? Please describe.
With Godot.Bindings we are able to provide gdunit4.api as a Godot extension point.

Describe the solution you'd like
Use the new project godot-dotnet to build an GDExtension.
This will allow us to use the api direct in Godot.

Describe alternatives you've considered
The alternative is actually to load the code as CSharpScript and build an GDScript bridge to access the C# API.

Additional context
Add any other context or screenshots about the feature request here.

GD-76: Using `<DisplayName>FullyQualifiedName</DisplayName>` in `.settings` results in no tests found

The used API version

4.2.2-rc1 (Pre Release/Master branch)

The used Godot version

v4.2.1.stable.mono.official.b09f793f5

Operating System

Windows, Unix

Describe the bug

When using <DisplayName>FullyQualifiedName</DisplayName> in .settings there a no tests discovered anymore.

Steps to Reproduce

Example:

  1. use example project
  2. edit the .settings to <DisplayName>FullyQualifiedName</DisplayName>
  3. run the tests from command line
    dotnet test --no-build --settings .runsettings
Testlauf für "D:\development\workspace\gdUnit4Mono\example\.godot\mono\temp\bin\Debug\exampleProject.dll" (.NETCoreApp,Version=v8.0)
Microsoft (R) Testausführungs-Befehlszeilentool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.

Die Testausführung wird gestartet, bitte warten...
Insgesamt 1 Testdateien stimmten mit dem angegebenen Muster überein.
In "D:\development\workspace\gdUnit4Mono\example\.godot\mono\temp\bin\Debug\exampleProject.dll" ist kein Test verfügbar. Stellen Sie sicher, dass die Testdiscoverer und -executors registriert und die Versionseinstellungen für Plattform und Framework richtig sind, und wiederholen Sie den Vorgang.
HTML-Testergebnisdatei: D:\development\workspace\gdUnit4Mono\example\TestResults\test-result.html
WARNUNG: Ergebnisdatei wird überschrieben: D:\development\workspace\gdUnit4Mono\example\TestResults\test-result.trx
Ergebnisdatei: D:\development\workspace\gdUnit4Mono\example\TestResults\test-result.trx
  1. edit the .settings to <DisplayName>SimpleName</DisplayName>
  2. re-run the tests from command line, tests are discovered

I

Minimal reproduction project

No response

GD-62: Add full `.NET8` support

A Task is not a bug or feature request

Description

We want to support the newest .net version.

Acceptance criteria

  • support .NET7
  • support .NET8

GD-64: It might be better to use `LaunchProcessWithDebuggerAttached` instead of Start Process and `AttachDebuggerIfNeed`

Not something critical right now, but I decided to note it down.

Describe What
This is the code is in question:
https://github.com/van800/gdUnit4Mono/blob/a9038f91fc33c3a437d39d4714b13a12b06cae5e/testadapter/src/execution/TestExecutor.cs#L84 GdUnit4.TestAdapter.Execution.TestExecutor.Run
Consider letting the debugger to start Godot (with LaunchProcessWithDebuggerAttached api) from the very beginning and use the pid to get the process to do everything, which you already do now.

Describe Why
JIT may apply certain optimizations when the application is started without debugging. This may cause some problems with debugger evaluation of values.

GD-357: Parameterized test cases are not run from Godot Editor GdUnit4 inspector

The used GdUnit4 version

4.2.1 (Pre Release/Master branch)

The used Godot version

v4.2.1.stable.mono.official [b09f793f5]

Operating System

Windows 11
Using https://github.com/MikeSchulze/gdUnit4/releases/tag/v4.2.1 with 4.2.1 NuGet package.

Describe the bug

For C# test scripts, parameterized test cases do not appear to be running. In the GDUnit tab, the test cases remain in white as seen below.

image

I do not believe this is just a results display issue since opening a scene via the scene runner also has no visible effect. The following is the script from the minimal reproduction project:

using GdUnit4;
using System.Threading.Tasks;

[TestSuite]
public class CSharpTests
{
    [TestCase(1, 2, 3, 6)]
    [TestCase(3, 4, 5, 12)]
    [TestCase(6, 7, 8, 21)]
    public void TestCaseArguments(int a, int b, int c, int expect)
    {
        Assertions.AssertThat(a + b + c).IsEqual(expect);
    }

    [TestCase(1, 2, 3, 6)]
    [TestCase(3, 4, 5, 12)]
    [TestCase(6, 7, 8, 21)]
    public async Task TestCaseArgumentsWithScene(int a, int b, int c, int expect)
    {
        var runner = ISceneRunner.Load("res://test_scene.tscn", true, true);
        await runner.AwaitMillis(10000);
        Assertions.AssertThat(a + b + c).IsEqual(expect);
    }
}

Steps to Reproduce

  1. Open minimal reproduction project in Godot.
  2. In Visual Studio, build the project and make sure the gdUnit4 package is enabled in the Godot project settings.
  3. Right click test folder and select run Testsuites.
  4. In GDUnit tab, results for CSharpTests suite should be as previously described.

Minimal reproduction project

https://github.com/mpewsey/gdUnit4ParameterizedTestsBug

GD-49: Provide the full stack trace on test fail

Is your feature request related to a problem? Please describe.
image
Consider such test with composite Assert calls. Only talling me line 50 failed is not enough.

Describe the solution you'd like
Print the full stacktrace from the Test to the failed line.

Describe alternatives you've considered
none

Additional context
none

GD-32: `SceneRunner` add missing `SimulateMouseMoveRelative` and `SimulateMouseMoveAbsolute`

A Task is not a bug or feature request

Description

On GdUnit4 (GDScript) the API for scene runner provides two functions that missed in the C# API


## Simulates a mouse move to the relative coordinates (offset).[br]
## [member relative] : The relative position, indicating the mouse position offset.[br]
## [member time] : The time to move the mouse by the relative position in seconds (default is 1 second).[br]
## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]
@warning_ignore("unused_parameter")
func simulate_mouse_move_relative(relative: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner:
	await Engine.get_main_loop().process_frame
	return self


## Simulates a mouse move to the absolute coordinates.[br]
## [member position] : The final position of the mouse.[br]
## [member time] : The time to move the mouse to the final position in seconds (default is 1 second).[br]
## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]
@warning_ignore("unused_parameter")
func simulate_mouse_move_absolute(position: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner:
	await Engine.get_main_loop().process_frame
	return self

Acceptance criteria

  • implement SimulateMouseMoveRelative and SimulateMouseMoveAbsolute

GD-84: `AssertThat` dynamic assert type resolving do not work for `enum` and Godot `Variants`

The used API version

4.2.2.0 (Latest Release)

The used Godot version

Godot Engine v4.2.1.stable.mono.official.b09f793f5

Operating System

Windows 11

used packages
[net8.0]:
Paket oberster Ebene Angefordert Aufgelöst

gdUnit4.api 4.2.- 4.2.2
gdUnit4.test.adapter 1.- 1.1.0
Godot.SourceGenerators 4.2.1 4.2.1
GodotSharp 4.2.1 4.2.1
GodotSharpEditor 4.2.1 4.2.1
Microsoft.NET.Test.Sdk 17.9.0 17.9.0

Transitives Paket Aufgelöst

Castle.Core 5.1.1
CommandLineParser 2.9.1
coverlet.collector 6.0.0
Microsoft.CodeAnalysis.Analyzers 3.3.4
Microsoft.CodeAnalysis.Common 4.9.2
Microsoft.CodeAnalysis.CSharp 4.9.2
Microsoft.CodeCoverage 17.9.0
Microsoft.TestPlatform.AdapterUtilities 17.9.0
Microsoft.TestPlatform.ObjectModel 17.9.0
Microsoft.TestPlatform.TestHost 17.9.0
Moq 4.18.4
Newtonsoft.Json 13.0.3
System.Collections.Immutable 8.0.0
System.Diagnostics.EventLog 6.0.0
System.Reflection.Metadata 8.0.0
System.Runtime.CompilerServices.Unsafe 6.0.0

Describe the bug

When using the API in the suggested way with AssertThat I run into runtime errors on objects like Enum and Variant.

// throws an error
AssertThat(TestEnum.Foo).IsEqual(TestEnum.Foo);
// works
AssertObject(TestEnum.Foo).IsEqual(TestEnum.Foo);
'object' does not contain a definition for 'IsEqual'
   at CallSite.Target(Closure, CallSite, Object, TestEnum)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
   at Example.Tests.API.Asserts.AssertionsTest.AssertThatVariants() in D:\development\workspace\gdUnit4Net\example\test\api\AssertionsTest.cs:line 31
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Steps to Reproduce

Use the example to show the error

namespace Example.Tests.API.Asserts;

using Godot;
using GdUnit4;
using GdUnit4.Asserts;

using static GdUnit4.Assertions;

[TestSuite]
public class ExampleTest
{

    [TestCase]
    public void AssertThatOn()
    {
        // works
        AssertObject(TestEnum.Foo).IsEqual(TestEnum.Foo);
        // fails
        AssertThat(TestEnum.Foo).IsEqual(TestEnum.Foo);
        // fails
        AssertThat(Variant.From(11)).IsEqual(11);
    }
}

Minimal reproduction project

No response

GD-39: `CS0246: The type or namespace name 'GdUnit4' could not be found`

The used GdUnit4 version

4.2.1 (Pre Release/Master branch)

The used Godot version

v4.2.1 Mono

Operating System

Windows 10

Describe the bug

In last version (updated by the addon and/or right from AssetLib) using C# Mono build MSBuild return an errors:

  • CS0246: The type or namespace name 'GdUnit4' could not be found (are you missing a using directive or an assembly reference?) \game\addons\gdUnit4\src\mono\GdUnit4CSharpApi.cs(4,7)
  • CS0246: The type or namespace name 'GdUnit4' could not be found (are you missing a using directive or an assembly reference?) \game\addons\gdUnit4\src\mono\GdUnit4CSharpApi.cs(15,16)

Steps to Reproduce

  1. Install the addon in latest Godot Mono Build
  2. Build Project

Minimal reproduction project

No response

GD-57: Await on C# executor throws error on non-existing signal `ExecutionCompleted`

The used GdUnit4 version

4.2.1 (Pre Release/Master branch)

The used Godot version

v4.2.1.stable.mono.official [b09f793f5]

Operating System

macOS Ventura

Describe the bug

When running a long set of C# test suites, after ~50% of them complete and pass I hit the following error. Once this fires, the tests no longer run as the runner has crashed.

E 0:00:11:0413 GdUnitRunner.gd:83 @ _process(): In Object of type 'RefCounted': Attempt to connect nonexistent signal '' to callable 'GDScriptFunctionState::_signal_callback'. <C++ Error> Condition "!signal_is_valid" is true. Returning: ERR_INVALID_PARAMETER <C++ Source> core/object/object.cpp:1344 @ connect() <Stack Trace> GdUnitRunner.gd:83 @ _process()

Some context showing where the error was triggered is in the screenshot below:

Screenshot 2024-03-06 at 11 15 25 PM

Steps to Reproduce

Very difficult to nail this down to a smaller test case. I only saw this begin after accumulating test suites after some time. Attempting to disable certain test suites only makes the problem happen on the next test suite after the disabled one.

Minimal reproduction project

No response

GD-80: Rename repository from `gdUnit4Mono` to `gdUnit4Net`

A Task is not a bug or feature request

Description

We want to rename the project to a more reflective name, Mono is outdated, and we want to prefer to say Net

Acceptance criteria

  • rename the repository
  • fix all the links
  • fix the repository references in the assemblies

GD-42: `C#` Not all tests can be executed, the run stops at some point

The used GdUnit4 version

4.2.0 (Latest Release)

The used Godot version

Godot v4.2.stable.mono [Official Build]

Operating System

Godot v4.2.stable.mono - Windows 10.0.17763 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 31.0.15.4601) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Describe the bug

GDUnit4 freezes in the middle of running tests for my project. Running the test in debug mode shows the following error
image image

Steps to Reproduce

  1. Environment Setup: .Net 8 SDK is required.
  2. Clone the source code for the 1.0.0 release of GDTask.Nuget (commit 4412a7d)
  3. Open the ./GDTask.Tests directory with the official build of Godot Editor v4.2.0 stable.mono
  4. From the FileSystem, right-click the res://test/ directory, and select Run Testsuites.
  5. Expecting the running tests stops at GDTaskTest_Observable.

Minimal reproduction project

Fork or Clone the GDTask.Nuget repo and switch to the commit labeled with v1.0.0, or download the source code for the Release v1.0.0

GD-12: Rebuilding the project by splitting it into library and test projects

Describe What
The project should be splitted into pure library and test coverage.

Describe Why
Currently both are mixed which makes testing of the actual library not possible.

AC

  • splitt into
    • GdUnitMono4Api library project (pure API without test code)
    • GdUnitMono4Test test project, (loading the library and test)

GD-68: Update C# documentations

A Task is not a bug or feature request

Description

With release v4.2.2 we complete the missing functionality on listed asserts.

IDictionaryAssert

  • ContainsSameKeyValue
  • ContainsSameKeys
  • NotContainsSameKeys
  • IsNotSame
  • IsSame

IEnumerableAssert

  • ContainsSame
  • ContainsSameExactly
  • ContainsSameExactlyInAnyOrder
  • IsNotSame
  • IsSame
  • NotContains
  • NotContainsSame

INumberAssert

  • IsEqualApprox

ISceneRunner

  • SimulateMouseMoveAbsolute
  • SimulateMouseMoveRelative

Update api version to 4.2.2 and adapter to 1.0.1

Add documentation to describe the use with JetBrains Rider
https://github.com/JetBrains/godot-support?tab=readme-ov-file
https://github.com/van800/Godot421GdUnitExample?tab=readme-ov-file

GD-21: Debugging via external editor is not currently possible

The used Godot version:

v4.2.stable.mono.official [46dc27791]

OS including version:

Windows 11 (10.0.22621 Build 22621)

Describe the bug
Debugger does not get attached and breakpoints are never triggered. Please note that regular in-game debugging via VS Code does work.

Steps to Reproduce
When setting a breakpoint in VS Code and subsequently pressing the debug button, the test runs but does not attach to the debugger.

image

image

image

Minimal reproduction project:

using GdUnit4;
using System.Threading.Tasks;

[TestSuite]
public class prologue_test
{
    [TestCase]
    public async Task simulate_frame()
    {
        Assertions.AssertThat(true).IsTrue();
    }
}

GD-6: Update project to GodotSharp v4.1.0

Describe What
We need to update the project to the lates GodotSharp version.

Describe Why
The current build is based on an outdated version and needs to be updated.

Dev hints

GD-51: Use `.editorconfig` to format the code to C# standard

Is your feature request related to a problem? Please describe.
The code is not formatted to the c# standards and needs to be formatted.

Describe the solution you'd like
There is a standard formatting we can use editorconfig-vscode

AC

  • set up the project to use the .editorconfig
  • install the required extensions
  • format all classes and fix the warnings.

GD-96: Methods with a single parameterized test case are not executed

The used Test Adapter version

1.1.1

The used Godot version

v4.2.2.stable.mono.official [15073afe3]

Operating System

Windows 11

Describe the bug

I was starting to add parameters for my test method and added the first TestCase. Running the tests I expected all the tests, including the one with a single TestCase to be run. But, that test is not run and VS's Output window shows this in the Tests dropdown:

Building Test Projects
========== Starting test run ==========
Start executing tests, 1 TestCases total.
Current directory set to: C:\Users\User\Documents\Godot Projects\Conveyorer
Run with args --path . res://gdunit4_testadapter/TestAdapterRunner.tscn --testadapter --configfile="C:\Users\User\Documents\Godot Projects\Conveyorer\GdUnitRunner_5b0e82a4-759e-42e2-9e8d-e96eeeb2b2c0.cfg"
stdout: Godot Engine v4.2.2.stable.mono.official.15073afe3 - https://godotengine.org
stdout: Vulkan API 1.3.262 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon RX 6600M
stdout: Load testsuite C:\Users\User\Documents\Godot Projects\Conveyorer\UnitTests\SingleNodeTests.cs
stdout: Testrun ends with exit code: 100, FailFast:False
Godot ends with exit code: 100
Run TestRunner ends with 100
========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 975 ms ==========

Steps to Reproduce

Have a working test setup. Add the test below and confirm it runs correctly for both parameters

[TestCase(true)]
[TestCase(false)]
public void ParametrisedTest(bool value) {
	Assertions.AssertBool(value).IsTrue();
}

Then comment out either TestCase attribute, compile, rerun tests. The test method is not run.

Minimal reproduction project

No response

GD-44: Cancel not propagated on `C# Dev Kit Test Explorer`

The used GdUnit4 version:
GdUnit4Mono 4.2.1

The used Godot version:
Godot 4.2.1

OS including version:
Windows 11

Describe the bug
Using the gdunit4.test.adapter in Visual Studio Code and C# Dev Kit.
When running the tests from the "Test Explorer" the cancel do not kill the child Godot process.

microsoft/vscode-dotnettools#947

Steps to Reproduce

  • Open the TEST EXPLORER
  • Select GdUnit4.Tests.Asserts and press run
  • Wait until tests ar started and press the cancel button on the test explorer
    The test looks like are canceld
    image
========== Starting test run ==========
Start executing tests, 131 TestCases total.
Run tests -------->
stdout: Godot Engine v4.2.1.stable.mono.official.b09f793f5 - https://godotengine.org
stdout: Vulkan API 1.3.260 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 4070 Ti
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\AssertionsTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\BoolAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\DictionaryAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\EnumerableAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\NumberAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\ObjectAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\SignalAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\StringAssertTest.cs
stdout: Load testsuite D:\development\workspace\gdUnit4Mono\test\src\asserts\Vector2AssertTest.cs
========== Test run aborted: 19 Tests (19 Passed, 0 Failed, 0 Skipped) run in < 1 ms ==========

But the Godot test runner process is still running until all tests are finished.

GD-94: The asserts should consider `ToString()` to generate better error messages when comparing objects.

The used API version

4.2.3 (Latest Release)

The used Godot version

v4.2.2.stable.official [15073afe3]

Operating System

Windows, Mac, Unix

Describe the bug

It is actually hard to read error messages when comparing objects.
e.g. a test to verify an array contains the expected objects

    private sealed class TestClass
    {
        public string Value { get; }

        public TestClass(string value) => Value = value;

        public override string ToString() => $"Value:{Value}";
    }

    [TestCase]
    public void Foo()
    {
        var objectA = new TestClass("aaa");
        var objectB = new TestClass("bbb");
        var data = new object[] { objectA, objectB };

        AssertThat(data).ContainsExactlyInAnyOrder(new TestClass("aaa"), objectA, objectB);
    }

The error current looks like:

Expecting contains exactly elements:
    [<GdUnit4.Tests.Asserts.AssertionsTest+TestClass>(id: 19299281), <GdUnit4.Tests.Asserts.AssertionsTest+TestClass>(id: 39475801)]
 do contains (in any order)
    [<GdUnit4.Tests.Asserts.AssertionsTest+TestClass>(id: 19737894), <GdUnit4.Tests.Asserts.AssertionsTest+TestClass>(id: 19299281), <GdUnit4.Tests.Asserts.AssertionsTest+TestClass>(id: 39475801)]
 but could not find elements:
    [<GdUnit4.Tests.Asserts.AssertionsTest+TestClass>(id: 19737894)]
   at GdUnit4.Tests.Asserts.AssertionsTest.Foo() in D:\development\workspace\gdUnit4Net\test\src\asserts\AssertionsTest.cs:line 179

We can only differentiate based on the given object ID, but we don't understand the real difference.
The ToString() is ignored to build the message, this would very helpfully to understand the objects be compared.

Steps to Reproduce

Use the example from the description and check the error message.

The error message should respect the ToString() to build the error message.
It should be:

Expecting contains exactly elements:
    [Value:aaa (objId: 43423319), Value:bbb (objId: 55265559)]
 do contains (in any order)
    [Value:aaa (objId: 27627990), Value:aaa (objId: 43423319), Value:bbb (objId: 55265559)]
 but could not find elements:
    [Value:aaa (objId: 27627990)]
   at GdUnit4.Tests.Asserts.AssertionsTest.Foo() in D:\development\workspace\gdUnit4Net\test\src\asserts\AssertionsTest.cs:line 179```

### Minimal reproduction project

_No response_

GD-74: Improve the CI workflow for job `unit-test-example` by validate the test report

A Task is not a bug or feature request

Description

The current job unit-test-example executes the test and forces the step to always end with success.
We have done this so as not to interrupt the job.
But we forgot a validation step right after the test results that checks the expected test results.

Acceptance criteria

  • Add a validation step after the Run Unit Tests step to check the content of the test report.
  • If the report matches the expected result, it ends with success, otherwise with a dedicated error.

GD-90: Aborting test run from Visual Studio causes `GdUnitRunner` file to persist

The used Test Adapter version

1.1.0

The used Godot version

v4.2.2.stable.mono.official [15073afe3]

Operating System

Windows 11

Describe the bug

Running tests any which way I expect that after the run is complete, the GdUnitRunner_{GUID here}.cfg file is deleted. Instead the file remains, clogging up the project folder and git changes

Steps to Reproduce

Run tests from Visual Studio using the "Debug Tests" menu option from the right click menu and have a breakpoint set in the test method. Wait for the breakpoint to be hit and the execution halted and then, instead of continuing the run by clicking the Continue with the green arrow, press the "Stop debugging" with the red square.

Minimal reproduction project

No response

GD-9: Fix SceneRunnerTest

A Task is not a bug or feature request

Description

The SceneRunnerTest is actually ignored.
see TestRunner.cs

                if (testSuite.Name.Equals("SceneRunnerTest"))
                    continue;

Acceptance criteria

  • bring the SceneRunnerTest back to status green

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.