Test a Paper plugin with real bots, locally and in CI

4files
5min read
Sheet 6 of 6 · plugin developers

Filesscenarios/island-menu.json · server.properties · s08-a-flight-afk.yml · junit-platform.properties

Filescenarios/island-menu.jsonFileserver.propertiesTo test what a player actually sees, a menu that opens, a command that answers, a click that pays out, you need bots that join a real Paper server over the protocol and check the result. A mock server cannot tell you that. IgniteTestTool runs those bots from scenario files or from JUnit 5 tests, on your machine or in a CI job, and fails the build when a step does not pass.

Two kinds of test, both worth having

Unit tests against a mock server. A mock implementation of the server runs inside plain JUnit, with no server to start. It is fast and the right tool for logic: a cooldown that expires, an economy that rounds, a config that parses. What it cannot show you is what a real client sees, and it does not run NMS code.

Integration tests against a real server. Here the server is the real Paper jar with your plugin and its dependencies loaded, and a client joins it. This is where the bugs live that players report: the menu that opens empty because a placeholder plugin loaded late, the item that duplicates on a shift-click, the command that works for ops only. These tests are slower, so you write fewer of them and aim them at the paths players use.

Most plugins want both. This guide is about the second kind.

What a real-server test needs

  • A Paper server you can start and stop from a script, with your fresh build in plugins/.
  • A client that joins it. A bot speaking the protocol is enough; it does not need a game window.
  • Steps the bot runs, like typing a command, waiting for a menu, clicking a slot.
  • Checks: the menu title, an item in a slot, a chat line, a line in the server log.
  • An exit code and a report your CI can read.

IgniteTestTool covers all five, built around scenario files you can record by playing.

Write a scenario

A scenario is a list of steps for one bot, in JSON or YAML. This one opens an island menu and clicks into the members page:

scenarios/island-menu.json
{
  "name": "Island menu",
  "bot": "TestBotA",
  "steps": [
    { "do": "join" },
    { "do": "chat", "c": "/is" },
    { "do": "expectWindow", "title": "(?i)island", "timeout": 4000 },
    { "do": "click", "custom": "(?i)members" },
    { "do": "parallel", "bots": 3, "pattern": "Test_{n}", "steps": [{ "do": "join" }, { "do": "quit" }] },
    { "do": "quit" }
  ]
}

TestBotA joins, types /is, waits up to four seconds for a menu whose title matches (?i)island and clicks the item named like members. Then three more bots join and quit at once. A step that does not pass fails the run, and the report says which one and why. Titles and item names are matched with small caps read as plain letters, so styled menus still match.

You do not have to write these by hand: the recorder turns what you do with a bot into steps. For checks a client cannot see, like an entity's health or a block's state, a small server agent plugin answers server and assertServer steps.

Bots join with offline names on a server with online-mode=false, or with a saved premium account for online-mode servers.

Run it in CI

The same jar runs without a window when the command line has --run-scenario:

java -jar IgniteTestTool.jar --run-scenario tests/scenarios --server-dir server --start-server --junit build/itt/junit.xml --timeout 10m

It starts the server, waits for its Done line, joins the bots, plays every file in name order, writes JUnit XML, stops the server and exits with 0 when everything passed, 1 when a scenario failed or the server did not start, 2 for a bad command line and 3 when it is not licensed. Errors in the server log fail the run by default, each as its own test case with the stack trace; --ignore-exceptions takes a regex for the ones you accept.

    1. Add two secrets to the repository

      ITT_JAR_URL, a download link for your IgniteTestTool jar, and ITT_LICENSE, your licence key. The key takes the licence's shared CI slot, which does not count against your own computers.

    2. Copy the workflow

      Config keyeula.txtFileserver.propertiesThe wiki's CI page has a GitHub Actions file to copy: it builds the plugin, downloads Paper 1.21.11, writes eula.txt and server.properties, runs the scenarios and uploads the reports. It runs on windows-latest, because the tool's process guard is Windows only.

    3. Keep the evidence

      Add --report-html for a page with every step and a gallery of captures, and --summary for a text summary. On GitHub Actions the summary also lands on the job page.

    4. Speed it up when the suite grows

      --cache skips files that passed before against the same text, includes and jars. --workers 3 splits the folder over three copies of the server at once.

Or run it from JUnit 5

If your build already runs JUnit, the extension puts the scenarios in the same test tree:

build.gradle
dependencies {
  testImplementation 'com.ignitedev:IgniteTestTool-junit:1.3.0'
  testImplementation 'org.junit.jupiter:junit-jupiter'
  testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
 
tasks.named('test') {
  useJUnitPlatform()
}
@IgniteTest(port = 25600, version = "1.21.10", scenarios = "src/test/itt")
class FlightTest {
 
  @ScenarioTest("s08-a-flight-afk.yml")
  void flight(GroupResult group) {
  }
}

The file runs once and every top level group in it becomes its own test, named after the group, in the IDE and in the build report. A failed group fails with the step that broke, the bot and the message. Steps can also be written in Java with ScenarioBuilder, and Ignite.verify fails the test with every failed step and the last 40 lines of the transcript. Each run leaves its log under build/itt.

Filejunit-platform.properties@IgniteTest tags the class ignite, so excludeTags 'ignite' keeps bot tests out of a quick unit run. Host, port and version can be overridden from junit-platform.properties, so CI can point the same tests at another server.

Two limits worth knowing before you plan around it: the JUnit engine does not start the server, so start it before the tests or run them from a job that does; and server log errors do not fail a JUnit test the way they fail a CI mode run.

Requirements and price

The desktop app runs on Windows 10 or 11 with JDK 21, against Paper 1.21.4 to 1.21.11. IgniteTestTool is 69.99 EUR a month, 150 EUR every three months, 300 EUR a year or 999.90 EUR once, from its own shop.

Where to go next

Written from

  1. IgniteTestTool wiki: JUnit 5, CI mode, Scenarios, Bots