Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
898b56f
Setup gdUnit4
valkyrienyanko Feb 8, 2026
79d7eda
Add ServerClientConnects test
valkyrienyanko Feb 8, 2026
6001f7b
Fix netcode test by requiring Godot runtime
valkyrienyanko Feb 8, 2026
bf26c71
Commit .runsettings
valkyrienyanko Feb 8, 2026
d109c43
Create build_and_test.yml (#214)
valkyrienyanko Feb 8, 2026
131812a
Go back to net8.0 latest
valkyrienyanko Feb 8, 2026
e428cfa
Merge branch 'gdunit4' of https://github.com/CSharpGodotTools/Templat…
valkyrienyanko Feb 8, 2026
e35ea57
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
e4e19d5
Update NuGet.config with $(RepositoryRoot)
valkyrienyanko Feb 8, 2026
3862903
Update NuGet.config
valkyrienyanko Feb 8, 2026
2dc8f72
Update NuGet.config
valkyrienyanko Feb 8, 2026
1ebcf24
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
a3e95bc
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
914e38e
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
8d4c7a3
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
490aa65
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
f743900
Framework is a submodule so treat it as such
valkyrienyanko Feb 8, 2026
095f96b
Try to find Godot exe
valkyrienyanko Feb 8, 2026
848141b
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
e86ea67
Delete .runsettings
valkyrienyanko Feb 8, 2026
5be5360
Update build_and_test.yml
valkyrienyanko Feb 8, 2026
e0426b5
Create .runsettings
valkyrienyanko Feb 8, 2026
42f6fca
Go back to net9.0 (absolutely required for gdunit)
valkyrienyanko Feb 8, 2026
81def2b
Only use GODOT_BIN .runsettings path on windows
valkyrienyanko Feb 8, 2026
9bd497a
Delete .runsettings
valkyrienyanko Feb 8, 2026
1626b25
Ignore .runsettings file in .gitignore
valkyrienyanko Feb 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://github.com/marketplace/actions/gdunit4-test-runner-action
name: GdUnit4 Tests
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: godot-gdunit-labs/gdUnit4-action@v1
with:
godot-version: '4.6'
godot-status: 'stable'
godot-net: true
paths: 'res://Setup/Testing'
console-verbosity: 'normal'
publish-report: false
upload-report: true
report-name: test-report.xml
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ data_*/
mono_crash.*.json
*.DotSettings.user

# gdUnit4
TestResults/*
!TestResults/.gdignore
gdunit4_testadapter_v5/
.runsettings

# Visual Studio
.vs/*
Properties/*
Expand Down
2 changes: 1 addition & 1 deletion Framework
Submodule Framework updated 0 files
2 changes: 1 addition & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="LocalNugets" value="Framework/Libraries" />
<add key="LocalNugets" value="%GITHUB_WORKSPACE%/Framework/Libraries" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
25 changes: 0 additions & 25 deletions Setup/Testing/Testing.cs

This file was deleted.

1 change: 0 additions & 1 deletion Setup/Testing/Testing.cs.uid

This file was deleted.

6 changes: 0 additions & 6 deletions Setup/Testing/Testing.tscn

This file was deleted.

57 changes: 57 additions & 0 deletions Setup/Testing/Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using GdUnit4;
using static GdUnit4.Assertions;
using Framework.Netcode;
using Framework.Netcode.Examples.Topdown;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Framework;

namespace Template.Setup.Testing;

[TestSuite]
public class Tests
{
[TestCase]
public static void StringToLower()
{
AssertString("AbcD".ToLower()).IsEqual("abcd");
}

[TestCase]
[RequireGodotRuntime]
public static async Task ServerClientConnects()
{
GameServer server = new();
GameClient client = new();

server.Start(25565, 100, new ENetOptions());

Task connectTask = client.Connect("127.0.0.1", 25565, new ENetOptions());

try
{
bool connected = false;
Stopwatch stopwatch = Stopwatch.StartNew();

while (stopwatch.Elapsed < TimeSpan.FromSeconds(2))
{
if (client.IsConnected)
{
connected = true;
break;
}

await Task.Delay(10);
}

AssertBool(connected).IsTrue();
}
finally
{
client.Stop();
server.Stop();
await connectTask;
}
}
}
1 change: 1 addition & 0 deletions Setup/Testing/Tests.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://btn7any5gk0u3
18 changes: 15 additions & 3 deletions Template.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<Project Sdk="Godot.NET.Sdk/4.6.0">
<!-- Project Settings -->
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>13.0</LangVersion>
<!--Required for ImGui-->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableDynamicLoading>true</EnableDynamicLoading>
<!--Prevent use of the global usings feature-->
<ImplicitUsings>false</ImplicitUsings>
<RootNamespace>Template</RootNamespace>
<Nullable>disable</Nullable>
<!-- gdUnit4 requires this -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Disable warnings -->
<!-- CS0108: 'X' hides inherited member 'Y'. Use the new keyword if hiding was intended. Consider the scenario where you want [OnInstantiate] for both derived and inherited types. -->
<!-- IDE0290: Use primary constructor. -->
<NoWarn>CS0108;IDE0290</NoWarn>
<!-- NU1605: Disable warning of invalid/incompatible GodotSharp version (gdUnit4 recommends this) -->
<NoWarn>NU1605;CS0108;IDE0290</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,6 +29,15 @@
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.6.0" />
<PackageReference Include="PacketGen" Version="1.1.2" />

<!-- gdUnit4 package dependencies -->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="gdUnit4.api" Version="5.1.0-rc3" />
<PackageReference Include="gdUnit4.test.adapter" Version="3.0.0" />
<PackageReference Include="gdUnit4.analyzers" Version="1.0.0">
<PrivateAssets>none</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<!-- References -->
<!-- This is required for other platforms where the ENet NuGet package is not enough -->
<Reference Include="ENet-CSharp.dll" Condition="Exists('ENet-CSharp.dll')" />
Expand Down
Empty file added TestResults/.gdignore
Empty file.