Automated Game Testing: Unit Tests, Playtests and AI Agents
Automate game testing in Unity, Godot and Unreal: unit tests, playtests with simulated input, CI, and an AI agent that plays your game.

Automated game testing means letting code check your game instead of clicking through it by hand after every change: unit tests for the rules, play-mode tests that run real scenes with simulated input, and a CI job that runs both on every push. In our experience the setup that works best today is a closed loop: an AI agent writes the change, runs the tests, plays the game with real key presses and screenshots, and only then hands it to you. You keep the one job no test can do: deciding whether the game feels good. This post shows that loop with concrete examples for Unity Test Framework, gdUnit4 in Godot and Unreal's Automation system.
Why Testing Games Is Harder Than Testing Apps
A game has physics, frame timing, random numbers and a player who does things you never planned for, so many teams test nothing automatically and rely on playtesters. That works until a gravity tweak breaks a jump in level 3 and nobody notices for two weeks.
Most game bugs, though, are mechanical: "the player can no longer reach the last platform" or "the score does not reset on restart" are checkable by a program. Automation should catch those, so humans can spend their time on what only humans can judge.
The Four Layers of Automated Game Testing
We split testing into four layers. Each catches a different kind of bug, and each costs a different amount of time to run.
- Unit tests. Pure logic without a scene: damage formulas, inventory rules, save file parsing, wave spawn tables. They run in milliseconds, so run them on every change.
- Play-mode tests. A real scene loads, frames advance, input is simulated and the test asserts on the result: the player moved, the door opened, the enemy died. They take seconds, so run the relevant ones on every change and all of them before a merge.
- Agent playtests. An AI agent starts the game, presses keys, steps frames, takes screenshots and reports what it saw. This catches what nobody wrote a test for yet, and every useful finding should become a play-mode test.
- Human playtests. You or your testers play. This is where fun, pacing, readability and motion are judged. No automated layer replaces it.
Layers 1 and 2 also run in CI on every push; layer 3 runs while you work.
The Closed Loop: How an AI Agent Tests Your Game
In our experience the biggest change AI agents bring to game testing is not that they write tests. It is that they close the loop on their own: change, compile, run tests, play, look, fix, before they tell you they are done. An agent that only edits files is guessing; one connected to the live editor can check.
With AI Game Developer, a request looks like this: "Make the double jump 20 percent higher, then prove the player can still reach the ledge in the first room." The agent then does the following.
- Changes the tuning value or the script, and waits for the editor to recompile.
- Reads the console for errors and warnings.
- Runs the unit and play-mode tests that cover the jump, and fixes what fails.
- Starts the game, presses the keys, steps frames and reads the player's position and velocity.
- Takes a screenshot and looks at it, because "the position is correct" and "the character is not stuck inside the wall" are different checks.
- Adds a play-mode test for the ledge, so the next change is checked automatically.
- Reports what it changed, what it ran and what it saw.
Step 6 is the important habit: every bug the agent finds becomes a test, so your suite grows around exactly the things that broke before.
What the agent can do differs by engine, and it matters for how you plan the loop:
- Unity: the agent runs EditMode and PlayMode tests with the tests-run tool, enters and leaves play mode, reads the console and takes screenshots. It can also run short C# directly inside the live editor to inspect or set up a scene.
- Unreal: the agent can start Play In Editor paused, advance it in fixed 1/60 second frames while holding keys such as W and LeftShift, and read the play state: the pawn's location, velocity, movement mode and the active Enhanced Input contexts. Keys go through the player's input mapping like real ones. Screenshots come from the viewport, the game view or a camera.
- Godot: the agent reads and changes scenes and scripts, builds C#, takes viewport and camera screenshots, and reads logs and runtime errors from a running game. Tests run through godot-cli with GUT or gdUnit4.
- Web (Three.js): the game runs in a panel beside the chat, and the agent sends keyboard, mouse, touch and gamepad input, steps frames, changes the time scale and runs playtests: scripted sequences of input, frame steps, checks and screenshots that end in one PASSED or FAILED report. The full walkthrough is at ai-game.dev/blog/threejs-game-development-with-ai.
Unity: Unity Test Framework With Simulated Input
Unity Test Framework is Unity's built-in NUnit runner. EditMode tests run without entering play mode and suit pure logic. PlayMode tests run in play mode, and a test marked with the UnityTest attribute is a coroutine, so it can wait for frames and seconds.
For input, use the Input System's InputTestFixture. It gives every test a clean, isolated Input System and helpers such as Press, Release and PressAndRelease. Two setup steps, as of November 2026, from Unity's Input System testing docs:
- In Packages/manifest.json add com.unity.inputsystem to a testables array next to dependencies.
- In your test assembly definition reference UnityEngine.TestRunner, UnityEditor.TestRunner, Unity.InputSystem and Unity.InputSystem.TestFramework, with nunit.framework.dll.
{
"dependencies": {
"com.unity.inputsystem": "1.11.2"
},
"testables": [
"com.unity.inputsystem"
]
}The version number is only an example. A jump test then reads like a description of the bug it prevents:
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
public class PlayerJumpTests : InputTestFixture
{
[UnityTest]
public IEnumerator Space_MakesPlayerJump()
{
var keyboard = InputSystem.AddDevice<Keyboard>();
yield return SceneManager.LoadSceneAsync("Level1");
var player = GameObject.FindWithTag("Player");
float startY = player.transform.position.y;
Press(keyboard.spaceKey);
yield return new WaitForSeconds(0.25f);
Release(keyboard.spaceKey);
Assert.Greater(player.transform.position.y, startY + 0.5f,
"Player did not leave the ground after pressing Space");
}
}Add the scene to the build settings first. In the editor, the agent runs it with tests-run. From a terminal or CI, unity-mcp-cli runs the tests in a batch-mode editor with Unity's own -runTests, without the plugin or an MCP server, and takes the verdict from the NUnit report rather than from the editor's exit code:
unity-mcp-cli test ./MyGame --mode PlayMode --junit-output junit.xml
unity-mcp-cli test ./MyGame --mode EditMode --format githubThe github format prints annotations at the failing test's source line, so a red CI run points straight at the problem.
Godot: gdUnit4 and GUT From the Command Line
Godot has no built-in test runner, so you install one as an addon. gdUnit4 supports GDScript and C# and has a scene runner that loads a scene, simulates keys, mouse and input actions and runs a given number of frames. As of November 2026 its latest release is 6.2.3, and its changelog mentions Godot 4.7 fixes. GUT is the other popular choice and is GDScript only.
A gdUnit4 playtest follows the same shape as the Unity one: create a scene runner for your level, press the right action or key, simulate a number of frames, then assert on a node's position or a label's text. Two practical notes from the gdUnit4 docs and changelog. Input simulation calls are asynchronous, so await them. And simulate_frames counts frames, not seconds, so pass a fixed frame delta when the result depends on time.
godot-cli finds whichever runner you installed and runs it headless with a hard timeout, judging the result from the JUnit report and the log rather than Godot's exit code, which is unreliable in headless mode:
godot-cli check ./MyGame
godot-cli test ./MyGame --runner gdunit4 --output junit.xml
godot-cli test ./MyGame --filter player --format githubExit code 0 means all tests passed, 8 means at least one failed, and 6 means no verdict: no runner, no report, or a test script that failed to load, which godot-cli refuses to call a pass. Setup for the editor addon is at ai-game.dev/engines/godot.
Unreal: Automation Tests, Functional Tests and Agent Play
Unreal ships the most complete testing system. As of November 2026 Epic's Automation Test Framework documentation describes unit tests, feature tests, smoke tests that should finish within a second, Automation Specs for behaviour-driven tests, functional tests placed in levels for gameplay checks, plus content stress tests and screenshot comparison between builds. To run them in the editor, first enable an automation tests plugin in Edit > Plugins (for example Editor Tests, Runtime Tests or Functional Testing Editor in the Testing section), then open Tools > Test Automation.
Functional tests are the Unreal equivalent of play-mode tests: a test actor in a test map runs gameplay and reports success or failure, and you can build them in Blueprint.
From a terminal or CI, unreal-mcp-cli builds the editor target when needed and runs the Automation tests headless, taking the verdict from the report's index.json:
unreal-mcp-cli compile ./MyGame
unreal-mcp-cli test ./MyGame --filter Project --junit-output junit.xmlWhile you work, the agent does not need a written test to check a movement change. Through RQL it starts Play In Editor paused and advances it with keys held, so the result does not depend on the editor's frame rate:
unreal-mcp-cli rql -p ./MyGame 'editor | call StartPlay()'
unreal-mcp-cli rql -p ./MyGame 'editor | call AdvancePlay(2, 0, "W, LeftShift")'
unreal-mcp-cli rql -p ./MyGame 'editor | call StopPlay()'The result carries the pawn's location, speed and movement mode, so "sprinting for two seconds covers at least 10 metres" becomes a check the agent can run in one call. More on the Unreal side in ai-game.dev/blog/best-ai-for-unreal-engine.
Running Game Tests in CI
CI is what turns tests from a good intention into a habit. Our recommended setup:
- Run unit tests and fast play-mode tests on every pull request. Keep this under ten minutes, or people stop waiting for it.
- Run the full play-mode and functional suite nightly or before a release.
- Publish JUnit results so failures show per test, not as one red build. All three engine CLIs write JUnit XML and support the github annotation format.
- Treat "no verdict" as a failure. A crashed editor, a missing report or a test that never loaded is not a pass.
- Fix the random seed and the frame delta in tests. Flaky tests teach the team to ignore red builds, which is worse than no tests.
- Unity in CI needs a licensed editor; Unreal CI needs a machine that can build your editor target. Plan the runner before the tests.
If you install the Unity plugin and do not want it running in ordinary CI test jobs, set UNITY_MCP_DISABLE=1 in the environment of the step that launches Unity. It skips the plugin's startup while leaving your package manifest unchanged.
When a check goes red, ask the agent to read the failing test and the log and fix the cause, not the test.
What Automation Cannot Test: Fun and Motion
A test can prove the jump reaches 2.4 metres. It cannot tell you the jump feels floaty, or that a hit lacked weight because the hitstop was two frames too short.
In our experience these are the things a human must check, every time a change touches them:
- Fun: is the core loop still enjoyable after ten minutes, not ten seconds?
- Motion and game feel: acceleration curves, camera smoothing, animation blending, screen shake, hitstop.
- Readability: can a new player tell what is dangerous, interactive or collectable?
- Difficulty and pacing: tests prove a level is possible, not that it is fair.
- Audio and timing: whether a sound lands on the frame it should.
So the split we recommend is simple. The agent proves the change works and did not break anything: compiled, tests green, played, screenshotted. You then play it and judge how it feels. If you catch yourself checking whether a door opens, that check belongs in a test.
A Practical Checklist to Start
- Pick one runner per engine: Unity Test Framework, gdUnit4 or GUT for Godot, Unreal Automation with functional tests.
- Move your most important rules into code that can be tested without a scene: damage, scoring, inventory, save data.
- Write three play-mode tests for the core loop: the player can move, the main action works, the level can be finished.
- Run them from the engine CLI on your machine, then add the same command to CI with JUnit output.
- Connect an AI agent to the editor and ask it to finish every task by running the tests and playing the change.
- Every bug you fix becomes a test, written by the agent in the same task.
- Play the game yourself after each meaningful change, and spend that time on feel, not on checks a test could do.
Trade-Offs to Know
- Better: regressions are caught in minutes instead of weeks, and the agent stops claiming success it cannot show.
- Worse: play-mode tests are slower and more fragile than unit tests, and level or UI changes break them. Test behaviour, not object names.
- Worse: CI with an engine editor costs real setup time: licences, build machines, caching.
- Worse: an agent playtest is only as good as its goal. Ask it to "reach the ledge", not to "test the game".
Try It With AI Game Developer
AI Game Developer connects Claude Code, Codex, Cursor or its own built-in agent to Unity, Unreal, Godot and Web (Three.js) projects, with the test, play and screenshot tools described above and the three engine CLIs for the terminal and CI. Install the desktop app from ai-game.dev/download, connect your Unity project as described at ai-game.dev/engines/unity, and ask the agent for something it can prove: "add a play-mode test that the player can reach the ledge, make it pass, and show me a screenshot".

