Add Unity GSDK unit tests and CI workflow#193
Conversation
- Create test project (UnityGsdk/Tests/Tests.csproj) that compiles model and helper source files without Unity engine dependencies - Add GSDKConfigurationTests: config parsing, env vars, round-trip - Add SessionConfigTests: CopyNonNullFields, equality, hash code - Add SerializationTests: heartbeat request/response, maintenance schedule, connected players, game state/operation enum serialization - Add CI workflow (.github/workflows/unity-tests.yml) triggered on PRs with changes to UnityGsdk/** paths - Update UnityGsdk/.gitignore to allow Tests/Tests.csproj Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
|
@copilot can you amend the Unity GSDK readme to mention that these files don't need to be included when someone uses the Unity GSDK? |
|
@copilot can you retry? |
Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Added a "What is the |
There was a problem hiding this comment.
Pull request overview
Adds a standalone .NET unit test project for Unity GSDK model/helper classes (no Unity engine dependency) and introduces a GitHub Actions workflow to run those tests on PRs that touch UnityGsdk/**.
Changes:
- Added
UnityGsdk/Tests/Tests.csprojplus new MSTest test suites covering config parsing, session config behavior, and JSON serialization/deserialization. - Added
.github/workflows/unity-tests.ymlto run Unity GSDK tests on PRs that modify Unity SDK files. - Updated
UnityGsdk/.gitignoreto allow committing the test project file, and updatedUnityGsdk/README.mdwith a Tests folder FAQ + typo fix.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| UnityGsdk/Tests/Tests.csproj | New .NET test project compiling Unity GSDK model/helper sources via linked includes. |
| UnityGsdk/Tests/SessionConfigTests.cs | New unit tests for SessionConfig copy/equality/hash behavior. |
| UnityGsdk/Tests/SerializationTests.cs | New unit tests for SimpleJson serialization and model round-trips (heartbeat, maintenance, enums, etc.). |
| UnityGsdk/Tests/GSDKConfigurationTests.cs | New unit tests for GSDKConfiguration parsing and env var capture. |
| UnityGsdk/README.md | Documentation update: adds Tests folder FAQ and fixes a typo. |
| UnityGsdk/.gitignore | Un-ignores the new test project file while keeping Unity’s default ignores. |
| .github/workflows/unity-tests.yml | New CI workflow to build/test the Unity test project on relevant PRs. |
- Update integration instructions to use the correct folder name 'Assets/PlayFabSdk' (the previous 'PlayFabSDK' casing was wrong on case-sensitive filesystems like Linux). - Expand the 'Tests/' section to make clear it refers to the new top-level UnityGsdk/Tests/ folder, that it sits outside Assets/ so Unity does not import or compile it, and that it does not need to be copied when integrating the SDK. - Disambiguate from the pre-existing in-engine Assets/Tests/ NUnit assembly which is gated behind the UNIT_TESTING define. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GSDKConfigurationTests.ReadConfiguration_EnvironmentVariables_Captured: capture original PF_TITLE_ID/PF_BUILD_ID/PF_REGION values before the test and restore them in the finally block. The previous version unconditionally cleared them, which would wipe any pre-existing values set on the developer's machine or on the CI runner for the rest of the process. - unity-tests.yml: add --no-build to the test step. dotnet test builds by default, so the explicit Build step was redoing the build; --no-build skips that and shaves CI time without removing the two-step structure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What this PR does / why we need it:
Adds standalone unit tests for the Unity GSDK model/helper classes and a GitHub Actions workflow to run them on PRs, matching the pattern established in #191 (C#) and #192 (C++).
The Unity SDK's model classes (
GSDKConfiguration,SessionConfig,HeartbeatRequest/Response,MaintenanceSchedule, etc.) andSimpleJsonhelpers have no Unity engine dependencies, so they compile and test in a standard .NET project without requiring Unity Editor.Test project (
UnityGsdk/Tests/Tests.csproj):<Compile Include="..." Link="..." />— no separate library project neededGSDKConfigurationTests— config parsing, env vars, certificates, ports, round-trip serializationSessionConfigTests—CopyNonNullFields, equality operators, hash codeSerializationTests— heartbeat request/response, maintenance schedule V2, connected players, allGameState/GameOperationenum valuesCI workflow (
.github/workflows/unity-tests.yml):UnityGsdk/**ubuntu-latest, .NET 10.0.x,dotnet testOther:
UnityGsdk/.gitignore— added!Tests/Tests.csprojexception (existing gitignore excludes*.csproj)UnityGsdk/README.md— added FAQ section clarifying that theTests/folder is for development/CI only and does not need to be included when integrating the Unity GSDK; also fixed a pre-existing "scripring" → "scripting" typoSpecial notes for your reviewer:
MSTest package versions match
csharp/Tests/Tests.csprojfor consistency.If applicable:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.