Skip to content

Latest commit

 

History

History
76 lines (53 loc) · 2.92 KB

TESTING.md

File metadata and controls

76 lines (53 loc) · 2.92 KB

Testing with AI Studio

AI Studio treats testing as a first-class part of building. The Test Engineer agent writes tests, runs them with the run_tests tool, and iterates until they pass — and reads playtest logs to debug runtime behavior.

The run_tests tool

run_tests finds and runs spec ModuleScripts in Studio and returns a structured summary:

{ "passed": 7, "failed": 1, "total": 8, "specCount": 3, "results": [ ... ] }
  • Where it looks: by default, ModuleScripts under ServerScriptService/Tests, or anywhere named *spec* / *test*. Pass a path to scope it to a specific folder.
  • Fresh execution: each spec is compiled and run from its current source every time, so edits are reflected on re-run (unlike require, which caches). Specs get their own script reference and normal globals, so require(script.Parent.ModuleUnderTest) works.

Writing a spec

A spec is a ModuleScript that asserts and returns a { passed, failed } count:

-- ServerScriptService/Tests/JumpPad.spec
local pad = workspace:FindFirstChild("JumpPads")
local passed, failed = 0, 0

local function check(name, cond)
    if cond then passed += 1 else failed += 1; warn("FAIL: " .. name) end
end

check("JumpPads folder exists", pad ~= nil)
check("has at least one pad", pad and #pad:GetChildren() > 0)
check("pad is anchored", pad and pad:FindFirstChildOfClass("Part") and pad:FindFirstChildOfClass("Part").Anchored)

return { passed = passed, failed = failed }

A spec that simply runs without error counts as 1 passed; an error counts as 1 failed with the message captured.

TestEZ

If your project uses TestEZ, write a bootstrap ModuleScript that runs it and returns the results object — run_tests reads successCount / failureCount / errors directly:

-- ServerScriptService/Tests/Bootstrap.spec
local TestEZ = require(game.ReplicatedStorage.TestEZ)
return TestEZ.TestBootstrap:run({ game.ServerScriptService.Tests }, TestEZ.Reporters.TextReporter)

The QA loop

Roblox doesn't let plugins press Play, so the loop is:

  1. AI writes & runs tests (run_tests) for logic it can exercise in edit mode.
  2. You press Play to exercise runtime behavior (physics, players, replication).
  3. AI reads logs (get_logs with filter: "errors") to see what happened and fix bugs.
  4. Repeat until green.

Just ask, e.g.:

"Write tests for the jump pad and run them. Then I'll playtest — read the logs and fix any errors."

The Coordinator brings in the Test Engineer, which writes specs, runs run_tests, reports the summary, and — after you playtest — reads the logs and coordinates fixes with the Coder.

Ad-hoc assertions

For quick checks without persistent spec files, the agents use run_luau, which runs fresh Luau every time and returns its printed output — handy for one-off assert(...) / print(...) probes during debugging.