Integration playtests

Run integration playtests inside a real Roblox Play session. Read Beacon Yard's tests/ harness, invoke RunGameTests, use test-only attributes, keep Output clean, and fix a flaky health check.

Project lesson, about 70 minutes, 11 steps

By the end you can

  • Run Beacon Yard's server and client playtest suites and read every TEST line
  • Explain why the suite runs through the RunGameTests bindable and asserts server values, not the HUD
  • Shorten a round with test-only attributes without changing the contract numbers in Config
  • Replace a flaky equality with the rule you actually mean

Before this: Unit tests with Jest-Lua, Debugging: breakpoints, the console, a method

Step 1 of 11

Twenty checks in one Play

Press Play, wait for the yard, and run one line from the server command bar:

luau
game.ServerScriptService.RunGameTests:Invoke()

Output fills with lines like TEST PASS coin_pickup and TEST PASS wrench_kill, then TEST SUITE DONE. In about a minute the suite moved your character onto a pad, started a round, stood you next to the drone, swung the wrench three times and bought both shop items. Nothing was mocked.

Roblox Studio
Roblox Studio during Play: Output lists TEST PASS lines ending with TEST SUITE DONE and TEST CLIENT DONE, with the HUD at the top left of the viewport.

Select a numbered pin, or a row below, to read what it marks.

The end of a suite run: the last server checks, TEST SUITE DONE, then the client checks.

This is an integration test: it checks that the pieces work together in the real engine. The unit tests of the last lesson check one rule at a time; this suite checks the wiring.

Choose one

What does coin_pickup check that a unit test of the payout rule cannot?

What does coin_pickup check that a unit test of the payout rule cannot?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 2 of 11

Where the suite lives

Rojo maps the tests/ folder to ReplicatedStorage.GameTests. tests/init.luau returns a function and does nothing until you call it; tests/client.luau is the client half.

local function pass(name: string)
	print("TEST PASS " .. name)
end
 
local function fail(name: string, reason: string)
	print("TEST FAIL " .. name .. ": " .. reason)
end
 
local function skip(name: string, reason: string)
	print("TEST SKIP " .. name .. ": " .. reason)
end
 
local function expect(name: string, ok: boolean, reason: string)
	if ok then
		pass(name)
	else
		fail(name, reason)
	end
end
 
local function waitFor(seconds: number, predicate: () -> boolean): boolean

Every check goes through expect(name, ok, reason). A pass prints the name; a failure prints the name and a reason with the real numbers, such as coins 0 -> 3, wanted +5. A good failure message is half the debugging done.

Choose one

Which failure reason helps most when coin_pickup fails?

Which failure reason helps most when coin_pickup fails?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 3 of 11

Why a bindable, not require

The previous lessons met the command bar trap: it has its own require cache, so a test required from it would get a second, empty DataService. The server script avoids this by requiring the suite itself and exposing a BindableFunction1.

local testModule = ReplicatedStorage:FindFirstChild("GameTests")
if testModule and testModule:IsA("ModuleScript") then
	local runTests = require(testModule) :: () -> ()
	local runner = Instance.new("BindableFunction")
	runner.Name = "RunGameTests"
	runner.Parent = ServerScriptService
	function runner.OnInvoke(): string
		runTests()
		return "ran"

Invoking the bindable runs the suite inside the live server's cache, with the real profiles. The client half has no such problem, because it only reads the HUD and input bindings, so you run it with a plain require in the client command bar.

A full run: Play, the bindable, the server lines, then the client module.

Transcript
  1. 0:00 Play is running and the yard has been built.
  2. 0:07 RunGameTests uses the server script's require cache.
  3. 0:26 The pass lines include the coin, the shop, the drone, and the shield.
  4. 0:29 The client module then prints TEST CLIENT DONE.

Build along

m06-drone-wrench

  • tests/init.luau
  • tests/client.luau
  • src/server/init.server.luau
  1. Check out m06-drone-wrench, run rojo serve, connect Studio and press Play.

    You should see Workspace.Yard exists in Explorer and your character stands in the yard.

  2. Switch the command bar to the server and run game.ServerScriptService.RunGameTests:Invoke().

    You should see TEST PASS lines arrive over about a minute and end with TEST SUITE DONE. DataStore checks print TEST SKIP in an unpublished place.

  3. Switch the command bar to the client and run require(game.ReplicatedStorage.GameTests.client)().

    You should see TEST PASS ui_scale, hud_coins, hud_objective and swing_action, then TEST CLIENT DONE.

  4. Press Stop before the next run, so coins and the phase start fresh.

    You should see Studio returns to edit mode. Workspace.Yard is gone, because MapBuilder builds it only in Play.

Link to this step · This confused me

Step 4 of 11

Assert the scoreboard, not the broadcast

The server suite never looks at the HUD. It reads the leaderstats.Coins IntValue the server wrote, the RoundPhase attribute the server set, and the drone's health on the server.

What the client shows is the broadcast. A test that reads the HUD is checking the TV picture. A test that reads the server's IntValue is checking the scoreboard the broadcast was made from.

Think of it as The live broadcast

Both sidesRemember: Replication is the live broadcast.

The client suite does read the HUD, on purpose: it checks that the broadcast was drawn correctly. Two suites, two sides, two questions.

Match the pairs

Match each check to the suite and side that should own it.

Link to this step · This confused me

Step 5 of 11

Shorter rounds without lying in Config

A real round lasts 40 seconds and the cooldown 8. The suite cannot wait that long for every run, but it must not change Config.luau either, because config_numbers checks those numbers as a contract.

So the game reads three workspace attributes that only the suite sets: TestRoundSeconds, TestCooldownSeconds and TestCoinRespawnSeconds. The suite sets them, waits, and clears them. The game never sets them.

-- Tests shorten the phases with workspace attributes. The game never
-- sets them, so Play uses the Config numbers.
local function positiveOverride(name: string): number?
	local override = workspace:GetAttribute(name)
	if typeof(override) == "number" and override > 0 then
		return override
	end
	return nil
end
 
local function publish(phase: RoundPhase, endsAt: number)
Work it out

The suite sets TestRoundSeconds to 14. How many seconds does Config.ROUND_SECONDS still say?

seconds

Link to this step · This confused me

Step 6 of 11

Output must stay clean

no_output_errors watches Output from the start of the test round until the phase is Idle again. Any error fails it. A warning fails it too, unless its text contains one of five needles, and every needle has a row in tests/README.md explaining why.

local function warningAllowed(message: string): boolean
	-- Each needle is justified in tests/README.md. Do not add one here
	-- without a row in that file.
	local allowed = {
		"[Ids]",
		"DataStore unavailable",
		"DataStore load failed",
		"DataStore session",
		"Asset type does not match",
	}
	for _, needle in allowed do
		if string.find(message, needle, 1, true) then
			return true
		end
	end
	return false

This is why the debugging lesson said to delete trace prints and keep warn for real failures. A new warn("picked up a coin") would fail the suite.

Choose one

During the server suite, your new ShopService debug line emits warn("Shop opened"). What happens?

During the server suite, your new ShopService debug line emits warn("Shop opened"). What happens?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 7 of 11

A flaky check, and the rule you meant

shield_absorb buys a shield, stands you next to the drone and checks that the hit was absorbed. The first version compared health with ==. It passed at full health and failed at random below it.

The reason: the default character Health script heals about 1 point a second while you are under 100. During the wait, 85 can become 86. Equality fails; nothing is wrong with the shield. A test that passes or fails on the same code is called Flaky testFlaky testA test that passes or fails on the same code, depending on timing or chance.Think of it as a smoke alarm that sometimes goes off when you make toast..

		-- The default character Health script heals about 1 per second, so
		-- "no hit" means health did not drop by a drone strike.
		local held = afterAbsorb ~= nil and afterAbsorb.Health > healthBefore - 5

The fix is to write the rule you mean: "health did not drop by a drone strike". A strike is 15, so anything above before - 5 holds.

Luau
Ctrl Enter runs the cell. Checked against the expected output
Predict the output

Health is 90 before the shield check and 85 after. What does the suite's rule (after > before - 5) return?

local before, after = 90, 85
print(after > before - 5)
Health is 90 before the shield check and 85 after. What does the suite's rule (after > before - 5) return?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 8 of 11

From the suite to the Course Runner

Challenges in this course are graded the same way: a learner file you edit, and a test module that prints TEST PASS lines.

game.ServerScriptService.RunGameTests:Invoke() runs the full server suite. To grade just this challenge, use m14-ship, press Play and run game.ServerScriptService.RunGameTests:Invoke("automated-tests") in the server command bar. The first argument is the test module name. If the challenge ID differs from that name, give the ID as the second argument. When all checks pass, copy the BY- code from the PASS CODE: line in Output. Calling a challenge module directly bypasses the runner and does not print that code.

Other ways pros do this

OptionWhat it isWhen pros pick itTrade-offs
Playtest harness in StudioA suite that runs inside Play and prints TEST lines, like tests/.Integration checks of real gameplay: touches, rounds, purchases.Slow, needs Studio, and timing can make it flaky.
StudioTestServiceStudio-only service to start a server with up to 8 simulated clients from a plugin or pipeline.Multiplayer and join-leave tests driven by tooling.Studio only; does nothing in a published game.
Open Cloud Luau ExecutionRuns a script headlessly on a Roblox server against a published place version.CI: every pull request, no Studio on the runner.No real player character, 5-minute task limit, needs an API key and a test place.
Studio MCPAn MCP server that lets an assistant start Play, run Luau and read Output.Driving the playtest suite from a script or an AI agent on your machine.Still runs your local Studio, so it is not a CI runner.
Choose one

On a checkout with the Course Runner, what is the difference between RunGameTests:Invoke() and RunGameTests:Invoke("automated-tests")?

On a checkout with the Course Runner, what is the difference between RunGameTests:Invoke() and RunGameTests:Invoke("automated-tests")?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 9 of 11

Where the broadcast picture breaks

Where does it break?“The live broadcast” is a good picture of replication. Where does it stop being true?

It breaks here. Only property changes in some containers are sent, and nothing a client changes ever travels back up to the server.

The true model. The server copies changes in replicated containers, such as Workspace and ReplicatedStorage, down to clients. A client's own changes stay on that client unless it asks the server through a remote.

The broadcast picture says the client only receives. That is mostly true for game state, and it is why the server suite cannot see the HUD. But the client also produces things the server never sees: its own GUI, its input bindings, its camera. A suite that runs only on the server has a blind spot exactly there, which is why tests/client.luau exists.

Choose one

Which of these can only be checked from the client?

Which of these can only be checked from the client?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 10 of 11

Challenges

Level 1, Apprentice

Challenge

Run both suites and account for every line that is not a pass.

Start from
The game at milestone m06 (download)

Done means

  • You run the server and client suites in one Play session
  • You list which checks printed TEST SKIP and why

Meet the criteria above, then record your own result. No test grades this check.

Choose one

Why does datastore_roundtrip print TEST SKIP in a fresh, unpublished place?

Why does datastore_roundtrip print TEST SKIP in a fresh, unpublished place?

Press 1 to 4 to choose, Enter to check.

Level 2, Builder

Challenge

Add one integration check to tests/init.luau for the gates.

Start from
The game at milestone m06 (download)

Done means

  • A new check, gate_open, asserts the left gate moves away from its closed position during Active
  • It reads the server's part position, not a client view
  • The suite still ends with TEST SUITE DONE and every old check passes

Meet the criteria above, then record your own result. No test grades this check.

Level 3, Professional

Challenge

Replace the flaky equality in the learner file with the suite's rule. To grade the change, use m14-ship, press Play and run this in the server command bar:

luau
game.ServerScriptService.RunGameTests:Invoke("automated-tests")
Start from
The game at milestone m06 (download)
Grade it
To grade work from an earlier milestone, apply your challenge changes to a checkout based on m14-ship, which includes the Course Runner. In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("automated-tests") in the server command bar. Copy the pass code from Output.

Done means

  • challenges/automated_tests_work.luau implements health > before - 5
  • A heal of 1 or 2 holds, a drop of 15 fails, a drop of exactly 5 fails
  • challenges/automated-tests.luau prints TEST PASS for all seven cases

The Course Runner prints this code when the test passes.

Link to this step · This confused me

Step 11 of 11

Recap

Recap

  1. Playtests run the real game: invoke RunGameTests on the server, then require the client half on the client.
  2. Assert server values for server facts, keep contract numbers in Config, and shorten sessions with test-only attributes.
  3. Fix flaky checks by writing the rule you mean, and keep Output clean so warnings stay meaningful.

Replication is the live broadcast, until only property changes in some containers are sent, and nothing a client changes ever travels back up to the server.

Next Performance: MicroProfiler, memory, network

Link to this step · This confused me