Sample Declarative Test for Hangman

HangmanGame

word

guesses

status?

apple

plae

WIN

apple

abcdefghi

LOSE

apple

abcdef

CONTINUE


Sample Procedural Test for Hangman

Test "player wins" scenario

Set a known "secret" word.

ActionFixture

start

HangmanActions

enter

setWord

apple

The game prompt should show five spaces for the five letters in the word apple. The initial game status should be "continue" (we shouldn't have won or lost at this point), and the number of incorrect guesses should start at zero.

ActionFixture

check

prompt

_ _ _ _ _

check

status

CONTINUE

check

incorrectGuesses

0

Guess a letter that isn't in the word.

ActionFixture

enter

guess

t

check

prompt

_ _ _ _ _

The prompt should not change

check

status

CONTINUE

The game should not be over

check

incorrectGuesses

1

We should have racked up one incorrect guess

Guess a letter that is in the word.

ActionFixture

enter

guess

a

check

prompt

a _ _ _ _

The prompt should show all correctly guessed letters

Guess another letter that's in the word.

ActionFixture

enter

guess

p

check

prompt

a p p _ _

The prompt should show all correctly guessed letters

Guess another letter that's in the word.

ActionFixture

enter

guess

l

check

prompt

a p p l _

The prompt should show all correctly guessed letters

check

status

CONTINUE

The game should not be over yet

Guess the final correct letter.

ActionFixture

enter

guess

e

check

prompt

a p p l e

The prompt should show all correctly guessed letters

check

status

WIN

The player should have won

ProceduralAndDeclarativeTestExamples (last edited 2009-04-30 23:15:37 by localhost)