Test Plan for Inventory Display - UQcsse3200/2024-studio-3 GitHub Wiki
1. Introduction
This test plan outlines the test cases for the InventoryDisplay class. The InventoryDisplay is responsible for creating and managing the visual representation of a player's inventory in the game, including displaying items and updating the UI when the inventory changes.
2. Test Objectives
- Verify the correct initialization of the InventoryDisplay
- Ensure proper creation and management of UI elements
- Test the updating of the display when inventory changes
- Verify the handling of different item types and states
- Test edge cases and error handling
3. Test Cases
3.1 Initialization Tests
3.1.1 Default Constructor
- Test Method:
testDefaultConstructor()
- Objective: Verify that the InventoryDisplay initializes correctly with default slot size.
- Expected Result: The component should initialize with a slot size of 200.
3.1.2 Custom Constructor
- Test Method:
testCustomConstructor()
- Objective: Ensure that the InventoryDisplay initializes correctly with a custom slot size.
- Expected Result: The component should initialize with the specified slot size.
3.1.3 Invalid Slot Size
- Test Method:
testInvalidSlotSize()
- Objective: Verify that the InventoryDisplay throws an exception when initialized with invalid slot sizes.
- Expected Result: An IllegalArgumentException should be thrown for slot sizes <= 0.
3.2 UI Creation Tests
3.2.1 Create with Empty Inventory
- Test Method:
testCreateWithEmptyInventory()
- Objective: Ensure that the InventoryDisplay creates the correct number of empty slots for an empty inventory.
- Expected Result: The display should create the correct number of slots, each containing only the background image.
3.2.2 Create with Items
- Test Method:
testCreateWithItems()
- Objective: Verify that the InventoryDisplay correctly creates slots with items when the inventory contains items.
- Expected Result: The display should create slots with both background and item images for occupied slots.
3.3 Update Tests
3.3.1 Update Inventory
- Test Method:
testUpdateInventory()
- Objective: Ensure that the InventoryDisplay updates correctly when items are added or removed from the inventory.
- Expected Result: The display should update to show new items, remove displayed items, and handle null texture paths.
3.4 Resource Management Tests
3.4.1 Asset Loading
- Test Methods: Various (integrated into other tests)
- Objective: Verify that the InventoryDisplay correctly loads and uses texture assets for slots and items.
- Expected Result: The correct textures should be loaded for slots and items, including handling of null textures.
3.5 Disposal Tests
3.5.1 Dispose
- Test Method:
testDispose()
- Objective: Ensure that the InventoryDisplay properly disposes of its resources.
- Expected Result: All UI elements (table and slots) should be removed from the stage.
4. Test Execution
All tests should be executed as part of the test suite in InventoryDisplayTest.java. The testing framework (JUnit) will report on the success or failure of each test case.
5. Conclusion
This test plan covers the core functionality of the InventoryDisplay, including initialization, UI creation, updating, resource management, and disposal. Successful execution of all test cases will provide confidence in the robustness and correctness of the InventoryDisplay implementation.