Skip to content

Achievements Test Plan

Krish edited this page Oct 21, 2026 · 7 revisions

Achievements Test Plan

Part of Achievements · AchievementsService

Strategy

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

1. AchievementsTest

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.

2. AchievementServiceTest

src/test/java/com/csse3200/game/services/AchievementServiceTest.java

3. AchievementReportersTest

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.

4. Running tests and coverage

JaCoCo is already configured in the project's Gradle build.

./gradlew test jacocoTestReport

Open 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.

5. Manual test checklist

# 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.

6. Test results

image image

Table of Contents

Home

Getting Started

Game Engine

Entities and Components
Input Handling

Features

Components
Achievements
Player
Items and Inventory
Enemies
Bosses
Interactable NPCs
Cutscenes and Dialogue
Training Grounds
Music
Weapons
Abilities & Spells
Rooms and Dungeons
Game Screens and Areas
UI

Test Plans

Team 1
Team 2

Troubleshooting

Clone this wiki locally