Skip to main content
The Chat surface lets you assert on captured chat message strings and broadcast messages to the server. ChatAssert provides content checks that operate on raw strings (no reflection needed), while ChatTestAdapter handles message broadcasting through the Universe API. Chat testing is useful when your mod implements chat commands, message formatting, chat filters, or automated announcements. These tests verify that messages contain the expected content and that broadcasting reaches the server without errors.

Complete Example Suite

Adapter Methods

MethodReturnsDescription
broadcastMessage(String message)booleanBroadcast a message to all players via the Universe API
chatEventClassAvailable()booleanCheck if the PlayerChatEvent class is on the classpath

Assertion Methods

MethodFailure Message
assertMessageContains(String message, String expected)”Expected message to contain ‘[expected]’ but was ‘[message]‘“
assertMessageNotEmpty(String message)”Expected message to be non-empty but it was empty”

When to Test Chat

Chat tests are most useful when:
  • Your mod formats chat messages (colors, prefixes, player ranks)
  • You implement chat filters or censorship systems
  • You have automated announcements that fire on events
  • You need to verify that broadcast messages reach the Universe API
ChatAssert works on plain strings, so capture messages via event hooks or test interceptors, then pass them to the assertions.

Next Steps

  • Events - capture chat events
  • Commands - test command output messages
  • Players - mock player chat interactions