Taghunter98 / JavaGo

0 stars 0 forks source link

Test Item Class #3

Open Taghunter98 opened 4 days ago

Taghunter98 commented 4 days ago

Ticket Title: Test Item Class Functionality and Methods

Description: This ticket focuses on testing the Item class within the JavaGo package. The goal is to ensure that all core methods work as expected, including object creation, item detail printing, and array handling.

Related Issue: #Item-Class-Implementation (link to the corresponding development issue)

Acceptance Criteria:

Test Plan:

  1. Test Environment Setup:

    • Ensure Java JDK 11+ is installed.
    • Run tests in an IDE that supports JUnit testing (e.g., IntelliJ IDEA or Eclipse).
    • Confirm that dependencies such as the Terminal class are functional.
  2. Test Cases:

    • Test Case ID: TC-001

      • Description: Verify the creation of an Item object.
      • Steps to Reproduce:
        1. Create an Item object using the following attributes:
          Item("Americano", "Strong black coffee", 2.50, 5, false)
        2. Assert that the values for item name, description, price, calories, and allergy status are correctly set.
      • Expected Result: The Item object should store the correct values for all attributes.
    • Test Case ID: TC-002

      • Description: Validate the printItem method with a valid item name.
      • Steps to Reproduce:
        1. Create several Item objects and add them to the items array list.
        2. Call Item.printItem("Americano").
      • Expected Result: The details of the Americano item should be printed, including the name, description, calories, and allergen info.
    • Test Case ID: TC-003

      • Description: Validate the printItem method with an invalid item name.
      • Steps to Reproduce:
        1. Call Item.printItem("Mocha") when no Mocha item exists in the list.
      • Expected Result: "Item not found" should be printed to the console.
    • Test Case ID: TC-004

      • Description: Validate the printItems method.
      • Steps to Reproduce:
        1. Create multiple Item objects and add them to the items list.
        2. Call Item.printItems().
      • Expected Result: All items in the items array list should be printed with details like name, description, price, and calories.
    • Test Case ID: TC-005

      • Description: Validate accessor methods.
      • Steps to Reproduce:
        1. Create an Item object.
        2. Call the following methods: getItemName(), getItemDes(), getPrice(), getItemCal(), hasAllergy().
      • Expected Result: Each method should return the correct value corresponding to the object’s attributes.
  3. Post-conditions:

    • Ensure no data persists between tests, and the items list should be cleared after test completion.

Additional Notes: