-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Common issues
As there is a discrete number of possible outcomes, your tests should test them all. This may seem like overkill, but how else will you know that your game logic is correct in all circumstances?
Your feature test should not need to test all of the rock/paper/scissors(/lizard/spock) possibilities - this is the responsibility of your unit tests.
Although you do not need to test all possible combinations, your feature tests should test every possible outcome - i.e.:
- a win
- a loss
- and a draw. to ensure the user interface logic is correct.
Your Game
class (or similar) should not return presentation strings like "Congratulations - you won!"
. This is a presentation concern and should be handled in another layer of code. Instead, return representative codes, such as :win
and :draw
from the Game
class which can be translated by the presentation layer.
This approach makes it possible to change the presentation layer (e.g. to add support for a different language) without changing the lower-level code (open/closed principle).