WeatherTestAdapter to control weather and WeatherAssert to check it.
Weather testing is important when your mod has weather-dependent logic - damage modifiers during storms, visibility changes in fog, or mob spawning rules that differ by weather type. Automated tests verify these weather-dependent behaviors without waiting for natural weather cycles.
Complete Example Suite
Adapter Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
getWeather | Object world | String | Get the current weather type for the world |
setWeather | String weatherType | void | Force the world weather to the given type |
Assertion Methods
| Method | Parameters | Failure Message |
|---|---|---|
assertWeather | Object world, String expected | ”Expected weather [expected] but was [actual]“ |
assertNotWeather | Object world, String weatherType | ”Expected weather to not be [weatherType]“ |
Key Details
- Weather changes may take one tick to propagate - always call
ctx.waitTicks(1)aftersetWeatherbefore asserting. - Use
IsolationStrategy.DEDICATED_WORLDto avoid changing weather on the live server during tests. - Weather type strings are server-defined. Common values include
"clear","rain", and"snow".
Next Steps
- World Testing - entity spawning and block operations
- Effects - weather may interact with status effects
- Scheduling - world tick management