RandomComboService - UQcsse3200/2024-studio-3 GitHub Wiki
Test Environment
- Framework: JUNIT 5
- Dependencies:
EventHandler
: Used to trigger eventsRandomComboService
: Class being testedServiceLocator
: Manages services used throughoutMockito
: Used to mock dependencies
Test Cases
1. testGetSelectedUpgrade
- Purpose: To verify that
getSelectedUpgrade()
returns one of the upgrades - Setup: Initialise
RandomComboService
with a mockedEventHandler
- Expected Outcome: Returns a string that matches a valid upgrade
2. testActivateUpgrade
- Purpose: To verify that
activateUpgrade
triggers correct event based on selected upgrade - Setup:
- Initialise
RandomComboService
with a mockedEventHandler
- Override the
getSelectedUpgrade
method
- Initialise
- Expected: The
activateUpgrade()
method triggers the event with mockedEventHandler
3. testGetEvents
- Purpose: To verify that
getEvents
returns the correctEventHandler
- Setup: Initialise
RandomComboService
with a mockedEventHandler
- Expected: Use
assertEquals
to check if returned instance matches mock provided in setup