RageUpgrade - UQcsse3200/2024-studio-3 GitHub Wiki
Test Environment
- Framework: JUNIT 5
- Dependencies:
Mockito
: For mocking dependenciesParameterizedTest
: For testing different inputs
Test Cases
1. testRageOverlayPopsUP
-
Purpose: To ensure that the rage overlay becomes visible when rage mode is activated.
-
Setup:
- Call activateRageMode() on the rageUpgrade instance.
- Verify that the rageModeOn event is triggered, and the layout becomes visible.
-
Expected Outcome: The rage overlay (layout) should be visible, and isRageActive() should return true. Also the event handler should trigger event
rageModeOn
2. testRageOverlayCloses
-
Purpose: To ensure that the rage overlay is hidden when rage mode is deactivated.
-
Setup:
- Call activateRageMode() followed by deactivateRageMode() on the rageUpgrade instance.
- Verify that the rageModeOff event is triggered and that the layout becomes hidden.
-
Expected: The rage overlay (layout) should be hidden, and isRageActive() should return false. Also the event handler should trigger rageModeOff event.
3. testRageMeterDepletesIn30Seconds
-
Purpose: Ensure that the rage meter depletes over a span of 30 seconds and rage mode deactivates.
-
Setup:
- Call activateRageMode() and simulate 30 seconds by repeatedly calling update() while mocking gameTime.getDeltaTime() to return 1 second.
- Verify the value of the rage meter after 30 seconds.
-
Expected: After 30 seconds, the rage meter should deplete to 0, and deactivateRageMode() should be triggered. Also the rage meter should then start filling after depleted
4. testRageMeterFillsIn90Seconds
- Purpose: Ensure that the rage meter fills up completely over 90 seconds when rage mode is inactive.
- Setup: Set the rage meter to 0 and simulate 90 seconds by repeatedly calling update() while mocking gameTime.getDeltaTime() to return 1 second.
- Expected: After 90 seconds, the rage meter should fill up to 1f, and isRageFilling() should return false.
5. testRageDeactivationBeforeDepletion
-
Purpose: To ensure that deactivating rage mode before full depletion correctly transitions into the filling phase and tracks progress correctly.
-
Setup:
- Use parameterized rage meter values (e.g., 0.25f, 0.5f, 0.75f) and deactivate rage mode.
- Simulate time and check if the rage meter starts filling with accurate progress.
-
Expected: After deactivation, the rage meter should start filling, and the fill time remaining should be calculated correctly.
6. testCannotActivateRageModeWhileFilling
- Purpose: To ensure that rage mode cannot be activated while the rage meter is still filling up.
- Setup: Set the rage meter to a partially filled value (e.g., 0.5f) and attempt to activate rage mode.
- Expected: Rage mode should not activate, and isRageActive() should return false.
7. testDispose
-
Purpose: To verify that resources used by RageUpgrade are properly unloaded during disposal.
-
Setup:
- Call dispose() on the rageUpgrade instance.
- Verify that the resourceService.unloadAssets() method is called for the relevant assets.
-
Expected: The resourceService should unload the assets related to the rage upgrade, and no resources should remain in memory.
8. tearDown
- Purpose: Ensure that the service locator is cleared after each test to avoid contamination across tests.
- Setup: Call ServiceLocator.clear() after each test to ensure no lingering services.
- Expected: All services should be removed from ServiceLocator, ensuring a clean environment for subsequent tests.