SlideShare une entreprise Scribd logo
1  sur  53
Integração Contínua Terra Ágil Nov/2010
IC Integração Contínua “Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly.” http://www.martinfowler.com/articles/continuousIntegration.html
IC IC @ Atlas :  Testes: Unidade/Funcionais (Integração)
IC Bottom Up!  Injeção de Dependência Mocks TDD Integracao Continua / Hudson Conclusão
IC Dependency Injection Design Pattern Reduzir acoplamento Vários tipos (constructor injection, setter injection, interface injection)
IC Dependency Injection class HardcodedWorkflow { 	public void execute() 	{ 	// do LOTS of workflow stuff 		... 		FileSenderService service =  new FileSenderService(fileName, "This is a message");  		service.send(); 		// do LOTS more workflow stuff 		... } }
IC Dependency Injection class FileSenderService implements ISenderService { 	private String message; 	private File file; 	public FileSenderService(String fileName, String message) 	{ 		this.parameter = message; 		this.file = File.open(fileName); 	} 	public void send() 	{ 		file.write(message); 	} }
IC Dependency Injection class EmailSenderService implements ISenderService { 	... 	public void send() 	{ 		smtpLib.send(emailAddress, message); 	} }
IC É só um “IF”
IC É só um “IF”
IC Dependency Injection class HardcodedWorkflow { 	public void execute(int delivery) 	{ 	// do LOTS of workflow stuff ... ISenderService service; if(delivery == MsgDelivery.FILE) { 			service = new FileSenderService("This is a message"); } else if(delivery == MsgDelivery.EMAIL) { 			service = new EmailSenderService("This is a slightly different message"); }  service.send(); // do LOTS more workflow stuff ... 	} }
IC 2 meses depois ...
IC Dependency Injection 	... if(delivery == MsgDelivery.FILE) { 		service = new FileSenderService("This is a message");  	} else if(delivery == MsgDelivery.EMAIL) { 		service = new EmailSenderService(userAddress, "This is a slightly different message""); 	} else if(delivery == MsgDelivery.ADMINISTRATOR_EMAIL) { 		service = new EmailSenderService(adminAddress, "SUDO this is a message!!!"); 	} else if(delivery == MsgDelivery.ABU_DHABI_BY_AIR_MAIL) { 		service = new AbuDhabiAirMailSenderService("Hello, Mama"); 	} else if(delivery == MsgDelivery.DEVNULL) { 		service = new DevNullSenderService("Hello, is anybody in there??!?!"); // why do I care?!?! 	} ...
IC 2 Anos depois ...
IC
IC Dependency Injection To The Rescue!!! class FlexibleWorkflow { 	private ISenderService service; 	public FlexibleWorkflow(ISenderService service) // << "LOOSE COUPLING" 	{ 		this.service = service; 	} 	public void execute() 	{ 		// do LOTS of workflow stuff 		... this.service.send(); 		// do LOTS more workflow stuff 		... 	} }
IC Dependency Injection To The Rescue!!! class FileWorkflowController { 	public void handleRequest() 	{ 		ISenderService service =  			new FileSenderService("This is a message."); // << "TIGHT COUPLING!!!" 		FlexibleWorkflow workflow =  			new FlexibleWorkflow(service); 		workflow.execute(); 	} }
IC Dependency Injection To The Rescue!!! class EmailWorkflowController { 	public void handleRequest() 	{ 		ISenderService service =  			new EmailSenderService(getUserEmail(), "This is a slightly different message."); 		FlexibleWorkflow workflow =  			new FlexibleWorkflow(service); 		workflow.execute(); 	} }
IC Dependency Injection Ok, legal, mas o quê isso tem a ver com o pastel?!?!
IC Testes com Mocks!!! class FlexibleWorkflowTest extends TestCase { 	// millions of other tests 	... 	public void testMessageSend() 	{ 		ISenderService mockService =  			new MockSenderService(); 		FlexibleWorkflow workflow =  			new FlexibleWorkflow(mockService); 		workflow.execute(); 		assertTrue(workflow.getResult(), true); mockService.assertCalled("send"); 		// millions of other assertions 		... 	} }
IC Mock Objects Mocks aren’t Stubs! http://martinfowler.com/articles/mocksArentStubs.html
IC Stubs 	ISenderService stubService =  new StubService(); 	FlexibleWorkflow workflow = new FlexibleWorkflow(stubService); 	workflow.execute(); // nada mais a fazer, o stub nao provê nenhuma informacao
IC Stubs
IC Mock Objects Estilo diferente de testes
IC Mock Objects Inspecionar comportamento class FlexibleWorkflowTestextends TestCase { 	public void testMessageSend() 	{ 		ISenderService mockService =  			new MockSenderService(); 		FlexibleWorkflow workflow =  			new FlexibleWorkflow(mockService); 		workflow.execute(); 		assertTrue(workflow.getResult(), true); mockService.assertCalled("send"); 		// millions of other assertions 		... 	} }
IC Mock Objects Simulando condições de erro public void testMessageSendError() { 	ISenderService mockService =  		new MockSenderService(); 	// mock lanca "SmtpTimeoutException" quando 	// metodo "send" e chamado 	mockService.setSideEffect("send",  		new SideEffect() {  void run () { throw new SmtpTimeoutException();} }); 	FlexibleWorkflow workflow =  		new FlexibleWorkflow(mockService); 	try { 		workflow.execute(); 	} catch(Exception e) { 		assertFail(); } } interface SideEffect { 	void run(); }
IC Mock Objects Mocks sao agentes do codigo de teste
IC TDD “You have probably heard a few talks or read a few articles where test driven development is depicted as a magic unicorn that watches over your software and makes everybody happy.”
IC TDD “ Well, about 18.000 lines of ‘magic unicorn’ code later, I'd like to put things into perspective.”
IC TDD “The truth is, test driven development is a huge pain in the ass.”
IC TDD “But do you know what sucks more? The liability that comes without those tests.” http://debuggable.com/posts/test-driven-development-at-transloadit:4cc892a7-b9fc-4d65-bb0c-1b27cbdd56cb
IC TDD Ok, “Test First” ... ... mas por onde eu começo?!?!
IC TDD Ok, “Test First” ... ... mas por onde eu começo?!?!
IC TDD Implementar mínimo necessário para o teste FALHAR.
IC TDD Implementar mínimo necessário para o teste FALHAR. class Math { 	public int sum(int a, int b)  	{ thrownew NotImplementedException(); 	} } class MathTest extends TestCase { 	public void testSum() 	{ Math m = new Math(); 		assertEquals(m.sum(1,2), 3); 	} }
IC TDD Vantagens
IC TDD Vantagens Código é testável “por natureza”.
IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências.
IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências. Cobertura de Código.
IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências. Cobertura de Código. Design gera interfaces (de código) mais “amigáveis”.
IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências. Cobertura de Código. Design gera interfaces (de código) mais “amigáveis”. TDD não tem “ciúminho”.
IC TDD Desvantagens
IC TDD Desvantagens Na 1a. vez, prepare-se para errar.
IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito.
IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda!
IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda! Nada é de graça (No Unicorns)
IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda! Nada é de graça (No Unicorns) Código legado
IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda! Nada é de graça (No Unicorns) Código legado É um “pé no saco”
IC Build “On-Commit” Build Noturno Testes Artefatos Radiadores De Informação
IC Hudson e o “Gremlin”
IC Hudson e o “Gremlin” Dificuldades Makefiles Ambiente
Conclusão There’s no Free Lunch ... ... and no Silver Bullet! Baby Steps! Purismo não leva a lugar nenhum Ferramentas adequadas
Hudson Q&A diego.pereira@corp.terra.com.br

Contenu connexe

Dernier

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
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
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
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...
 

Terra Ágil - Integração Contínua

  • 2. IC Integração Contínua “Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly.” http://www.martinfowler.com/articles/continuousIntegration.html
  • 3. IC IC @ Atlas : Testes: Unidade/Funcionais (Integração)
  • 4. IC Bottom Up! Injeção de Dependência Mocks TDD Integracao Continua / Hudson Conclusão
  • 5. IC Dependency Injection Design Pattern Reduzir acoplamento Vários tipos (constructor injection, setter injection, interface injection)
  • 6. IC Dependency Injection class HardcodedWorkflow { public void execute() { // do LOTS of workflow stuff ... FileSenderService service = new FileSenderService(fileName, "This is a message"); service.send(); // do LOTS more workflow stuff ... } }
  • 7. IC Dependency Injection class FileSenderService implements ISenderService { private String message; private File file; public FileSenderService(String fileName, String message) { this.parameter = message; this.file = File.open(fileName); } public void send() { file.write(message); } }
  • 8. IC Dependency Injection class EmailSenderService implements ISenderService { ... public void send() { smtpLib.send(emailAddress, message); } }
  • 9. IC É só um “IF”
  • 10. IC É só um “IF”
  • 11. IC Dependency Injection class HardcodedWorkflow { public void execute(int delivery) { // do LOTS of workflow stuff ... ISenderService service; if(delivery == MsgDelivery.FILE) { service = new FileSenderService("This is a message"); } else if(delivery == MsgDelivery.EMAIL) { service = new EmailSenderService("This is a slightly different message"); } service.send(); // do LOTS more workflow stuff ... } }
  • 12. IC 2 meses depois ...
  • 13. IC Dependency Injection ... if(delivery == MsgDelivery.FILE) { service = new FileSenderService("This is a message"); } else if(delivery == MsgDelivery.EMAIL) { service = new EmailSenderService(userAddress, "This is a slightly different message""); } else if(delivery == MsgDelivery.ADMINISTRATOR_EMAIL) { service = new EmailSenderService(adminAddress, "SUDO this is a message!!!"); } else if(delivery == MsgDelivery.ABU_DHABI_BY_AIR_MAIL) { service = new AbuDhabiAirMailSenderService("Hello, Mama"); } else if(delivery == MsgDelivery.DEVNULL) { service = new DevNullSenderService("Hello, is anybody in there??!?!"); // why do I care?!?! } ...
  • 14. IC 2 Anos depois ...
  • 15. IC
  • 16. IC Dependency Injection To The Rescue!!! class FlexibleWorkflow { private ISenderService service; public FlexibleWorkflow(ISenderService service) // << "LOOSE COUPLING" { this.service = service; } public void execute() { // do LOTS of workflow stuff ... this.service.send(); // do LOTS more workflow stuff ... } }
  • 17. IC Dependency Injection To The Rescue!!! class FileWorkflowController { public void handleRequest() { ISenderService service = new FileSenderService("This is a message."); // << "TIGHT COUPLING!!!" FlexibleWorkflow workflow = new FlexibleWorkflow(service); workflow.execute(); } }
  • 18. IC Dependency Injection To The Rescue!!! class EmailWorkflowController { public void handleRequest() { ISenderService service = new EmailSenderService(getUserEmail(), "This is a slightly different message."); FlexibleWorkflow workflow = new FlexibleWorkflow(service); workflow.execute(); } }
  • 19. IC Dependency Injection Ok, legal, mas o quê isso tem a ver com o pastel?!?!
  • 20. IC Testes com Mocks!!! class FlexibleWorkflowTest extends TestCase { // millions of other tests ... public void testMessageSend() { ISenderService mockService = new MockSenderService(); FlexibleWorkflow workflow = new FlexibleWorkflow(mockService); workflow.execute(); assertTrue(workflow.getResult(), true); mockService.assertCalled("send"); // millions of other assertions ... } }
  • 21. IC Mock Objects Mocks aren’t Stubs! http://martinfowler.com/articles/mocksArentStubs.html
  • 22. IC Stubs ISenderService stubService = new StubService(); FlexibleWorkflow workflow = new FlexibleWorkflow(stubService); workflow.execute(); // nada mais a fazer, o stub nao provê nenhuma informacao
  • 24. IC Mock Objects Estilo diferente de testes
  • 25. IC Mock Objects Inspecionar comportamento class FlexibleWorkflowTestextends TestCase { public void testMessageSend() { ISenderService mockService = new MockSenderService(); FlexibleWorkflow workflow = new FlexibleWorkflow(mockService); workflow.execute(); assertTrue(workflow.getResult(), true); mockService.assertCalled("send"); // millions of other assertions ... } }
  • 26. IC Mock Objects Simulando condições de erro public void testMessageSendError() { ISenderService mockService = new MockSenderService(); // mock lanca "SmtpTimeoutException" quando // metodo "send" e chamado mockService.setSideEffect("send", new SideEffect() { void run () { throw new SmtpTimeoutException();} }); FlexibleWorkflow workflow = new FlexibleWorkflow(mockService); try { workflow.execute(); } catch(Exception e) { assertFail(); } } interface SideEffect { void run(); }
  • 27. IC Mock Objects Mocks sao agentes do codigo de teste
  • 28. IC TDD “You have probably heard a few talks or read a few articles where test driven development is depicted as a magic unicorn that watches over your software and makes everybody happy.”
  • 29. IC TDD “ Well, about 18.000 lines of ‘magic unicorn’ code later, I'd like to put things into perspective.”
  • 30. IC TDD “The truth is, test driven development is a huge pain in the ass.”
  • 31. IC TDD “But do you know what sucks more? The liability that comes without those tests.” http://debuggable.com/posts/test-driven-development-at-transloadit:4cc892a7-b9fc-4d65-bb0c-1b27cbdd56cb
  • 32. IC TDD Ok, “Test First” ... ... mas por onde eu começo?!?!
  • 33. IC TDD Ok, “Test First” ... ... mas por onde eu começo?!?!
  • 34. IC TDD Implementar mínimo necessário para o teste FALHAR.
  • 35. IC TDD Implementar mínimo necessário para o teste FALHAR. class Math { public int sum(int a, int b) { thrownew NotImplementedException(); } } class MathTest extends TestCase { public void testSum() { Math m = new Math(); assertEquals(m.sum(1,2), 3); } }
  • 37. IC TDD Vantagens Código é testável “por natureza”.
  • 38. IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências.
  • 39. IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências. Cobertura de Código.
  • 40. IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências. Cobertura de Código. Design gera interfaces (de código) mais “amigáveis”.
  • 41. IC TDD Vantagens Código é testável “por natureza”. Ajuda a usar Mocks e Injeção de Dependências. Cobertura de Código. Design gera interfaces (de código) mais “amigáveis”. TDD não tem “ciúminho”.
  • 43. IC TDD Desvantagens Na 1a. vez, prepare-se para errar.
  • 44. IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito.
  • 45. IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda!
  • 46. IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda! Nada é de graça (No Unicorns)
  • 47. IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda! Nada é de graça (No Unicorns) Código legado
  • 48. IC TDD Desvantagens Na 1a. vez, prepare-se para errar. Muito. Mas aprender, mais ainda! Nada é de graça (No Unicorns) Código legado É um “pé no saco”
  • 49. IC Build “On-Commit” Build Noturno Testes Artefatos Radiadores De Informação
  • 50. IC Hudson e o “Gremlin”
  • 51. IC Hudson e o “Gremlin” Dificuldades Makefiles Ambiente
  • 52. Conclusão There’s no Free Lunch ... ... and no Silver Bullet! Baby Steps! Purismo não leva a lugar nenhum Ferramentas adequadas