Stendhal Quest Testing: Difference between revisions

From Arianne
Jump to navigation Jump to search
imported>Kymara
No edit summary
imported>Kymara
No edit summary
(No difference)

Revision as of 20:03, 26 November 2010



Stendhal Quests

Generate a chat log

We need chat logs of players doing each Stendhal Quest so that we can create tests for them. So, it's easy to help us because all you need to do, is do the quest and then save the chat log for us. There are some ways you can help us make the best possible test:

  • don't say yes to everything immediately. try saying no and then come back and say yes
  • try to fool the npc. if he asked you for an item, say you had it when you didn't really! or if you were supposed to kill something, say yes you did, before you really did.
  • if it's repeatable, try to come back and do it too early, and then again later
  • 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 hudson - quests which are all or mostly green are done, and quests which are all or mostly red need a chatlog provided.

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

 Run Configurations ... 
 Arguments tab
 Program arguments: gamechat.log
 Click Run

If all is well you should get some text output into your Console starting with

package games.stendhal.server.maps.quests;

import static org.junit.Assert.assertEquals;
import games.stendhal.server.core.engine.SingletonRepository;

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

java games.stendhal.tools.test.ChatTestCreator chatlog.txt [chatlogtest.java]
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at games.stendhal.tools.test.ChatTestCreator.main(ChatTestCreator.java:75)
  • You didn't put gamechat.log into the Program arguments.
Exception in thread "main" java.io.FileNotFoundException: gamechat.log (No such file or directory) 
  • You didn't copy gamechat.log into the project folder for your eclipse workspace.