DEV Community

Juego Studios
Juego Studios

Posted on

Writing Automated PlayMode Smoke Tests With the Unity Test Framework: A Starter Checklist

If you've ever shipped a Steam build where the main menu wouldn't load on a clean install, or a console submission that failed because a save slot broke, you already know the case for smoke tests. They don't replace a QA pass. They catch the embarrassing, build-breaking problems in the ten minutes after a build finishes, before anyone on the team downloads it.

Here's a starter checklist for small US teams who want automated PlayMode smoke tests running with the Unity Test Framework before every Steam or console build. It assumes Unity 2021 LTS or later and the Test Framework package that ships with it.

1. Put smoke tests in their own assembly

Create a dedicated test folder with an Assembly Definition that references your game assemblies and UnityEngine.TestRunner / UnityEditor.TestRunner, marked as a test assembly. Keep smoke tests separate from unit tests so you can run them on their own with a category filter:

[Category("Smoke")]
public class BootSmokeTests { /* ... */ }
Enter fullscreen mode Exit fullscreen mode

That separation matters later, when the full suite takes twenty minutes and you only want the five-minute gate on every commit to main.

2. Test the boot path exactly as a player hits it

The first test should load your real first scene, not a test scene, and wait for the game to reach a known "ready" state:

[UnityTest]
public IEnumerator Boot_ReachesMainMenu()
{
    SceneManager.LoadScene("Boot");
    float timeout = 30f;
    while (MainMenu.Instance == null && timeout > 0f)
    {
        timeout -= Time.unscaledDeltaTime;
        yield return null;
    }
    Assert.IsNotNull(MainMenu.Instance, "Main menu never appeared after boot");
}
Enter fullscreen mode Exit fullscreen mode

Expose a small, explicit ready signal (a singleton, an event, or a flag on a bootstrap object) rather than waiting a fixed number of seconds. Fixed waits are the fastest way to get flaky tests.

3. Walk the menus that every player touches

Navigate the menus with code, not simulated clicks on screen coordinates: open settings, change a value, back out, start a new game. Call the same methods your UI buttons call. If a menu can only be driven by clicking a specific pixel, that's worth fixing for controller support anyway.

Check for things that should never happen: missing references, NullReferenceException in the log, or a screen that never finishes its transition. LogAssert.NoUnexpectedReceived() at the end of a test turns stray errors into failures.

4. Round-trip a save file

Save bugs are among the most expensive to find late, especially near console certification. A basic smoke test:

  1. Start a new game in a known state.
  2. Change something measurable (position, inventory count, a flag).
  3. Save, reload the scene, load the save.
  4. Assert the value survived.

Point the save path at a temporary folder during tests so you never touch a developer's real saves, and add one test that loads a save written by the previous release to catch format changes.

5. Exercise the purchase flow against a fake store

You can't hit real Steam or console store backends from CI, so put store calls behind an interface and inject a fake that returns success, failure and "user cancelled". The smoke test checks that each result leaves the game in a sane state: the item granted once on success, nothing granted on failure, and no stuck "processing" spinner on cancel. This is the test that saves you from a weekend of refund tickets.

6. Run it headless in CI before the build is uploaded

Run the suite from the command line on your build machine:

Unity -batchmode -projectPath . -runTests -testPlatform PlayMode \
  -testCategory Smoke -testResults results/smoke.xml -logFile -
Enter fullscreen mode Exit fullscreen mode

Wire it into whatever you use (GitHub Actions with a self-hosted runner, Jenkins, TeamCity) so a failed smoke test blocks the Steam upload or console packaging step. Publish the XML results so failures show up with the test name, not just a red build.

7. Keep the suite short and owned

A smoke suite is only useful if it stays fast and trusted. Aim for something that finishes in minutes, delete or fix flaky tests within a day, and name one person who owns it each sprint. When a bug slips through that a smoke test could have caught, add that test before closing the bug.

Where this fits in a soft launch

Smoke tests matter most when you're shipping updates every week, for example during a soft launch, when economy and progression tweaks go out constantly (I wrote about tuning loot and progression before a US soft launch separately). Each of those builds should pass the same gate.

If you need extra hands on a Unity project, Juego Studios offers Unity game development services, including test automation alongside feature work. Whoever writes them, a handful of reliable smoke tests will pay for themselves the first time they stop a broken build from going out.

Top comments (0)