mikeschulze / gdunit4net Goto Github PK
View Code? Open in Web Editor NEWA Godot C# Unit Test Framework.
License: MIT License
A Godot C# Unit Test Framework.
License: MIT License
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]
Describe What
With introducing the .editorconfig
we need to format the code to resolve the warnings
Describe What
The ci pipeline is currently disabled and obsolete.
Rebuild the ci-pr workflow to use the testrunner
1.2.0 (Pre Release/Master branch)
v4.2.1.stable.mono.official [b09f793f5]
Windows 11
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
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 19Html 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.trxFailed! - 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
No response
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);
}
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;
}
}
src\core\SceneRunner.cs
Der Typ- oder Namespacename "GDScriptFunctionState" wurde nicht gefunden (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis). [gdUnit4Mono]
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
I want to support the VSC test adapter
(https://github.com/Microsoft/vstest-docs/blob/main/RFCs/0004-Adapter-Extensibility.md)
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");
}
}
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();
}
}
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.
4.2.2 (Latest Release)
Godot Engine v4.2.1.stable.mono.official.b09f793f5
ALL
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
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>>();
}
}
No response
The API differs between GDScript and C# and needs to be reconciled.
partial missing on C#
GdUnitDictionaryAssert vs IDictionaryAssert ✅
GdUnitArrayAssert vs IEnumerableAssert ✅
GdUnitFloatAssert vs INumberAssert ✅
currently not planned to support on C#
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
Minimal reproduction project:
N/A since project is currently private
It would be good to show by an example project how to use the GdUnit4 C# API.
Add an example project which uses the NuGet packages
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
<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" />
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>
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.
4.2.3
v4.2.2.stable.mono.official [15073afe3]
Windows 11
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
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
No response
add new input action methods to ISceneRunner
API
ISceneRunner SimulateActionPressed(string action);
ISceneRunner SimulateActionPress(string action);
ISceneRunner SimulateActionRelease(string action);
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
}]
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.
4.2.2-rc1 (Pre Release/Master branch)
v4.2.1.stable.mono.official.b09f793f5
Windows, Unix
When using <DisplayName>FullyQualifiedName</DisplayName>
in .settings
there a no tests discovered anymore.
Example:
.settings
to <DisplayName>FullyQualifiedName</DisplayName>
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
.settings
to <DisplayName>SimpleName</DisplayName>
I
No response
We want to support the newest .net version.
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.
4.2.1 (Pre Release/Master branch)
v4.2.1.stable.mono.official [b09f793f5]
Windows 11
Using https://github.com/MikeSchulze/gdUnit4/releases/tag/v4.2.1 with 4.2.1 NuGet package.
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.
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);
}
}
test
folder and select run Testsuites
.A lot of errors based on GdScript2 changes object vs Godot.Variant
Revise the used arguments/types and change it to Godot.Variant
The used GdUnit4 version:
v4.2.1.stable.mono.official [b09f793f5]
The used Godot version:
gdunit.api 4.2.0-rc.202402192051
OS including version:
ALL
Describe the bug
With the latest release the IsTestSuite
do not detect test suites anymore
Steps to Reproduce
Open Godot editor and try to run a c# test via context menu, nothing happens
Is your feature request related to a problem? Please describe.
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
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
SimulateMouseMoveRelative
and SimulateMouseMoveAbsolute
4.2.2.0 (Latest Release)
Godot Engine v4.2.1.stable.mono.official.b09f793f5
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
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)
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);
}
}
No response
The used GdUnit4 version:
GdUnit4 v4.2.1
The used Godot version:
Godot v4.2.1
OS including version:
Windows 11
Visual Studio Code 1.85.1
Describe the bug
See here microsoft/vscode-dotnettools#841
Steps to Reproduce
Open the TEST EXPLORER
and check against .NET TEST EXPLORER
4.2.1 (Pre Release/Master branch)
v4.2.1 Mono
Windows 10
In last version (updated by the addon and/or right from AssetLib) using C# Mono build MSBuild return an errors:
No response
4.2.1 (Pre Release/Master branch)
v4.2.1.stable.mono.official [b09f793f5]
macOS Ventura
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:
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.
No response
We want to rename the project to a more reflective name, Mono
is outdated, and we want to prefer to say Net
4.2.0 (Latest Release)
Godot v4.2.stable.mono [Official Build]
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)
GDUnit4 freezes in the middle of running tests for my project. | Running the test in debug mode shows the following error |
---|---|
.Net 8 SDK
is required.1.0.0
release of GDTask.Nuget
(commit 4412a7d)./GDTask.Tests
directory with the official build of Godot Editor v4.2.0 stable.mono
res://test/
directory, and select Run Testsuites
.GDTaskTest_Observable
.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
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.
With release v4.2.2 we complete the missing functionality on listed asserts.
IDictionaryAssert
IEnumerableAssert
INumberAssert
ISceneRunner
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
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.
Minimal reproduction project:
using GdUnit4;
using System.Threading.Tasks;
[TestSuite]
public class prologue_test
{
[TestCase]
public async Task simulate_frame()
{
Assertions.AssertThat(true).IsTrue();
}
}
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
.editorconfig
1.1.1
v4.2.2.stable.mono.official [15073afe3]
Windows 11
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 ==========
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.
No response
Describe What
With introducing the .editorconfig
we need to format the code to resolve the warnings
Convert existing VectorXAsserts into a generic VectorAssert to support all Godot vector types
VectorAssert<T>
Vector2Assert
Vector3Assert
VectorAssert<T>
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
GdUnit4.Tests.Asserts
and press run========== 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.
4.2.3 (Latest Release)
v4.2.2.stable.official [15073afe3]
Windows, Mac, Unix
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.
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_
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.
Run Unit Tests
step to check the content of the test report.https://github.com/microsoft/vstest-docs/blob/main/docs/filter.md
it should be possible to run a test with a given test filter.
dotnet test --filter "FullyQualifiedName~GdUnit4.Tests.Asserts.BoolAssertTest"
The SceneRunner has a lot of issues for renamed input event methods.
It needs also to addapt the big fix from GdUnit3 MikeSchulze/gdUnit3#365
We want to clean up the used actions and run with the new gdunit4-action
1.1.0
v4.2.2.stable.mono.official [15073afe3]
Windows 11
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
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.
No response
The SceneRunnerTest is actually ignored.
see TestRunner.cs
if (testSuite.Name.Equals("SceneRunnerTest"))
continue;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.