SlideShare a Scribd company logo
1 of 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

More Related Content

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

Featured

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
 

Featured (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