Kanga Testing Plan - UQcsse3200/2024-studio-2 GitHub Wiki
Testing Kanga Boss Entity
This section details the tests performed on the creation of the Kanga boss entity. It verifies various features and components to ensure the correct functionality of the Kanga NPC. These tests are located in BossFactoryTest.java
between lines 32 to 138.
Test Breakdown
TestKangaCreation
1. - Verifies that the Kanga boss entity is successfully created, ensuring the object is not null.
- Assertion:
assertNotNull(kanga, "Kanga should not be null.");
TestKangaIsEntity
2. - Ensures that the Kanga boss is of type
Entity
, verifying the correct inheritance. - Assertion:
assertEquals(kanga.getClass(), Entity.class);
TestKangaHasComponents
3. - Checks the presence of necessary components for Kanga, including:
PhysicsComponent
for handling physical interactions.PhysicsMovementComponent
for movement physics.ColliderComponent
for collision detection.BossAnimationController
for managing animations.CombatStatsComponent
to track combat stats like health.
- Assertions:
assertNotNull(kanga.getComponent(PhysicsComponent.class)); assertNotNull(kanga.getComponent(PhysicsMovementComponent.class)); assertNotNull(kanga.getComponent(ColliderComponent.class)); assertNotNull(kanga.getComponent(BossAnimationController.class)); assertNotNull(kanga.getComponent(CombatStatsComponent.class));
TestKangaStats
4. - Ensures the Kanga boss has the correct combat stats, starting with 150 health points.
- Assertion:
assertEquals(150, kanga.getComponent(CombatStatsComponent.class).getHealth(), "Kanga should have 150 HP.");
TestKangaAnimation
5. - Validates that the Kanga boss has the correct animation, specifically checking for the "wander" animation.
- Assertion:
assertTrue(kanga.getComponent(AnimationRenderComponent.class).hasAnimation("wander"), "Kanga should have wander animation.");
TestKangaSetPosition
6. - Verifies that the Kanga boss can be positioned correctly at the specified location, such as (0,0).
- Assertion:
Vector2 pos = new Vector2(0f, 0f); kanga.setPosition(pos); assertEquals(pos, kanga.getPosition());
These tests confirm that the Kanga boss entity is properly initialized with all essential components and configurations for interaction, movement, and combat.
Visual Testing
https://youtu.be/Ny-1nAlynto?si=Xhmcj2f9uXhYmb0O&t=25
Testing KangaJoeyTask
This section describes the tests performed for the KangaJoeyTask
, located in KangaJoeyTaskTest.java
. These tests ensure that the task is functioning correctly, especially with respect to prioritisation, range checking, and spawn management.
Test Breakdown
shouldReturnCorrectPriorityWhenActiveAndInRange
1. - Verifies that the task returns the correct priority when the target is within range, and the task is active.
- Assertion:
assertEquals(5, kangaJoeyTask.getPriority());
shouldReturnNegativePriorityWhenOutOfRange
2. - Ensures that the task returns a negative priority when the target is out of range.
- Assertion:
assertEquals(-1, kangaJoeyTask.getPriority());
shouldReturnNegativePriorityWhenTooFar
3. - Verifies that the task returns negative priority when the target is too far, even if the task is active.
- Assertion:
assertEquals(-1, kangaJoeyTask.getPriority());
shouldStopSpawningWhenOutOfRange
4. - Ensures that no more Joeys are spawned when the target moves out of range.
- Assertion:
verify(eventHandler, times(1)).trigger(eq("spawnJoey"), eq(ownerEntity));
shouldNotSpawnJoeyWhenMaxSpawnsReached
5. - Verifies that no more Joeys are spawned once the maximum number of spawns is reached.
- Assertion:
verify(eventHandler, times(maxSpawns)).trigger(eq("spawnJoey"), eq(ownerEntity));
shouldReturnPriorityWhenWithinRange
6. - Ensures that the task returns the correct priority when the target is within range, even when the task is inactive.
- Assertion:
assertEquals(5, kangaJoeyTask.getPriority());
These tests confirm that the KangaJoeyTask
handles spawning, prioritisation, and range checking as expected.