Top Banner
22

Unit Tests (Sérgio Igarashi)

Mar 20, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit Tests (Sérgio Igarashi)
Page 2: Unit Tests (Sérgio Igarashi)

Unit tests Sérgio Igarashi

Page 3: Unit Tests (Sérgio Igarashi)

It should be done

"Unit testing is a tool, just like any other tool. Its purpose is to make us better at our jobs, which is to produce robust, maintainable software." THOMPSON, Matt, 2013.

Page 4: Unit Tests (Sérgio Igarashi)

Agenda

● Sobre seu projeto

● Testar: Por que, O que, Como, ???

● Quick & Nimble

● Tips

● Referências

Page 5: Unit Tests (Sérgio Igarashi)

Sobre...seu projeto

"Ah, a gente precisava entregar o app, ai acabou despriorizando os testes."

Page 6: Unit Tests (Sérgio Igarashi)

Sobre

1. Quem faz ?

2. Quanto é a cobertura mínima ?

3. Quebra build ?

4. Quem não concorda ou tem alguma oposição ?

5. Quem não entende ?

Page 7: Unit Tests (Sérgio Igarashi)

Intro

"Então...é que o problema é que eu não sei o que testar. "

Page 8: Unit Tests (Sérgio Igarashi)

FAQ: Testar

1. Por quê ?

2. O quê ?

3. Como ?

Page 9: Unit Tests (Sérgio Igarashi)

Você sabia ?

Page 10: Unit Tests (Sérgio Igarashi)

Por quê Testar ?

● Integridade;

● Policiamento;

● Manutenibilidade;

● Documentação;

Page 11: Unit Tests (Sérgio Igarashi)

O quê Testar ?

"You should test every line of code that you write." LISLE, Ron. 2013

Page 12: Unit Tests (Sérgio Igarashi)

Como testar ?

● Abstraia dependências externas ao seu código;

● Pense em asserções;

● Especifique o que você está testando dentro do contexto;

● REFATORE;

Page 13: Unit Tests (Sérgio Igarashi)

Quick & Nimble

"Programmers wanted to know where to start, what to test, and what not to test, how much to test in one go, what to call their tests and how to understand why a test fails." NORTH, Dan, 2016.

Page 14: Unit Tests (Sérgio Igarashi)

Quick

● Framework BDD;

● Provê agrupamentos de contexto;

● Apoia na escrita "clara" de testes;

● Dev-friendly para testes assíncronos;

Page 15: Unit Tests (Sérgio Igarashi)

Nimble

● Expressa expectativas de forma clara e verbosa ;

● Descreve mensagens de erro para falhas;

● Customiza asserções;

● Expectativas assíncronas;

Page 16: Unit Tests (Sérgio Igarashi)

Tips

Saindo do piloto automático.

Page 17: Unit Tests (Sérgio Igarashi)

Pensando em testes

● Cenários

● Casos

● Ações

Page 18: Unit Tests (Sérgio Igarashi)

Relatório de Cobertura

100%

…será ?

Page 19: Unit Tests (Sérgio Igarashi)

E esse bug aqui nessa classe 100% testada ?

Ora Ora...parece que temos um Xeroque Rolmes aqui.

Page 20: Unit Tests (Sérgio Igarashi)

Referências

Era tudo mentira...

Page 22: Unit Tests (Sérgio Igarashi)

www.concretesolutions.com.br

Ajudamos empresas a criar produtos digitais de sucesso

Belo Horizonte - Av. Getúlio Vargas, 671 8º andar, sala 800 - Savassi - (31) 3360-8900

Rio de Janeiro - Rua São José, 90 - cj. 2121Centro - (21) 2240-2030

São Paulo - Av. Nações Unidas, 11.5413º andar - Brooklin - (11) 4119-0449

Sergio Igarashi

[email protected]