51
TEST DRIVEN DEVELOPMENT Hercules Lemke Merscher - @hlmerscher

Test Driven Development

Embed Size (px)

Citation preview

Page 1: Test Driven Development

TEST DRIVEN DEVELOPMENT

Hercules Lemke Merscher - @hlmerscher

Page 2: Test Driven Development

O que é?

http://i-love-my-life.com/wp-content/uploads/2011/03/doubt.jpg

Page 3: Test Driven Development

TÉCNICA

https://media.licdn.com/mpr/mpr/shrinknp_800_800/AAEAAQAAAAAAAASQAAAAJDllYzc1ZjgxLTliNDQtNGU2MS1hNDg0LTFiOWZlNTQ4N2Q5ZA.png

Page 4: Test Driven Development

TDD E TESTE AUTOMATIZADO. SINÔNIMOS?

https://images.rapgenius.com/e7c0c514d4e7564079c2e6b0c8d547b5.540x350x1.jpg

Page 5: Test Driven Development

POR QUÊ?

https://imgflip.com/s/meme/Question-Rage-Face.jpg

Page 6: Test Driven Development

ERROS RECORRENTES

https://upload.wikimedia.org/wikipedia/commons/3/3b/Windows_9X_BSOD.png

Page 7: Test Driven Development

O COMPUTADOR É MAIS RÁPIDO

http://www.seuseriado.com/wp-content/uploads/2016/04/The-Flash-2ª-Temporada.jpg

Page 8: Test Driven Development

O COMPUTADOR NÃO CANSA

http://2.bp.blogspot.com/-mF5paUPo6tQ/UkeaGETMkWI/AAAAAAAAAYA/L6AnHHKP8uc/s1600/52636309+(1).png

Page 9: Test Driven Development

LEI DE MURPHY

http://shedka.com/wp-content/uploads/2015/06/tostada-1000x666.jpg

Page 10: Test Driven Development

BUG’S EM PRODUÇÃOhttp://www.dan-dare.org/FreeFun/Images/CartoonsMoviesTV/BugsLifeWallpaper800.jpg

Page 11: Test Driven Development

MEDO DE TOCAR NO CÓDIGO

https://councillorpadraigmcshane.files.wordpress.com/2012/11/scooby-and-shaggy-afraid-scooby-doo-2992126-852-480.jpg

Page 12: Test Driven Development

CORREÇÕES QUE GERAM MAIS BUG’S

http://web.pdx.edu/~cem3/looney/img/coyoterocket.png

Page 13: Test Driven Development

http://iblasquez.github.io/presentation_TDD_CodingDojo/TDD_Mantra.png

Page 14: Test Driven Development

VERMELHO

http://static.maciverinstitute.com/F%20Letter%20Grade-cropped-proto-custom_4-thumb-618xauto-7419.jpg

Page 15: Test Driven Development

VERDE

https://www.exceptionnotfound.net/content/images/2015/04/the-coder.jpg

Page 16: Test Driven Development

REFATORA

http://cdn.hitfix.com/photos/6214402/HannibalLecterSOTL.jpg

Page 17: Test Driven Development

E A PARTE DO CÓDIGO, JÁ CHEGOU?

https://i.ytimg.com/vi/ovm2zkuqJD8/maxresdefault.jpg

Page 18: Test Driven Development

PRIMEEEIIIIROOOO...

ESCREVA O TESTE

http://2.bp.blogspot.com/-S8U-dF2WTzk/UlLk0q5jy4I/AAAAAAAAC4M/OFlBxMqwCYA/s1600/mask.jpg

Page 19: Test Driven Development

TESTE

test('Product instantiates a new product', (t) => {

let product = new Product();

t.ok(product instanceof Product);

t.end();

});

Page 20: Test Driven Development

TESTE FALHA

ReferenceError: Product is not defined

Page 21: Test Driven Development

CÓDIGO

function Product() {

}

Page 22: Test Driven Development

TESTE PASSA# Product instantiates a new productok 1 should be truthy

1..1# tests 1# pass 1

# ok

Page 23: Test Driven Development

BABY STEPS

http://www.clipartkid.com/images/300/download-baby-steps-clipart-LA7TaY-clipart.jpg

Page 24: Test Driven Development

TESTEtest('Product#price zero by default', (t) => {

let product = new Product();

t.equal(product.price, 0);

t.end();

});

Page 25: Test Driven Development

TESTE FALHA# Product#price zero by default

not ok 2 should be equal

---

operator: equal

expected: 0

actual: undefined

Page 26: Test Driven Development

CÓDIGO

function Product() {

this.price = 0;

}

Page 27: Test Driven Development

TESTE PASSA# Product#price zero by default

ok 2 should be equal

1..2

# tests 2

# pass 2

# ok

Page 28: Test Driven Development

TESTEtest('Product#quantity zero by default', (t) => {

let product = new Product();

t.equal(product.quantity, 0);

t.end();

});

Page 29: Test Driven Development

TESTE FALHA# Product#quantity zero by default

not ok 3 should be equal

---

operator: equal

expected: 0

actual: undefined

Page 30: Test Driven Development

CÓDIGO

function Product() {

this.price = 0;

this.quantity = 0;

}

Page 31: Test Driven Development

TESTE PASSA# Product#quantity zero by default

ok 3 should be equal

1..3

# tests 3

# pass 3

# ok

Page 32: Test Driven Development

TESTEtest('Product#total calculates amount', (t) => {

let product = Object.assign(

new Product(), { price: 10, quantity: 2 });

t.equal(product.total(), 20);

t.end();

});

Page 33: Test Driven Development

TESTE FALHA

t.equal(product.total(), 20);

^

TypeError: product.total is not a function

Page 34: Test Driven Development

CÓDIGO

function Product() {

this.price = 0;

this.quantity = 0;

this.total = () => this.price * this.quantity;

}

Page 35: Test Driven Development

TESTE PASSA# Product#total calculates amount

ok 4 should be equal

1..4

# tests 4

# pass 4

# ok

Page 36: Test Driven Development

COM TDD EU AGARANTCHÍU !!!https://img.buzzfeed.com/buzzfeed-static/static/2015-03/3/10/enhanced/webdr14/enhanced-buzz-29154-1425395469-14.jpg

Page 37: Test Driven Development

TDD É SOBRE FEEDBACK

http://www.sacadasdecarreira.com.br/files/2015/12/design-feedback-tips.png

Page 38: Test Driven Development

TESTE UNITÁRIO

http://unity-coding.slashgames.org/wp-content/uploads/unit-test.jpg

Page 39: Test Driven Development

TESTE DE REGRESSÃO

https://d.ibtimes.co.uk/en/full/1396036/delorean.jpg

Page 40: Test Driven Development

TESTE DE INTEGRAÇÃO

http://mlb-s1-p.mlstatic.com/15139-MLB20096270752_052014-O.jpg

Page 41: Test Driven Development

TESTE DE ACEITAÇÃO

http://aaronacceptance.ca/wp-content/uploads/2015/07/Loan-Approval_Aaron_Acceptance_256.png

Page 42: Test Driven Development

MOCKS, STUBS E FAKES

http://goias24horas.com.br/wp-content/uploads/2013/08/marionete.jpg

Page 43: Test Driven Development

CÓDIGO DIFÍCIL DE TESTAR

É UM MAU SINAL?

Page 44: Test Driven Development

QUANTAS ASSERTIVAS POR TESTE?

Page 45: Test Driven Development

DEVO USAR PASSOS DE BEBÊ

SEMPRE?

Page 46: Test Driven Development

PRECISO DA APROVAÇÃO DO MEU CHEFE PARA

ESCREVER TESTES?

http://cdn.business2community.com/wp-content/uploads/2016/01/Godfather-300x169-3.png-3.png

Page 47: Test Driven Development

COBERTURA

Page 48: Test Driven Development

COBERTURA

https://github.com/hlmerscher/dojo-onde

Page 49: Test Driven Development

http://www.maonamassasalgadosecia.com.br/uploads/widget/image/512/170/51217096/mao-na-massa.png

Page 50: Test Driven Development

REFERÊNCIAS

Page 51: Test Driven Development

OBRIGADO!www.herculesdev.com.br