Repository navigation
Achievements Test Plan
Part of Achievements · AchievementsService
The achievement logic is pure Java, so a small number of unit test classes cover almost all of it without launching the game. Tests use JUnit 5 and Mockito. Boss encounter behaviour needs large setups (mocked factories, timers, many components), so the boss reporters are tested manually with the checklist in section 5.
| Test class | Covers |
|---|---|
AchievementsTest |
Achievement, AchievementsFactory, and the shipped configs/achievements.json
|
AchievementServiceTest |
AchievementService: dispatch, queries, save and restore |
AchievementReportersTest |
AchievementProgressComponent, RoomAcheivements
|
| Manual checklist |
AchievementDisplay, SnakeAchievementComponent, FinalBossAchievementComponent
|
src/test/java/com/csse3200/game/components/achievements/AchievementsTest.java
One class with three nested groups. It replaces the earlier AchievementTest and AchievementConfigTest.
| Group | What it checks |
|---|---|
AchievementBehaviour |
Constructors, update unlocking once, the condition not being re-evaluated after unlock, setCondition, progress and target, restoreState
|
FactoryRules |
Unknown type rejected, name/description/category copied, and the unlock rule of each type: dungeonClear, dungeonReached, gold, enemyKillCount (any enemy), killStreak reset, speedRun, enemySet, snake and finalBoss
|
ShippedConfig |
Loads the real configs/achievements.json. Every entry builds, every name is non-blank and unique, and the four miniboss achievements unlock only for the right enemy and only once. |
The shipped-config checks catch typo'd types and duplicate names, which would break the game at start-up or the save data.
src/test/java/com/csse3200/game/services/AchievementServiceTest.java
src/test/java/com/csse3200/game/components/achievements/AchievementReportersTest.java
These tests fire entity events and check the AchievementContext sent to a mocked service. RoomConfig is assumed to have a no-arg constructor and a public dungeonId field (as RoomAcheivements reads it). Adjust if it differs.
JaCoCo is already configured in the project's Gradle build.
./gradlew test jacocoTestReportOpen the HTML report (usually core/build/reports/jacoco/test/html/index.html; check your module name) and look at:
com.csse3200.game.components.achievements-
com.csse3200.game.services→AchievementService
Target: at least 90% line coverage on those classes. The remaining uncovered code should be the reporters' boss logic and AchievementDisplay, both covered by the checklist below.
| # | Scenario | Expected |
|---|---|---|
| 1 | Clear the first dungeon | "First Steps" toast appears with sound. |
| 2 | Unlock two achievements at once (e.g. clear and speed run) | Toasts show one after the other, 2 seconds each, with no overlap. |
| 3 | Pick up 10 gold | "Coin Collector" unlocks on the 10th pickup. |
| 4 | Kill 5 enemies with no damage taken, then repeat but get hit after the 4th kill | Streak achievement unlocks only in the first case. |
| 5 | Clear dungeon one in under 60 seconds | "Sonic Who?" unlocks. Over 60 seconds, it does not. |
| 6 | Unlock some achievements, save, quit, load | They remain unlocked and are not re-announced. Progress is restored. |
| 7 | Snake: land a hit while it is exposed | "Whack-a-Mole" unlocks once. |
| 8 | Snake: defeat it without collecting any green gems | "What are those green things?" unlocks. |
| 9 | Final boss: stay hands-off for the Stage 1 break | "I need a break too" unlocks. |
| 10 | Final boss Stage 2: avoid all fireballs | "I'm fireproof!" unlocks. |
| 11 | Final boss Stage 3 Wave 1: get hit by ice | "Whoa! The Snow Queen" unlocks. Three consecutive hits unlock "Brrr, it's freezing!". |
| 12 | Die mid-boss fight | No boss achievement is reported after the player's death. |
| 13 | Open the game with no achievement service (e.g. a test screen) | No crash. |
| 14 | Snake Stage 2: collect a green gem | "Green bubble" unlocks once, and "What are those green things?" no longer unlocks on a win. |
| 15 | Final boss Stage 2: hit the boss with a player ice projectile | "Coolin' off, make it fun" unlocks. |
| 16 | Final boss Stage 3 Wave 1: land the first sword or dagger hit | "You flashed too fast" unlocks. |
| 17 | Final boss Stage 3 Wave 2: trigger a statue teleport | "How can a statue even flash?" unlocks. |
| 18 | Final boss Stage 1: hit the boss during the break | "I need a break too" does not unlock. |
Entities and Components
Input Handling
- Service Locator
- Loading Resources
- Logging
- Unit Testing
- Debug Terminal
- Animations
- Audio
- AI
- Physics
- Terrain
- Concurrency & Threading
- Settings