Crafting System Testing Plan Sprint Three - UQdeco2800/2022-studio-2 GitHub Wiki

Junit Testing

In this section, the components tested for sprint two and three will be discussed. The method used are:

  1. JUnit testing.
  2. Sonarcloud testing.

Test Plan

In this sprint, we were able to test whether the Material was successfully created. This helps debug functionality and reduces errors. In addition, I tested the "Open Crafting Table" to make sure I can start the Crafting Table properly. To support testing and keeping a record of feature code, we've added journaling to the Open&Close Crafting Table, Add&Remove Material Form Box1/2, and Crafting Weapon implementations to ensure proper recording and journaling.

1. Crafting Logic

@Test
    void canBuildTest() {
        List<WeaponConfig> buildItemsTest = new ArrayList<>();
        List<Materials> inventoryContentsTest = new ArrayList<>();
        inventoryContentsTest.add(Materials.Steel);
        inventoryContentsTest.add(Materials.Wood);
        inventoryContentsTest.add(Materials.Gold);
        inventoryContentsTest.add(Materials.Iron);
        inventoryContentsTest.add(Materials.Poop);
        CraftingLogic.canBuild(inventoryContentsTest);
        assertEquals(CraftingLogic.canBuild(inventoryContentsTest), buildItemsTest);
    }
@Test
    void getWeaponsTest() {
        WeaponConfigSetup configs =
                FileLoader.readClass(WeaponConfigSetup.class, "configs/Weapons.json");
        List<WeaponConfig> possibleWeaponsTest = new ArrayList<>();
        possibleWeaponsTest.add(configs.athenaDag);
        possibleWeaponsTest.add(configs.heraDag);
        possibleWeaponsTest.add(configs.SwordLvl2);
        possibleWeaponsTest.add(configs.dumbbell);
        possibleWeaponsTest.add(configs.tridentLvl2);
        possibleWeaponsTest.add(configs.heraAthenaDag);
        possibleWeaponsTest.add(configs.plunger);
        possibleWeaponsTest.add(configs.pipe);
        possibleWeaponsTest.add(configs.goldenPlungerBow);
        possibleWeaponsTest.add(configs.plungerBow);

        assertNotSame(possibleWeaponsTest, CraftingLogic.getPossibleWeapons());

1. Material Factory

@Test
    void createBaseMaterial() {
        Entity baseEntity;
        baseEntity = MaterialFactory.createBaseMaterial();
        int id = baseEntity.getId();
        assertEquals(baseEntity.getId(), id);
        assertTrue(baseEntity instanceof Entity);
    }
@Test
    void createGold(){
        Entity entity = MaterialFactory.testCreateGold();
        assertTrue(entity.checkEntityType(EntityTypes.CRAFTABLE));
        assertTrue(entity.checkEntityType(EntityTypes.GOLD));

1. Open Crafting Component

@Test
    void setCraftingStatus() {
        if (OpenCraftingComponent.getCraftingStatus()) {
            OpenCraftingComponent.setCraftingStatus();
            assertEquals(OpenCraftingComponent.getCraftingStatus(), false);
        }
    }

Future Test plan

In the next sprint we will Mock the methods in GameareadisPlay and whether we can successfully pause, restart, and exit the game.

⚠️ **GitHub.com Fallback** ⚠️