Stendhal Quest Testing: Difference between revisions
Content deleted Content added
imported>MartinFuchs adding line breaks after "bye" steps is now done automatically |
imported>Tigertoes mNo edit summary |
||
| (130 intermediate revisions by 6 users not shown) | |||
Line 12:
* if it's not repeatable, try to come back and ask for a quest again anyway!
Some quests have already got a test written for them because chat logs have been provided. Please take a look at the report from [http://stendhalgame.org/hudson/job/stendhal_HEAD/lastStableBuild/cobertura/games_stendhal_server_maps_quests/?
'''Tip:''' If you test on a [[Host_a_Stendhal_Server|local server]], you can use the <code>/teleportto ''npc''</code> command to travel faster. See the [[Stendhal:Administration|administration page]] for other useful commands.
== Run ChatTestCreator ==
Once you have the chatlog you can use <code>games.stendhal.tools.test.ChatTestCreator</code> to make a test. We assume you are using eclipse. First, copy the chat log into the project folder of your Stendhal project. For this tutorial we are using [[File:Test Gamechat.log]] - save it and rename it to gamechat.log like your own chatlogs would be, if you want to follow the tutorial exactly.
Next make sure the character who made the chatlog is added to the list of testers.
Open <code>src/games/stendhal/tools.test/LineAnalyser.java</code> and add your name to <code>playerNames</code>.
Open <code>src/games/stendhal/tools.test/ChatTestCreator.java</code> in the editor in Eclipse then go to the green arrow button for running an application.
Run Configurations ...
Arguments tab
Line 37 ⟶ 39:
and it will be plain with no coloured highlighting.
== Get the test to compile==
Line 43 ⟶ 45:
<source lang = "java">
public class TODO_Test extends ZonePlayerAndNPCTestImpl {
private Player player = null;
Line 50 ⟶ 52:
private String questSlot;
private static final String ZONE_NAME = "admin_test";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
QuestHelper.setUpBeforeClass();
setupZone(ZONE_NAME);
}▼
public TODO_Test() {
super(ZONE_NAME, TODO_NPC_Name);
}
@Before
public void setUp() {
final StendhalRPZone zone = new StendhalRPZone(
new TODO_NPC().configureZone(zone, null);
AbstractQuest quest = new TODO_Quest();
Line 72 ⟶ 79:
@Test
public void testQuest() {
▲ npc = SingletonRepository.getNPCList().get(TODO_Name);
</source>
===TODO_Test and TODO_Test()===
This is the class name of your test file. Which should be the class name of the quest file you are testing, plus 'Test'.
Ours is RainbowBeansTest.
=== TODO_NPC()===
Locate the maps file for the NPC in your quest (hint: search the src/games/stendhal/server/maps folder for their name) then use the class name of their maps file
Line 88 ⟶ 95:
This is the class name of the quest file you are testing. For us, that's RainbowBeans.
===
Fill in here, the name of the first NPC you spoke to for the quest. Put it in quotes
And once in the testQuest() function: SingletonRepository.getNPCList().get("Pdiddi");
===ZONE_NAME===
You can replace the default zone name "admin_test" by the zone, in which the quest actually happens. You can get this name just by looking in the display of the game client while playing the quest. Using the correct zone name is important if there is a teleport etc in the zone, which is used in the quest.
Now the errors should be gone:
<source lang = "java">
public class RainbowBeansTest extends ZonePlayerAndNPCTestImpl {
private Player player = null;
Line 101 ⟶ 112:
private String questSlot;
private static final String ZONE_NAME = "admin_test";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
QuestHelper.setUpBeforeClass();
setupZone(ZONE_NAME);
}
public RainbowBeansTest() {
super(ZONE_NAME, "Pdiddi");
}
Line 111 ⟶ 128:
final StendhalRPZone zone = new StendhalRPZone("admin_test");
new DealerNPC().configureZone(zone, null);
AbstractQuest quest = new RainbowBeans();
Line 123 ⟶ 139:
@Test
public void testQuest() {
npc = SingletonRepository.getNPCList().get("Pdiddi");
</source>
Line 201 ⟶ 216:
import utilities.PlayerTestHelper;
import utilities.QuestHelper;
import utilities.ZonePlayerAndNPCTestImpl;
public class RainbowBeansTest extends ZonePlayerAndNPCTestImpl {
private Player player = null;
private SpeakerNPC npc = null;
private Engine en = null;
private String questSlot;
private static final String ZONE_NAME = "admin_test";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
QuestHelper.setUpBeforeClass();
setupZone(ZONE_NAME);
}
public RainbowBeansTest() {
super(ZONE_NAME, "Pdiddi");
}
Line 327 ⟶ 349:
Now the variables ''en'' and ''npc'' are associated with the new NPC.
==Advanced testing: more than one dialog==
By now I'm going to assume that you are comfortable with basic tests, that you can test dialog, andthat you can modify the player by equipping him with items or setting his quest slot, if you need to.
Line 360 ⟶ 382:
</source>
and you can do other checks on the value of the quest slot, throughout.
==Advanced Testing: breaking up into several small tests==
Line 395 ⟶ 416:
at utilities.PlayerTestHelper.equipWithMoney(PlayerTestHelper.java:190)
Solution: put the stendhal project folder on your classpath for running tests - for Eclipse users see [[Stendhal on Eclipse#Running_JUnit_Tests_in_Eclipse|Running JUnit Tests in Eclipse]].
| |||