-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing worlds not cleaning up between tests
- Loading branch information
1 parent
b2fc0f1
commit 5d54c95
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/test/java/com/builtbroken/tests/example/TestSpawning.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.builtbroken.tests.example; | ||
|
||
import com.builtbroken.mc.testing.junit.TestManager; | ||
import net.minecraft.entity.passive.EntityBat; | ||
import net.minecraft.entity.passive.EntitySheep; | ||
import net.minecraft.world.World; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Created by Dark(DarkGuardsman, Robert) on 1/2/2020. | ||
*/ | ||
public class TestSpawning | ||
{ | ||
private static TestManager testManager = new TestManager("spawning"); | ||
|
||
@AfterEach | ||
void afterEach() { | ||
testManager.cleanupBetweenTests(); | ||
} | ||
|
||
@Test | ||
void spawnBat() { | ||
final World world = testManager.getWorld(); | ||
|
||
//Create bat | ||
final EntityBat bat = new EntityBat(world); | ||
bat.forceSpawn = true; | ||
bat.setPosition(100, 10, 100); | ||
|
||
//Spawn bat, returns true if spawned | ||
Assertions.assertTrue(world.spawnEntity(bat)); | ||
|
||
//Check that bat was added to the world | ||
Assertions.assertTrue(world.loadedEntityList.contains(bat)); | ||
Assertions.assertEquals(1, world.loadedEntityList.size()); | ||
} | ||
|
||
@Test | ||
void spawnSheep() { | ||
final World world = testManager.getWorld(); | ||
|
||
//Create bat | ||
final EntitySheep sheep = new EntitySheep(world); | ||
sheep.forceSpawn = true; | ||
sheep.setPosition(100, 10, 100); | ||
|
||
//Spawn bat, returns true if spawned | ||
Assertions.assertTrue(world.spawnEntity(sheep)); | ||
|
||
//Check that bat was added to the world | ||
Assertions.assertTrue(world.loadedEntityList.contains(sheep)); | ||
Assertions.assertEquals(1, world.loadedEntityList.size()); | ||
} | ||
} |