Stendhal Quest Testing: Difference between revisions

Content deleted Content added
imported>Kymara
No edit summary
imported>Kymara
advanced testing
Line 308:
 
==Advanced testing: more than dialog==
 
''TODO''
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.
 
But there is more to test than just dialog. Rewards are given (xp, items) - quest slots are updated - items are removed.
 
So here are some examples. Here, we just bought some rainbow beans. So he should have them. And we'd only given the player 2000 money, so now we think he should have none.
<source lang = "java">
assertTrue(player.isEquipped("rainbow beans"));
assertFalse(player.isEquipped("money"));
</source>
You could put this after the 'Bye' from the block where we bought them.
 
What about getting xp or karma? That's not relevant to this quest but here's an example from the SadScientist test:
<source lang = "java">
// store the p and karma values before getting reward
final int xp = player.getXP();
final double karma = player.getKarma();
 
en.step(player, "hi");
assertEquals("Here are the black legs. Now I beg you to wear them. The symbol of my pain is done. Fare thee well.", getReply(npc));
// [23:05] kymara earns 10000 experience points.
assertThat(player.getXP(), greaterThan(xp));
assertThat(player.getKarma(), greaterThan(karma));
</source>
 
The final two asserts just check that the xp and the karma did increase (though they don't check the amount)
 
After a quest was completed the quest slot should be "done" normally. So we might check
<source lang = "java">
assertTrue(questSlot.equals("done"));
</source>
and you can do other checks on the value of the quest slot, throughout.
== Trouble shooting ==
===ChatTestCreator===