StateEvaluator) and navigation (via AStar pathfinding). AIAssert and AITestAdapter handle AI state checks, while PathfindingAssert and PathfindingTestAdapter verify that pathfinding classes are available on the server classpath.
AI testing is valuable when your mod modifies NPC behavior - custom AI states, patrol routes, aggression triggers, or idle behaviors. These tests verify that the AI system is active on spawned NPCs and that the pathfinding infrastructure is available for navigation.
Complete Example Suite
AI Adapter Methods
| Method | Returns | Description |
|---|---|---|
getStateEvaluator(Object store, Object ref) | Object | Get the StateEvaluator component from an entity |
isAIActive(Object store, Object ref) | boolean | Check if the entity’s AI is currently active |
stateEvaluatorClassAvailable() | boolean | Check if the StateEvaluator class is on the classpath |
AI Assertion Methods
| Method | Failure Message |
|---|---|
assertAIActive(Object store, Object ref) | ”Expected entity AI to be active but it was inactive” |
assertAIInactive(Object store, Object ref) | ”Expected entity AI to be inactive but it was active” |
Pathfinding Adapter Methods
| Method | Returns | Description |
|---|---|---|
pathfindingAvailable() | boolean | Check if the AStarBase class is on the classpath |
astarEvaluatorAvailable() | boolean | Check if the AStarEvaluator class is on the classpath |
pathFollowerAvailable() | boolean | Check if the PathFollower class is on the classpath |
Pathfinding Assertion Methods
| Method | Failure Message |
|---|---|
assertPathfindingAvailable() | ”Expected AStar pathfinding classes to be available on the classpath but none were found” |
Key Details
- AI assertions require a valid ECS store and entity reference - use
@WorldTestwithspawnNPCto get a fully initialized NPC, or@EcsTestfor classpath-level checks. - The
StateEvaluatorcomponent must be present on the entity for AI checks to work. If missing, the assertion fails with a component-not-found message. - Use the adapter
stateEvaluatorClassAvailable()as a precondition guard before running AI-specific tests.
Next Steps
- NPCs - NPC spawning and role verification
- Physics - movement and pathfinding-related testing
- ECS Testing - component-level access