Download Test Driven .NET Development with FitNesse

Transcript
Chapter 5.
Writing simple test scripts
Tests are rarely as simple as the one described in Chapter 4, Writing basic
tests. Generally, they involve several steps and verifications. FitNesse
allows us to write multi-step test scripts as easily as simple verifications.
In this chapter we develop the next story, and learn how to write test
scripts and pass values between tables. Our task for this chapter is to
implement the second user story:
Register player
As an operator, I want players to register and open accounts before
purchasing tickets, so that I have their details for marketing
purposes and to prevent fraud.
Again, we speak to our business analysts about what to test and how to
verify that the story has been implemented correctly. The first thing they
say is that, upon successful registration, personal details should be stored
correctly in the system and the player should be able to log in with their
registered username and password. Also, the balance for new accounts
in the system should always be zero.
Focus on fixture code
To keep things simple, we will focus on test fixtures and testspecific code in this and the following chapters. Business
classes will be discussed just enough to support the story. You
can see the implementations of these classes in Appendix D,
Source code. You can also download them from
http://gojko.net/fitnesse.
To implement the story, we need to allow players to register and log in.
Each player will have a unique numeric ID, which should be returned
from the registration method (let's call it RegisterPlayer) if the operation
is successful. Let's create a data-transfer interface where we will store all
the personal details of the player required for the registration — we will
53