PlayerTestAdapter provides mock player creation and property access, while PlayerAssert verifies game mode, name, world assignment, and alive state.
Testing player logic without real clients is essential for CI/CD pipelines and automated regression testing. Mock players let you verify game mode switches, world assignments, and player-specific permissions entirely on the server side.
Complete Example Suite
Adapter Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
createMockPlayer | String name | Object | Create a mock player entity with the given name |
getPlayerName | Object player | String | Get the player’s display name |
getGameMode | Object player | String | Get the player’s current game mode |
getPlayerWorld | Object player | Object | Get the world the player is assigned to |
isPlayerAlive | Object player | boolean | Check if the player entity is alive |
Assertion Methods
| Method | Parameters | Failure Message |
|---|---|---|
assertGameMode | Object player, String expected | ”Expected game mode [expected] but was [actual]“ |
assertPlayerName | Object player, String expected | ”Expected player name [expected] but was [actual]“ |
assertPlayerInWorld | Object player, String expectedWorldName | ”Expected player to be in the given world” |
assertPlayerAlive | Object store, Object ref | ”Expected player to be alive” |
When to Test Players
Player tests are valuable when your mod:- Implements game mode switches (survival to creative, custom modes)
- Assigns players to specific worlds (lobbies, dungeons, arenas)
- Has player-specific logic that needs verification without real clients
- Combines with permission checks (see Permissions)
Next Steps
- Permissions - test permission checks on mock players
- Commands - test commands with mock senders
- World Testing - entity positioning in worlds