Stendhal Quest Testing: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Kymara
No edit summary
imported>Kymara
No edit summary
Line 15: Line 15:


== Run ChatTestCreator ==
== Run ChatTestCreator ==
Once you have the chatlog you can use games.stendhal.tools.test.ChatTestCreator 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]] - rename it if you want to follow the tutorial.
Once you have the chatlog you can use games.stendhal.tools.test.ChatTestCreator 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.


Open src/games/stendhal/tools.test/ChatTestCreator.java in the editor in Eclipse then go to the green arrow button for running an application.
Open src/games/stendhal/tools.test/ChatTestCreator.java in the editor in Eclipse then go to the green arrow button for running an application.
Line 33: Line 33:
and it will be plain with no coloured highlighting.
and it will be plain with no coloured highlighting.


Cope and paste all that text into a new file which you should save in tests/games/stendhal/server/maps/quests/. Call it the same name as the class file for your Quest, with 'Test' at the end. We are testing RainbowBeans.java, so we name the file, RainbowBeansTest.java.

Now there will be some red underlined errors in the file, for each part which is TODO. Don't worry about that!

<source lang = "java">
public class TODO_Test {

private Player player = null;
private SpeakerNPC npc = null;
private Engine en = null;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
QuestHelper.setUpBeforeClass();
}

@Before
public void setUp() {
final StendhalRPZone zone = new StendhalRPZone("admin_test");
new TODO_NPC().configureZone(zone, null);

AbstractQuest quest = new TODO_Quest();
quest.addToWorld();

player = PlayerTestHelper.createPlayer("bob");
}

@Test
public void testQuest() {
npc = SingletonRepository.getNPCList().get(TODO_Name);
</source>

===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

We searched Pdiddi and found he is defined in src/games/stendhal/server/maps/semos/pad/DealerNPC.java - so we replaces TODO_NPC() with DealerNPC() and added the import needed.

If you have more than one NPC active in this quest you need to add them! Just copy and paste the line and repeat for each NPC.
===TODO_Quest===
This is the class name of the quest file you are testing. For us, that's RainbowBeans.

===TODO_Name===
Fill in here, the name of the first NPC you spoke to for the quest. Put it in quotes : SingletonRepository.getNPCList().get("Pdiddi");

Now the errors should be gone:

<source lang = "java">
public class RainbowBeansTest {

private Player player = null;
private SpeakerNPC npc = null;
private Engine en = null;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
QuestHelper.setUpBeforeClass();
}

@Before
public void setUp() {
final StendhalRPZone zone = new StendhalRPZone("admin_test");
new DealerNPC().configureZone(zone, null);

AbstractQuest quest = new RainbowBeans();
quest.addToWorld();

player = PlayerTestHelper.createPlayer("bob");
}

@Test
public void testQuest() {
npc = SingletonRepository.getNPCList().get("Pdiddi");
</source>


== Trouble shooting ==
== Trouble shooting ==