Skip to content

Snake Testing

Jul-Wong edited this page Oct 15, 2024 · 10 revisions

This details the tests run for the creation of a snake entity. It tests various features and ensures the correct creation of that NPC. These tests can be located in NPCFactoryTest.java and can be found form lines 910 to 986.

Testing

  1. testSnakeInitialisation Checks the initialisation of the NPC by verifying its creation, name, type, and the presence of necessary components. This includes:
  • Verifying that the snake object is not null, ensuring it was created successfully.

  • Checking if the snake entity has the correct name "Snake" as specified in the configuration.

  • Confirming that the snake object is of type Entity, verifying its inheritance or implementation.

  • Ensuring the snake entity has a PhysicsComponent, which is necessary for physical interactions.

  • Validating that the snake entity includes a PhysicsMovementComponent, which handles its movement physics.

  • Verifying that the snake entity has a ColliderComponent for collision detection.

  • Checking if the snake entity has a ConfigComponent to manage its configuration settings.

Sound, BaseHint and NPC type Tests

  1. TestSnakeHasCorrectSoundPath: Ensures the sound path for the snake is correctly set to "sounds/snake-hiss.wav" in the configuration.

  2. TestSnakeHasCorrectBaseHint: Confirms that the base hint for the magpie is set correctly, matching "HHIISSSSSSS, I am the mighty Snake of the Jungle!", "You look very tasty and I am very hungry", "Go play a game and collect me some apples...", and "/msOr I will eat you whole!".

  3. TestSnakeIsFriendly: Ensures the snake entity has a FriendlyNPCAnimationController, indicating that it is a non-aggressive NPC.

Movement Tests

  1. TestSnakeHasAnimation: Validates that the snake entity has an idle animation named "float", ensuring visual representation.
  2. TestSnakeSetPosition: Verifies that the snake entity is placed correctly at the specified position (0,0) and can be moved to that location.

Visual Testing

snake test

Clone this wiki locally