Skip to content

AchievementTest

remmy edited this page Oct 12, 2024 · 5 revisions

The AchievementTest class thoroughly tests the functionality of the Achievement class by covering all its key methods. It verifies that achievements are properly created with the correct quest name, description, type, and icon path.

Testing Plan

Initialisation

private Achievement achievement;

    @BeforeEach
    void setUp() {
        achievement = new Achievement("Quest 1", "Defeat 10 enemies", false, false, Achievement.AchievementType.ENEMY, "icons/enemy.png");
    }

Tests

  • testGetQuestName(): Initialises an achievement and checks if the quest name is returned.
  • testGetQuestDescription(): Verifies that the description of the achievement is returned.
  • testIsCompleted(): Checks if the achievement is completed.
  • testComplete(): Ensures that the achievement is marked as completed.
  • testIsSeen(): Checks if achievement is seen or not.
  • testSetSeen(): Sets achievement as seen.
  • testGetType(): Confirms that the correct type of achievement is returned.
  • testGetIconPath(): Checks that the correct icon path for the achievement is returned.
  • testSerialization(): Serialises the achievement to JSON and verifies that deserialisation.
  • testDeserialization(): Deserializes an achievement from JSON data and checks that all attributes are correctly restored.

Visual Testing

ADD PIC HERE!!!

Clone this wiki locally