Step Reference

1file
9min read
Sheet 12 of 47 · Scenarios

Filesscenarios/30-shop.yml

Filescenarios/30-shop.ymlEvery step a scenario can take, with its parameters. This is the one-page guide the tool prints with java -jar IgniteTestTool.jar guide, sorted by what a step is for. The long form of each part is on the other Scenarios sheets.

A whole file

scenarios/30-shop.yml
name: shop buys a sword
bot: Buyer
include: [common.yml]            # define groups from lib/common.yml, looked up next to the file and in lib/
vars: {price: 150}
cache: {inputs: [plugins/Shop/config.yml]}
ignoreExceptions: ["Known noisy warning"]
steps:
  - {do: join}
  - {do: rcon, cmd: "eco set ${bot} 500", expect: "500"}
  - {do: chat, c: /shop}
  - {do: expectWindow, title: "(?i)shop", timeout: 4000}
  - {do: click, custom: "(?i)iron sword", expectWindow: "(?i)confirm"}
  - {do: click, slot: 11}
  - {do: expectChat, regex: "bought .* for (?<paid>\\d+)"}
  - {do: set, var: left, calc: "500 - ${paid}"}
  - {do: assertServer, path: player, player: "${bot}", field: "inventory[0].type", value: IRON_SWORD, timeout: 2000}
  - {do: rcon, cmd: "eco get ${bot}", expect: "${left}"}
finally:
  - {do: call, name: reset_player}
  - {do: quit}

Top of the file

KeyWhat it does
nameThe scenario's name
botThe bot that runs the steps
includePulls in the define groups of other files, looked up next to the file and in lib/
varsVariables for the file, vars: {price: 150}
paramsNames the file needs: a list of required names, or a map of name to default where null means required. Values replace ${name} before the run and also become vars
ignoreExceptionsServer errors this file may log without failing, while the server watcher runs
cachecache: {inputs: [..]} adds files the result cache watches, cache: {ignore: [..]} drops one, cache: false opts the file out
stepsThe steps
finallyRuns whatever failed before it. Calls and groups inside it run to the end too
setup: trueMarks a file that prepares the server for the others: every shard and worker runs it first and the cache never skips it
checkpoint: cleanPuts the saved copy of plugin data called clean back before the file runs, with a server restart
freshPlayers: truefresh: true on every join
defineNamed step groups, see Library
matrix, eachRun the file once per row, see Library

join on a bot an earlier run left online lets go of its keys, closes its menu and counts chat from that moment.

Bot actions

StepParameters
join, quithost, port, account; fresh: true resets health, hunger, items, effects and levels, freshPlayers: true at the top of the file does it for every join
chatc (text or /command), wait, until (regex, returns early)
clickOne of slot, item or custom (regex on the name) is required, lore only narrows the match; button, shift, expectWindow
close
gotox, y, z; like every action that takes a position, ~ is the block the bot stands in and ~2 counts from it
waitms
actionaction plus its own parameters, as + field keep the answer; call actions lists them all
answerDialogbutton, inputs, expectWindow

Expectations

StepParameters
expectWindow, expectNoWindowtitle (regex), timeout
expectSlotslot, item, custom, lore, count, glint, nameRuns, timeout; absent: true passes when no slot matches
expectTitletitle, color, bold, ...
expectChat, expectNoChatregex, timeout / window, since: step|scenario|now; named groups become variables
expectDialogtitle, type, inputs, buttons
assertPosx, y, z, range, timeout
expectServername (regex on the backend behind a proxy), probe: true asks the proxy with /server, timeout (default 10000)

Style checks on titles, names and lore, and dialogs, are on Styles & Dialogs.

Server

StepParameters
rconcmd, expect (regex), as
serverpath (an agent endpoint) plus its parameters, as + field; params: {name: .., action: .., cmd: ..} for the three names a step keeps for itself; x, y, z take ~ too
assertServerpath, field (dotted, [n], pdc.ns:key, inventory.size counts a list), op (eq ne gt ge lt le contains matches exists absent), value, delta, timeout
filepath in the server folder, then replace (regex) + with, write, append, expect (regex, polls until timeout) + as, or restore: true. Every file a scenario changed is put back when it ends, keep: true leaves the edit
checkpointsave: name or restore: name; paths in the server folder (default the data folder of every plugin). The server restarts around it and the bots have to join again, live: true copies under a running server

server and assertServer need the server agent, except for mongo and redis. Saved copies of plugin data are on Checkpoints.

Control flow

StepParameters
setvar + value, var + calc (+ - * / % and brackets), or vars: {a: 1}
looptimes, with steps. With until: pass it tries until one iteration gets through and fails when none of times does
groupsteps
parallelbots (count or names), with steps
ifcheck (any step), then, else: a check that does not pass takes the else branch, it is not a failure
logmessage
callname, with: runs a group from define
includefile, with: runs another file's steps in place

Pictures

StepParameters
takeover, frame, key, screenshot, record, releaseReal client pictures, see Screenshots in Scenarios

Every step

Any step takes optional: true, bot: <name> and name: <label>.

${var} works in every string. These are set for you:

VariableSet by
${bot}The bot running the step
${i}loop
${n}parallel
${slot}expectSlot
${match}expectChat

Library

define: {name: [steps]} or {name: {params: {a: null}, steps: [...]}} names a group of steps. A group is used with {do: call, name: x, with: {a: 1}}. {do: include, file: x.yml} runs another file's steps in place. matrix: {a: [1, 2]} or each: rows.csv runs the file once per row. The full rules are on Includes, Params & Rows.

Bot actions used most

These go in an action step as action: <name>.

ActionParameters and notes
sneakon
hotbarslot
useOne right click. swing: 1 adds the arm swing
useHoldms. A held key clicks again every 200 ms unless the item is a bow, food or shield, every: 0 forces one click
attackid
lookx y z
place
dig
equipitem
drop
invfull=1
hudAction bar, title, boss bars
advancementsmatch. What the player holds, a plugin's toast included
resourcePacksWhat the server pushed. answer=accept|decline|fail|ignore for the next one
markTake one before waitFor
waitFortype=chat|actionbar|title|sound|advancement|resourcepack|packet|entity|entityGone|move, match, since, timeout; absent: 1 passes when nothing matched in that time

call actions lists every action. The ones for exact numbers are on Precise Testing.

Server side

IgniteTestAgent answers what a bot cannot see, as call server/<endpoint> or a server / assertServer step.

EndpointParameters and notes
playerplayer=
entityplayer= / uuid= / id=
entitiesnear=, r=, type=
entity/set
dummyA target with known health
dummy/clear
blockworld, x, y, z. A chest, sign, spawner or skull also has state with its items, front, pdc
snapshot, restoreA box of blocks by name
execcmd, console output back
tickaction=freeze|unfreeze|step|rate
healthTPS
commands
ping
player/reset
placeholdertext=%x%, player=
permissionplayer=, node= or prefix=
events/watchtype=PlayerInteractEvent,full.class.Name. Records Bukkit events
eventssince=<mark>, type=, player=. Lists them with cancelled and their getters, events.size counts them
inspectplugin=, path=. Reads a plugin's own state by getter or field name
invokeplugin=, path=, method=, args=a,b or a JSON array. Calls a method on what the path leads to
sqlurl=jdbc:sqlite:plugins/Shop/data.db, or a MySQL url with user and password; query=. Answers count and rows, or updated

mongo and redis work the same way in a server or assertServer step, but the tool answers them itself, no agent needed:

EndpointParameters and notes
mongouri, db, collection, filter, sort, max; insert, update, delete: true
redishost, port, password, db, command: "HGET player:Steve coins", answer in value

inspect paths look like path=arenaService.arenas[IttArena].state: [n] for lists, .size to count, a player name finds a UUID key. No path shows the plugin's fields, a wrong name lists what is there. Use it before writing a helper plugin.

invoke picks the overload by what the arguments fit: numbers, booleans, enum names, a player name, a world, world:x:y:z. type=com.acme.Shop on inspect and invoke starts at the static side of a class, on=async keeps a slow call off the server thread.

sql, mongo and redis poll in assertServer like anything else:

- {do: assertServer, path: sql, url: .., query: "select coins from players where name = 'Steve'", field: "rows[0].coins", value: 150, timeout: 3000}

More on Databases & Plugin Calls.

Running from a script

ITT="java -jar IgniteTestTool.jar"          # add --data-dir <dir> when the tool runs with one
$ITT check suite/                           # parse only, finds typos in under a second
$ITT run suite/ --cache                     # runs what changed, skips what already passed
$ITT run suite/30-shop.yml                  # one file, always runs
$ITT run suite/ --failed                    # only what failed last time
$ITT run suite/ --cache --deploy            # build, swap the jar, restart the server, then run
$ITT last                                   # the last report again
$ITT call rcon c="list"                     # any endpoint, parameters as key=value
$ITT usage                                  # calls and bytes per endpoint, what the session cost so far
$ITT coverage                               # line coverage of the plugin, coverage <Class> for its missed lines
$ITT panel                                  # the same in a browser tab

run prints one line per file and, under a failed one, the step, the three steps before it, what the bot saw (position, health, held item, open window, last chat lines) and the server errors logged meanwhile. The first word is PASS or FAIL and the exit code follows it. That report is meant to be enough: read it before asking the server or the bot anything else.

Rules that keep a session short:

  • Run a folder with --cache instead of picking files by hand. A file is skipped when it passed and nothing it depends on changed: its own text, the files it includes, the jars in the server folder and in plugins/, and the config files of the server and its plugins. A config edited by hand brings the file back and the report names it. cache: {inputs: [..]} adds other files, cache: {ignore: [..]} drops one, cache: false opts a file out, call cache/clear forgets everything.
  • With code coverage on (call coverage/code/on plugins=<part of the jar name>, then restart the server) a pass also holds through a new build that changed no method the file ran. run --cache --deploy then reruns only the files an edit can reach, and the report says new build, no method it runs changed for the rest.
  • call cuts every list at 100 items and text at 4000 characters. Ask for less: fields=type,health,pos.y keeps those keys of every row, cap=5 shortens lists and maps, --full lifts the limit. usage shows which endpoint cost the most.
  • check knows the bot actions and the agent endpoints. A typo in action: or path: fails there, with the closest name, instead of minutes into a run.
  • --deploy needs the project set once: call workflow/set deployProject=<dir> deployBuild="gradlew build" deployArtifacts="build/libs/*.jar". A failed build prints its error lines and nothing runs.
  • Do not sleep. expectChat, expectWindow, expectSlot, assertServer and assertPos poll until their timeout, action: waitFor blocks on an event. wait is for a cooldown the plugin really has.
  • Do not read the server log for errors. With call watch/start on, a stack trace during a scenario fails it and shows up in the report with the plugin it came from.
  • Probing by hand is for finding out how something behaves, a few calls at most. Put several into one request: POST /batch with [{"path": "/chat", "params": {...}}, ...].

Other endpoints

EndpointWhat it is for
status, bots, processesWhat is running
start what=server, stop id=, console c=The managed server
join name=, quit bot=, chat bot= c=, win bot=, click bot= slot=, act bot= action=One bot by hand
suite/run, suite/check, suite/last, suite/status, suite/cancelWhat the commands above call; format=text gives the short report
history file=, flaky file=Past runs of one file, steps that fail only sometimes
cache, cache/clearWhat the result cache holds
usage, usage/clearCalls, bytes and rough tokens per endpoint
coverage/code (class=), coverage/code/on plugins=, coverage/code/off, coverage/code/resetLine coverage of the plugin jars
checkpoint, checkpoint/save name= paths=, checkpoint/restore name=, checkpoint/drop name=Saved copies of plugin data
deploy, deploy/status, workflow, workflow/setBuild and swap the plugin jar
watch/start, watch/statusServer error watcher
crawl, fuzz/start, load/start, soak/startLong jobs, only when asked for

Loading the index

Enter openUp Down moveEsc close