Leviathan Testing Plan - UQcsse3200/2024-studio-2 GitHub Wiki
Testing Leviathan Entity
This section outlines the tests performed on the creation of the Leviathan entity. It verifies the functionality and components of the Leviathan NPC. These tests are located in BossFactoryTest.java between lines 121 to 175.
Test Breakdown
1. TestWaterBossCreation
- Verifies that the Water Boss entity is successfully created and is not null.
- Assertion:
assertNotNull(waterBoss, "Water Boss should not be null.");
2. TestWaterBossIsEntity
- Confirms that the Water Boss is of type
Entity, ensuring it correctly inherits from theEntityclass. - Assertion:
assertEquals(waterBoss.getClass(), Entity.class);
3. TestWaterBossHasComponents
- Verifies the presence of critical components for the Water Boss, including:
PhysicsComponentfor handling physics-related behaviors.PhysicsMovementComponentfor managing movement physics.ColliderComponentfor detecting collisions.BossAnimationControllerfor managing boss-specific animations.CombatStatsComponentto track health and other combat stats.WaterAttackComponentto handle water-based attacks.
- Assertions:
assertNotNull(waterBoss.getComponent(PhysicsComponent.class)); assertNotNull(waterBoss.getComponent(PhysicsMovementComponent.class)); assertNotNull(waterBoss.getComponent(ColliderComponent.class)); assertNotNull(waterBoss.getComponent(BossAnimationController.class)); assertNotNull(waterBoss.getComponent(CombatStatsComponent.class)); assertNotNull(waterBoss.getComponent(WaterAttackComponent.class));
4. TestWaterBossStats
- Confirms that the Water Boss has the correct initial combat stats, particularly 200 health points.
- Assertion:
assertEquals(200, waterBoss.getComponent(CombatStatsComponent.class).getHealth(), "Water Boss should have 200 HP.");
5. TestWaterBossAnimation
- Ensures the Water Boss has the correct animations, specifically checking for the "idle" animation.
- Assertion:
assertTrue(waterBoss.getComponent(AnimationRenderComponent.class).hasAnimation("idle"), "Water Boss should have idle animation.");
6. TestWaterBossSetPosition
- Verifies that the Water Boss can be set to a specific position, such as (0, 0).
- Assertion:
Vector2 pos = new Vector2(0f, 0f); waterBoss.setPosition(pos); assertEquals(pos, waterBoss.getPosition());
These tests ensure that the Leviathan entity is correctly initialized with essential components, proper animations.