NPC test sprint3 - UQdeco2800/2022-studio-2 GitHub Wiki

Back to Dialogue & NPCs page

Overview

To test whether the npcs&dialogues we created met our requirements, we created a series of tests for it to help us confirm its accuracy.
Tested for dialogue text loading, changes, item addition, new npc positions and dialog button positions.
All the test classes are written in the NpcTest.java file.
Path:
image

Test plan

1.Test that the text in the dialog box loads.
2.Test whether the text of each NPC can be corresponded to.
3.Test that the text in the dialog box is loaded correctly according to the change in value.
4.Test whether items can be added to the inventory.
5.Test to see if the correct NPC has added items to the inventory.
6.Iterate for the old NPC location test. Test if the NPC is at the new location.Whether the new NPC location is in the map.
7.Test that the dialog box buttons are in the correct position.

Test code

image
image
Start testing with the Junit5 test format. Create variables for the classes that will be tested.
image
Initialize and assign values to variables.Simulates npc's that interact by changing their names.
image
Add a prerequisite to each NPC to determine whether the corresponding parameter needs to be added and whether the item needs to be added based on this condition.(I know that the if condition is fixed, but I wanted to write it out to facilitate better understanding.If a change is made to the value of the variable above, the test will fail.)
image
Create dialogue for each NPC to facilitate testing.

Test the NPC & dialogue's button position by scale.Each npc has a corresponding test.

image

Test that the text in the dialog box is loaded correctly according to the change in value.Each npc has a corresponding test.

image

Tests of text were created for humanGuard, friendlyCreature and plumberFriend. An error is reported when the variable is larger than the number of conversations available.

image image image

Test if items have been added to the inventory. When changing the name of an NPC, it looks to see if the npc has an item, and the test succeeds when the names of the three NPCs with items are set. My preset is plumberFriend.

image



Back to Dialogue & NPCs page

Author

  • Bokai Zhang
  • GitHub: hideonbush-crl
  • Discord: Bkai Z(bokai)#6469
⚠️ **GitHub.com Fallback** ⚠️