Testing Plan for WeaponAnimationController component - UQcsse3200/2024-studio-1 GitHub Wiki
WeaponAnimationControllerTest
Class
Test Plan for Objective
The purpose of this test plan is to validate the functionality of the WeaponAnimationController
class, which manages the animation logic for weapon entities and their connection to players. The tests aim to ensure the correct creation of the animation controller, and the connection and disconnection behavior of the controller when attached to a player.
Test Environment
Framework: JUnit 5 with Mockito for mocking dependencies
Objects Used:
WeaponAnimationController
class for managing weapon animations.Entity
class representing the player entity.WeaponFactory
for creating weapon objects (mocked).NameComponent
to assign names to entities (e.g., "Ranged").
Setup:
- The
beforeEach()
method registers necessary services such asRenderService
,EntityService
,PhysicsService
, andResourceService
. - Mocks are created for
WeaponFactory
andEntity
(player entity). - Projectiles' texture atlases are loaded to simulate game assets.
Test Cases
Test Case 1: Create WeaponAnimationController
Objective: Validate the successful creation of the WeaponAnimationController
.
Setup: Instantiate a new WeaponAnimationController
.
Expected Outcome:
- The
WeaponAnimationController
instance is successfully created and is not null.
Test Case 2: Connect and Disconnect Player
Objective: Ensure the WeaponAnimationController
correctly connects and disconnects a player entity.
Setup:
- Create a new
WeaponAnimationController
. - Add the
WeaponAnimationController
to the player entity. - Add a
NameComponent
to the player entity with the name "Ranged". - Connect the player to the
WeaponAnimationController
. - Disconnect the player from the
WeaponAnimationController
.
Expected Outcome:
- After connecting, the
connected
property of theWeaponAnimationController
should betrue
. - After disconnecting, the
connected
property of theWeaponAnimationController
should befalse
.
Conclusion
This test plan ensures that the WeaponAnimationController
class behaves as expected when creating the controller, connecting a player entity, and disconnecting the player, with proper state management for the connection status.