We are creating a rock-paper-scissors game, to do so, we create the rules of the game
Business needs / User story
As a player
I want the rock to beat scissors
Solution
Given I have chosen rock
When the opponent chooses scissors
Then I should win
Given I have chosen scissors
When the opponent chooses rock
Then the opponent win
Business needs / User story
As a player
I want the paper to beat rock
Solution
Given I have chosen paper
When the opponent chooses rock
Then I should win
Given I have chosen rock
When the opponent chooses paper
Then the opponent should win
Business needs / User story
As a player
I want scissors to beat paper
Solution
Given I have chosen scissors
When the opponent chooses paper
Then I should win
Given I have chosen paper
When the opponent chooses scissors
Then the opponent should win
Business need / User story
As a player
I want the same moves to draw
Solution
Given I have chosen rock
When the opponent chooses rock
Then it should be a draw
Given I have chosen scissors
When the opponent chooses scissors
Then it should be a draw
Given I have chosen paper
When the opponent chooses paper
Then it should be a draw
public class RockPaperScissors {
public String rockPaperSissors(String movePlayer1, String movePlayer2) {}
}
public class RockPaperScissors {
public GameStatus rockPaperSissors(Moves movePlayer1, Moves movePlayer2) {}
}
Configuración básica para empezar a hacer una kata o aprender a hacer tests en los siguientes lenguajes:
- PHP y PHPUnit
- Javascript con Jest
- Typescript con Deno
- Java, Junit y Mockito
- Scala, Munit y Scalacheck
- Kotlin, JUnit5 y MockK
- C#, xUnit (con FluentAsertion) y NSubstitute (para mock)
- Instalar composer
curl -sS https://getcomposer.org/installer | php
composer install
(estando en la carpeta php)./vendor/bin/phpunit
- Instalar Node
npm install
(Estando en la carpeta javascript)npm test
- Instalar Deno
deno test
(Estando en la carpeta typescript)
- Instalar las dependencias y tests con Maven [mvn test]
- Ejecutar los tests con el IDE
sbt
(en la carpeta scala)~test
para ejecutar los test en hot reload
- Instalar SDKMan
sdk install java 11.0.12-open
instala OpenJDKsdk install sbt
una vez instalado SDKMan
- Descargar Visual Studio Code
- Instalar para VS Code Metals
- Por consola: Puedes instalar dependencias y lanzar los tests con
gradlew test
- Usando IDE: Simplemente abre el proyecto desde el raiz de la plantilla Kotlin
- Instalar Microsoft Visual Studio Community 2022
- Abre el proyecto y se descargaran automáticamente los paquetes Nuguet necesarios
- Instalar python 3.x
- Una vez descargado el código fuente dentro de la carpeta */python/ creamos un virtual enviroment:
python3 -m venv env
- Activamos en virtual environment:
- windows:
.\env\Scripts\activate.bat
- linux/mac:
source env/bin/activate
pytest
para ejecutar los tests.
Prophecy para dobles de prueba
Scalacheck para testing basado en propiedades