test(TerasologyTestingEnvironment): avoid NPE on tearDown (the result of failed setUp)
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.engine.context.Context;
import org.terasology.engine.core.ComponentSystemManager;
import org.terasology.engine.core.EngineTime;
import org.terasology.engine.game.Game;
import org.terasology.engine.logic.console.Console;
import org.terasology.engine.logic.console.ConsoleImpl;
-import org.terasology.gestalt.naming.Name;
import org.terasology.engine.network.NetworkSystem;
import org.terasology.engine.network.internal.NetworkSystemImpl;
import org.terasology.engine.persistence.StorageManager;
import org.terasology.engine.recording.RecordAndReplaySerializer;
import org.terasology.engine.recording.RecordAndReplayUtils;
import org.terasology.engine.recording.RecordedEventStore;
-import org.terasology.reflection.TypeRegistry;
import org.terasology.engine.world.block.BlockManager;
import org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager;
+import org.terasology.gestalt.naming.Name;
+import org.terasology.reflection.TypeRegistry;
import java.nio.file.Path;
*
*/
public abstract class TerasologyTestingEnvironment {
+ private static final Logger logger = LoggerFactory.getLogger(TerasologyTestingEnvironment.class);
+
protected static Context context;
private static ModuleManager moduleManager;
@@ -113,7 +117,11 @@ public void setup() throws Exception {
@AfterAll
public static void tearDown() throws Exception {
+ if (env != null) {
env.close();
+ } else {
+ logger.warn("TTE.env unexpectedly null during tearDown");
+ }
}
