An introductory dynamics to Test Driven Development (TDD)An introductory dynamics to Test Driven Development (TDD)

Overview

tdd-demo

Nesse hands-on teremos uma dinâmica introdutória a Test Driven Development (TDD), ou desenvolvimento orientado por testes.

instruções

1 - Clonar esse projeto

2 - abrir na sua IDE de preferência (recomenda-se o intellij community editiion)

3 - executar o teste presente na classe Quadratic, na raiz do módulo tests. Esse teste deve passar.

Se você conseguiu executar com sucesso o teste, seu ambiente está pronto para a aula.

sobre Kotlin

Iremos utilizar Kotlin, uma linguagem multi-paradigma, inter-operável com Java, mas que possibilita construção de códigos mais idiomáticos e com menos escrita de boiler plate.

Para uma rápida introdução a kotlin, acesse o seguinte tutorial: https://play.kotlinlang.org/byExample/01_introduction

Para efeitos dessa aula, o conteúdo da introdução deve ser suficiente, principalmente para quem já conhece Java.

A maior parte do código que iremos escrever é bem parecida com Java.

Funções

Funções mais simples, que podem ser definidas em 1 linha, podem ser feitas nesse formato

fun sum(a: Integer, val b: Integer) = a + b

Ou você pode adotar um estilo mais parecido com java

fun sum(a: Integer, val b: Integer) : Integer { return a + b }

Operações com BigDecimals

Soma

val result = BigDecimal(10).plus(BigDecimal(5)) // 15

Subtração

val result = BigDecimal(10).minus(BigDecimal(5)) // 5

Multiplicação

val result = BigDecimal(2).multiply(BigDecimal(4)) // 8

Divisão

val result = BigDecimal(8).divide(BigDecimal(2)) // 4

Raiz quadrada

val result = BigDecimal(16).sqrt(MathContext(10)) // 4

Potência

val result = BigDecimal(3).number.pow(2) // 9

Esse resuminho tem 90% do kotlin que precisará ser escrito nessa aula!

A Dinâmica

Iremos juntos explocar como usar TDD de acordo com 2 técnicas: Abordagem Londres e Detroit.

Para isso iremos utilizar um caso clássico de matemática fundamental: Equações completas de segundo grau. Iremos codificar a fórmula de Bhaskara utilizando ambas abordagens.

lista de raízes para equações completas de segundo grau

Para uso na aula. Não se preocupe com isso antes ;)

Duas raízez (Delta > 0)

a = 1

b = -1

c = -12

Resultado esperado = [4,-3]

a = 1

b = -5

c = 6

Resultado esperado = [3,2]

Uma raíz (Delta = 0)

a = 4

b = -4

c= 1

Resultado esperado = [0.5]

Nenhuma raiz real (Delta < 0)

a = 1

b = -4

c = 5

Resultado esperado = []

You might also like...
Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

A project that takes advantage of docker and makes the load test easier

Performance Test It's a project that takes advantage of docker and makes the load test easier. Also, it collects metrics from each running container.

kafka test with embedded kafka

kafka-test Requirements running Kafka on localhost:9092 How to use cat sampleuser.json | http POST localhost:9000/produce or use runConfiguration ./.r

🌱 A test implementation of a Minecraft server using RESTful API taking advantage of the interoperability between Kotlin and Java.

🌱 Norin A test implementation of a Minecraft server using RESTful API taking advantage of the interoperability between Kotlin and Java. This project

TestContainer & Spring Test sample repo

SpringBoot Integration-Test sample 🐳 Kotlin(1.6.10) + Spring Boot 2.6.2 + Testcontainers(PostgreSQL) + MyBatis + DbUnit + Spring Security + JWT auth

Test Case Implementation From Nutrition-Framework
Test Case Implementation From Nutrition-Framework

Android Architecture Blueprints v2 Android Architecture Blueprints is a project to showcase different architectural approaches to developing Android a

Test Case Implementation From Nutrition-Framework
Test Case Implementation From Nutrition-Framework

About This Project (work-in-progress 👷 🔧️ 👷‍♀️ ⛏ ) Test Case Implementation Dari Nutrition Framework Version Release This Is Latest Release ~ Beta

Test tv - A marketing company needs a simple pluggable application with a RESTful interface

Demo project A marketing company needs a simple pluggable application with a RES

Nech9ev - Tinkoff Fintech test app
Nech9ev - Tinkoff Fintech test app

Тестовое задание в Тинькофф Финтех Скриншоты Latest category Top category Прилож

Owner
Plataforma Impact
Plataforma Impact
This repository contains event driven redis app uses redis streams

Spring Boot Redis Streams This repository contains event driven redis app uses redis streams Run redis in docker docker run --rm --name redis -itp6379

Maksim Kostromin 1 Dec 1, 2021
Event-driven application uses React, reactive Spring Boot WebFlux, R2DBC, MySQL and Liquibase

Product delivery Event-driven application uses React, reactive Spring Boot WebFlux, R2DBC, MySQL and Liquibase Status: IN PROGRESS if [[ "" != `docker

Maksim Kostromin 2 Aug 17, 2022
Gha-central-test - GitHub Actions Maven Central Test

GitHub Actions Maven Central Test Pushing a tag does a release. Local Maven Depl

James Ward 1 Jan 19, 2022
A project that helps us generate the test project to test the Gradle plugin.

Ktlint Gradle Provides the function to generate a Gradle project for us to test your Gradle plugin Latest plugin version: [1.0.0] Table of content How

Jack Chen 5 Jul 20, 2022
Sample demonstrates use of Flow, StateFlow & how we can test Flow

FlowSample This sample demonstrates use of Flow, StateFlow & how we can test Flow. In Kotlin, Coroutine is just the scheduler part of RxJava but now w

null 0 Oct 24, 2021
API for a library using Kotlin, Spring-boot and covered by test

Library API This API is to create Books and be able to borrow from them I'm using: Spring Boot version 2.5.6 Kotlin 1.5.31 Java 11 I'm implementing us

Daniel Queiroz 1 Nov 5, 2021
A funny project to help you test your BNF syntax

Readme The idea of this project is to implement a BNF expression compiler. We could use BNF to design some syntax like Arithmetic expression. <factor>

Jack Chen 4 Dec 21, 2022
Test task from AppSelect company

Test task from AppSelect company

Chapaev Anton 0 Nov 22, 2021
Simple App made for a test to Studio Sol Company

Studio Sol Test - Guess the Number Simple App made for a test to Studio Sol Company. #What you'll see in this project: ViewBinding Navigation Animatio

Philippe Muniz 1 Nov 19, 2021
Interview test for Kyosk interview

Kyosk-Android-Test A project done for the submission of my Kyosk interview application. Table Of Content. Project Structure - Domain - Data - Presenta

Kagiri Charles 6 Dec 4, 2021