SlideShare une entreprise Scribd logo
1  sur  21
1. Basico do TDD
Básico do TDD
Vantagens
• Qualidade
• Refatoração
• Compreensão
• Rastreabilidade
• Modularização
• Curva de Aprendizado
• Complexidade
• Tempo
Desvantagens
E quando há mais camadas na classe a ser
testada?
Injeção de Dependência
Mock
• É um “substituto” para um modulo
real.
• Isola o modulo a ser testado.
• Permite adicionar comportamentos
previsíveis.
Unit Test
Mock
Fake Data Generator
NBuilderFaker
Software de Biblioteca -
Frameworks
Brunogrbhg@gmail.com

Contenu connexe

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

TDD: Vantagens, Desvantagens e Técnicas Básicas

Notes de l'éditeur

  1. Contar história da minha experiência com TDD. Vou contar um pouco sobre a minha experiência com TDD. No primeiro projeto que utilizei essa técnica, eu não tinha um prazo bom, sendo apenas um mês para entregar uma solução, não tinha especificação do negócio e não dominava a técnica, conhecia vagamente o conceito, e já havia realizados testes de unidade anteriormente, mas nunca praticando o TDD. Durante o desenvolvimento, tive que ir me familiarizando com o TDD e compreendendo melhor como funcionava, me educando a utilizar e aos poucos fui conseguindo desenvolver técnicas e códigos auxiliares que me permitiam ter agilidade em desenvolver utilizando TDD. O mais interessante dessa experiência foi a forma como eu passei a compreender o modelo de negócios, que até então eu tinha dominio quase nulo. Programar utilizando TDD me fez compreender muito mais o negócio e ver aquilo do ponto de vista do usuário. Outra coisa interessante foi que eu pude ter um foco maior na arquitetura do software em si, sem me preocupar com banco de dados, de forma que até a última semana de desenvolvimento nós ainda não tinhamos banco de dados pronto, ele foi criado nessa última semana, quando o domínio da solução já estava bem modelado e as regras de negócio estavam todas implementadas.
  2. Contar história da minha experiência com TDD. Vou contar um pouco sobre a minha experiência com TDD. No primeiro projeto que utilizei essa técnica, eu não tinha um prazo bom, sendo apenas um mês para entregar uma solução, não tinha especificação do negócio e não dominava a técnica, conhecia vagamente o conceito, e já havia realizados testes de unidade anteriormente, mas nunca praticando o TDD. Durante o desenvolvimento, tive que ir me familiarizando com o TDD e compreendendo melhor como funcionava, me educando a utilizar e aos poucos fui conseguindo desenvolver técnicas e códigos auxiliares que me permitiam ter agilidade em desenvolver utilizando TDD. O mais interessante dessa experiência foi a forma como eu passei a compreender o modelo de negócios, que até então eu tinha dominio quase nulo. Programar utilizando TDD me fez compreender muito mais o negócio e ver aquilo do ponto de vista do usuário. Outra coisa interessante foi que eu pude ter um foco maior na arquitetura do software em si, sem me preocupar com banco de dados, de forma que até a última semana de desenvolvimento nós ainda não tinhamos banco de dados pronto, ele foi criado nessa última semana, quando o domínio da solução já estava bem modelado e as regras de negócio estavam todas implementadas.
  3. Como muitos já devem saber, o Test Driven Development é uma técnica que se baseia em um ciclo curto de repetições: - Criação do teste automatizado de uma nova funcionalidade, teste este que deve falhar; - Implementação minima do método a ser testado, possibilitando ao teste passer; - Por fim, refatoração do método para incluir regras de negócio mais complexas, garantindo a partir dali que aquele teste sempre irá passar.
  4. Vantagens: Maior qualidade de código e da aplicação no geral Exercita a refatoração – Te permite arriscar a escrever melhores códigos, arriscar padrões Compreensão do modelo negocial – Por incrível que pareça, você passa a compreender melhor o negócio quando pensa nas possibilidades de teste antes de desenvolver Rastreabilidade negocial – Te permite adicionar novas regras, novos métodos, novas funcionalidades, garantindo que as antigas ainda funcionam. Desvantagens: Curva de aprendizado – Se educar a usar TDD, compreender os conceitos Complexidade – Pensar mais em modularização, código mais clean Demanda mais tempo – Inicialmente você irá gastar mais tempo para desenvolver a solução, mas após compreender
  5. - Método criado sem implementação Implementação do teste para validar aquele método; o teste falha Implementação minima do método a ser testado Teste agora passa A partir daí, chegamos na Terceira etapa, que é a refatoração, onde eu poderia adicionar validações no método, garantindo que o teste sempre irá passar, e caso falhe, continuo refatorando.
  6. Vimos um exemplo muito simples e comum, mas e quando há mais camadas na classe a ser testada? Nesse ponto complica um pouco, pois dependemos de uma camada dentro do método que queremos testar para nos retornar um determinado valor. Podemos até implementar o repositório neste caso em memória, mas e quando ele for substituido pelo repositório real, como garantimos que este teste continuará funcionando?
  7. Antes de explicar a solução para o problema anterior, precisamos falar sobre injeção de dependência. Injeção de dependência tem como objetivo diminuir o acoplamento e facilitar o reuso. Consiste em você fazer uma inversão de controles; ao invés de você instanciar uma classe, você passa essa responsabilidade para um builder que fará isso por você. Dessa forma, programamos para interfaces, garantindo que uma classe não é afetada pela outra quando há modificações. É simplesmente impossível utilizar TDD sem implementar injeção de dependência no seu projeto, o que faz dele um pré requisito