BonusItems - UQdeco2800/2021-ext-studio-2 GitHub Wiki
Testing Ecosystem
the GameExtension class makes it easy by mocking the ligdx and game-engine classes
@ExtendWith(GameExtension.class)
public class AchievementBonusItemTest
Java Lang Reflect: Used to access private methods and private fields of a class from the testing suite and make them accessible for testing purposes
JUnit: Used for assertions and class extendWith
decorator plugins.
the logic of the bonus items is same as the Item Pickup Testing
Check if the bonusItem could be spawned at the game world
@Test
void shouldSpawnBonusItems() {
AchievementsBonusItems achievementsBonusItems = mock(AchievementsBonusItems.class);
achievementsBonusItems.spawnBonusItem();
verify(achievementsBonusItems).spawnBonusItem();
}