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
| Method | Returns | Description |
|---|---|---|
broadcastMessage(String message) | boolean | Broadcast a message to all players via the Universe API |
chatEventClassAvailable() | boolean | Check if the PlayerChatEvent class is on the classpath |
Assertion Methods
| Method | Failure 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.