Skip to content

Test plan For TutNpc Animation Controller

Aniket Gupta edited this page Oct 19, 2023 · 1 revision

TutnpcAnimationController Class

The TutnpcAnimationController class is responsible for managing animations for the Tutnpc (Tutorial NPC) entity in the game. This wiki page provides documentation for the class and its associated test class.

Introduction

The TutnpcAnimationController ensures proper animation handling and updates for the Tutnpc entity.

Class Overview

Methods

create()

  • Description: Initializes the animation controller and triggers the initial animation.

update()

  • Description: Updates the animation state based on the animation duration and the current animation.

Test Class: TutnpcAnimationControllerTest

The TutnpcAnimationControllerTest class is responsible for testing the methods of the TutnpcAnimationController class to ensure proper functionality.

Mock Objects:

  • AssetManager (Mock): Used to simulate asset loading.
  • AnimationRenderComponent (Mock): Used to simulate rendering animations.
  • TextureAtlas (Mock): Used to simulate the texture atlas for animations.

The TutnpcAnimationController will be initialized with these mock objects for testing purposes.

Test Setup

Before running the test cases, the necessary mock objects and dependencies are set up for testing. The TutnpcAnimationController is initialized with mock objects for testing purposes.

Test Cases

Test Case 1: create() Method

Objective: Verify that the create method correctly initializes the animation controller and triggers the initial animation.

Test Steps:

  1. Call the create method of the TutnpcAnimationController.
  2. Verify that the startAnimation method of the mock AnimationRenderComponent is called with the expected animation key ("row-2-column-1").
Screenshot 2023-10-19 at 12 48 33 PM

Test Case 2: update() Method

Objective: Ensure that the update method of the TutnpcAnimationController correctly updates the animation state based on the animation duration and the current animation.

Test Steps:

  1. Set the animationDuration property of the controller to a specific value (e.g., 10f).
  2. Mock the getCurrentAnimation method of the AnimationRenderComponent to return a specific animation key (e.g., "row-3-column-1").
  3. Call the update method of the TutnpcAnimationController.
Screenshot 2023-10-19 at 12 48 55 PM

Conclusion

This wiki page provides documentation for the TutnpcAnimationController class and its associated test class, TutnpcAnimationControllerTest. By using test cases and mock objects, we ensure that the animation controller functions correctly and can be reliably tested to maintain the reliability and correctness of the Tutnpc animation system in the game.

Contributors

Clone this wiki locally