clean up spawn creature tests
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-08-28 12:34:44 -04:00
parent 0a74bed5d6
commit 50aaf3f1f5

View File

@ -1,48 +1,39 @@
package electrosphere.entity;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.joml.Vector3d;
import org.junit.jupiter.api.Disabled;
import annotations.IntegrationTest;
import electrosphere.engine.Globals;
import electrosphere.engine.Main;
import electrosphere.engine.profiler.Profiler;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.NetUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import template.EntityTestTemplate;
import testutils.TestEntityUtils;
public class SpawningCreaturesTest {
@BeforeEach
public void initEngine(){
LoggerInterface.initLoggers();
LoggerInterface.loggerEngine.INFO("[Test] Spawn many creatures");
Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = true;
Globals.HEADLESS = true;
Profiler.PROFILE = false;
NetUtils.setPort(0);
Main.startUp();
}
/**
* Basic entity spawning integration tests
*/
public class SpawningCreaturesTest extends EntityTestTemplate {
// @Test
// public void testSpawnCreature(){
// System.out.println("[Test] Spawn creature");
// Globals.RUN_CLIENT = false;
// Globals.RUN_SERVER = true;
// NetUtils.setPort(0);
// Main.startUp();
// CreatureUtils.spawnBasicCreature("human", null);
// Main.mainLoop(1);
// assert TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)) == 1;
// }
//must wait on viewport testing, otherwise number of entities isn't going to be correct because the player character is spawning
@Disabled
@IntegrationTest
public void testSpawnCreature(){
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
assertEquals(1, TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)));
}
@Test
//must wait on viewport testing, otherwise number of entities isn't going to be correct because the player character is spawning
@Disabled
@IntegrationTest
public void testSpawnMultipleCreatures(){
// Realm realm = Globals.realmManager.getRealms().iterator().next();
// for(int i = 0; i < 100; i++){
// CreatureUtils.serverSpawnBasicCreature(realm, new Vector3d(0,0,0), "human", null);
// }
// Main.mainLoop(1);
// assert TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)) == 100;
int numberToSpawn = 100;
for(int i = 0; i < numberToSpawn; i++){
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
}
assertEquals(numberToSpawn, TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)));
}
}