Test Plan For MealComponent - UQcsse3200/2024-studio-3 GitHub Wiki

Test Environment

  • Framework: JUnit 5
  • Extension: GameExtension.class

Dependencies:

  • IngredientComponent
  • MealComponent
  • ItemType enum

Objective

The purpose of this test plan is to verify the functionality of the MealComponent class in the game. The test focuses on ensuring that the MealComponent is properly constructed and its properties, such as name, type, weight, ingredients, price, and quality, are correctly calculated.

Test Setup:

Ingredients Setup: Three IngredientComponent instances are created to simulate different types of ingredients used in meals:

  • Tomato: Raw state with specific quality attributes.
  • Cucumber: Cooked state with specific quality attributes.
  • Beef: Burnt state with specific quality attributes.

Test Cases:

Test Case: MealComponent Constructor Test Purpose: Verify that the MealComponent is properly constructed with the correct name, type, weight, list of ingredients, price, and calculated quality. Setup: Create a list of three ingredients (Tomato, Cucumber, Beef) and use them to construct a MealComponent representing a "steakMeal."

Assertions:

  • Assert that the meal name is set correctly to "steakMeal".
  • Assert that the item type is ItemType.STEAKMEAL.
  • Assert that the weight of the meal is correctly set to 32.
  • Assert that the list of ingredients matches the expected list (Tomato, Cucumber, Beef).
  • Assert that the price is correctly set to 20.
  • Assert that the calculated quality of the meal is correct (33).

Expected Outcome:

The test should pass if the MealComponent constructor correctly initializes all the fields based on the provided ingredients and the meal's attributes.

Test Coverage:

The test primarily covers the constructor and getters for MealComponent. The calculation of quality based on ingredient states (raw, cooked, burnt) is also indirectly verified.

This test plan ensures that the MealComponent constructor works as expected and that the class properties are initialized and calculated correctly. Additional test cases can be added to cover more complex scenarios and edge cases.