SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
Test-driven development primer




                     Test-driven development primer


                             Robert Munteanu
                           http://robert.muntea.nu



http://robert.muntea.nu
@rombert
Who I am



  
      $DAYJOB                             
                                              FOSS
       
           Adobe Experience                   
                                                  MantisBT
           Management                         
                                                  Mylyn Connector for
             −   Apache Sling                     MantisBT
             −   Apache Jackrabbit
                                              
                                                  Mylyn Connector for
                                                  Review Board
             −   Apache Felix
                                              
                                                  Apache Sling




http://robert.muntea.nu
@rombert
Agenda




     ●
         Intro to automated testing of software
     ●
         Test-driven development
     ●
         Top-down Test-driven development
     ●
         General industry practices around testing




http://robert.muntea.nu
@rombert
Not on the agenda




     ●
         Performance testing
     ●
         Fuzzing
     ●
         Security testing
     ●
         Internationalization and localisation testing
     ●
         GUI-driven testing ( play and record )




http://robert.muntea.nu
@rombert
I. Role of testing in software products




                                  Testing workflows




http://robert.muntea.nu
@rombert
Testing workflows




     Developer ships code
     to tester for validation




http://robert.muntea.nu
@rombert
Testing workflows




     Developer fully
     automates testing




http://robert.muntea.nu
@rombert
Testing workflows




     Developer and QE
     developer and QE
     tester work together




http://robert.muntea.nu
@rombert
Testing workflows


     My code works,
     dammit




http://robert.muntea.nu
@rombert
Testing automation




 ●
   Supported by a testing framework
 ●
   Your favourite language probably has it
 ●
  Makes it easy to separate the test code from the
 production code




http://robert.muntea.nu
@rombert
Testing automation




http://robert.muntea.nu
@rombert
Testing automation



      This is what you
     usually get at
     development time




http://robert.muntea.nu
@rombert
Types of tests




      The testing pyramid
     is a popular way of
     classifying tests




http://robert.muntea.nu
@rombert
Unit tests




 ●
   Small, self-contained
 ●
   No external dependencies
 ●
   Fastest type of test ( under 1 second )
 ●
   Should be the bulk of your test




http://robert.muntea.nu
@rombert
Service tests




 ●
   Larger tests
 ●
   Usually interact with external systems
 ●
   SQL-based tests are a good example




http://robert.muntea.nu
@rombert
UI tests




 ●
   Application instance up and running
 ●
   Interacts with the UI rather than in-process
 ●
   Most programatic UI testing uses Selenium




http://robert.muntea.nu
@rombert
Q&A




                  End of first session, your questions?




http://robert.muntea.nu
@rombert
Test-Driven development


     ●
       Rapid feedback for your changes
     ●
       Ensures implementation and API are minimal
     ●
      Safety net when refactoring or making other
     changes (YAGNI)
     ●
       Saves everyone time and money




http://robert.muntea.nu
@rombert
Cost of fixing bugs




http://robert.muntea.nu
@rombert
Test-Driven Development Hands-On




                          Note to self → switch to Eclipse




http://robert.muntea.nu
@rombert
Test-Driven Development Hands-On




                          Note to self → switch to Eclipse




http://robert.muntea.nu
@rombert
Test-Driven Development




     Classes are not
     always used in
     isolation, how does
     that work with TDD?




http://robert.muntea.nu
@rombert
Test-Driven Development Hands-On


     Dude, remember
     Eclipse?




http://robert.muntea.nu
@rombert
Q&A




              End of second session, your questions?




http://robert.muntea.nu
@rombert
Test-Driven development




                          Time to go up the pyramid a bit




http://robert.muntea.nu
@rombert
Test-Driven Development Hands-On




http://robert.muntea.nu
@rombert
Test-Driven development




                          And finally, top of the pyramid




http://robert.muntea.nu
@rombert
Test-Driven Development Hands-On




http://robert.muntea.nu
@rombert
Q&A




                 End of third session, your questions?




http://robert.muntea.nu
@rombert
Code quality




  Test code quality is the same as production code
 quality
 ●
   Fast
 ●
   Stable
 ●
   Meaningful




http://robert.muntea.nu
@rombert
Code coverage




 ●
   Measure it, know your weak points
 ●
   Don't obsess over percentages




http://robert.muntea.nu
@rombert
Automate, automate, automate




 ●
   Don't rely only on your IDE for tests
 ●
   Make sure it works with a build tool
 ●
   Make sure it works on other machines as well




http://robert.muntea.nu
@rombert
Automate, automate, automate




http://robert.muntea.nu
@rombert
Automate, automate, automate




http://robert.muntea.nu
@rombert
Automate, automate, automate




http://robert.muntea.nu
@rombert
Q&A




                End of fourth session, your questions?




http://robert.muntea.nu
@rombert
Resources




                          http://google.com




http://robert.muntea.nu
@rombert
Thank you




                             Robert Munteanu
                          http://robert.muntea.nu




http://robert.muntea.nu
@rombert

Mais conteúdo relacionado

Destaque

Alam al masaref arabic version
Alam al masaref   arabic versionAlam al masaref   arabic version
Alam al masaref arabic versionZoulfikar Kobeissi
 
Smart security solutions for SMBs
Smart security solutions for SMBsSmart security solutions for SMBs
Smart security solutions for SMBsJyothi Satyanathan
 
Brochure Incontournables de FIRST FINANCE
Brochure Incontournables de FIRST FINANCEBrochure Incontournables de FIRST FINANCE
Brochure Incontournables de FIRST FINANCEfirstfinance
 
Cyber Security: User Access Pitfalls, A Case Study Approach
Cyber Security: User Access Pitfalls, A Case Study Approach Cyber Security: User Access Pitfalls, A Case Study Approach
Cyber Security: User Access Pitfalls, A Case Study Approach Aviva Spectrum™
 
Secure Coding for Java - An Introduction
Secure Coding for Java - An IntroductionSecure Coding for Java - An Introduction
Secure Coding for Java - An IntroductionSebastien Gioria
 
Top 10 claims interview questions with answers
Top 10 claims interview questions with answersTop 10 claims interview questions with answers
Top 10 claims interview questions with answersanielrodd8
 
Aviation Insurance
Aviation InsuranceAviation Insurance
Aviation InsuranceAoife06
 
標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單
標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單
標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單StandardlifeAEM
 
Port Susan Bay Restoration
Port Susan Bay Restoration Port Susan Bay Restoration
Port Susan Bay Restoration SWCNabi
 
Parts of culture in pakistan
Parts of culture in pakistanParts of culture in pakistan
Parts of culture in pakistanFahad Sattar
 
Ratkaisuja - Auringosta ja rahasta
Ratkaisuja -  Auringosta ja rahastaRatkaisuja -  Auringosta ja rahasta
Ratkaisuja - Auringosta ja rahastaJouni K. Juntunen
 

Destaque (17)

Alam al masaref arabic version
Alam al masaref   arabic versionAlam al masaref   arabic version
Alam al masaref arabic version
 
Smart security solutions for SMBs
Smart security solutions for SMBsSmart security solutions for SMBs
Smart security solutions for SMBs
 
Brochure Incontournables de FIRST FINANCE
Brochure Incontournables de FIRST FINANCEBrochure Incontournables de FIRST FINANCE
Brochure Incontournables de FIRST FINANCE
 
Cyber Security: User Access Pitfalls, A Case Study Approach
Cyber Security: User Access Pitfalls, A Case Study Approach Cyber Security: User Access Pitfalls, A Case Study Approach
Cyber Security: User Access Pitfalls, A Case Study Approach
 
Apsg cm4020 - event
Apsg cm4020 - eventApsg cm4020 - event
Apsg cm4020 - event
 
Secure Coding for Java - An Introduction
Secure Coding for Java - An IntroductionSecure Coding for Java - An Introduction
Secure Coding for Java - An Introduction
 
Top 10 claims interview questions with answers
Top 10 claims interview questions with answersTop 10 claims interview questions with answers
Top 10 claims interview questions with answers
 
Aviation Insurance
Aviation InsuranceAviation Insurance
Aviation Insurance
 
SERVICE MARKETING
SERVICE MARKETINGSERVICE MARKETING
SERVICE MARKETING
 
標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單
標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單
標準人壽My Smart Planner Android應用程式 - 投資組合及查看名單
 
Port Susan Bay Restoration
Port Susan Bay Restoration Port Susan Bay Restoration
Port Susan Bay Restoration
 
Parts of culture in pakistan
Parts of culture in pakistanParts of culture in pakistan
Parts of culture in pakistan
 
IHELP@KSDG
IHELP@KSDG IHELP@KSDG
IHELP@KSDG
 
Cpr
CprCpr
Cpr
 
Trabalho de história
Trabalho de históriaTrabalho de história
Trabalho de história
 
Emplyment Tribunal Statistics
Emplyment Tribunal StatisticsEmplyment Tribunal Statistics
Emplyment Tribunal Statistics
 
Ratkaisuja - Auringosta ja rahasta
Ratkaisuja -  Auringosta ja rahastaRatkaisuja -  Auringosta ja rahasta
Ratkaisuja - Auringosta ja rahasta
 

Semelhante a Tdd Primer

Of microservices and microservices
Of microservices and microservicesOf microservices and microservices
Of microservices and microservicesRobert Munteanu
 
Of Microservices and Microservices - Robert Munteanu
Of Microservices and Microservices -  Robert MunteanuOf Microservices and Microservices -  Robert Munteanu
Of Microservices and Microservices - Robert Munteanumfrancis
 
Apache Sling as a Microservices Gateway
Apache Sling as a Microservices GatewayApache Sling as a Microservices Gateway
Apache Sling as a Microservices GatewayRobert Munteanu
 
Secure by Default Web Applications with Apache Sling
Secure by Default Web Applications with Apache SlingSecure by Default Web Applications with Apache Sling
Secure by Default Web Applications with Apache SlingRobert Munteanu
 
PyCon UK 2013 "Python Adventures in Startup Land"
PyCon UK 2013 "Python Adventures in Startup Land"PyCon UK 2013 "Python Adventures in Startup Land"
PyCon UK 2013 "Python Adventures in Startup Land"rwillmer
 
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Robert Reiz
 
It's a Jungle Out There – IoT and MRuby
It's a Jungle Out There – IoT and MRubyIt's a Jungle Out There – IoT and MRuby
It's a Jungle Out There – IoT and MRubymatustomlein
 
DevOps Pipelines and Metrics Driven Feedback Loops
DevOps Pipelines and Metrics Driven Feedback LoopsDevOps Pipelines and Metrics Driven Feedback Loops
DevOps Pipelines and Metrics Driven Feedback LoopsAndreas Grabner
 
Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015AboutYouGmbH
 
Do you really want to go fully micro?
Do you really want to go fully micro?Do you really want to go fully micro?
Do you really want to go fully micro?Robert Munteanu
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?European Collaboration Summit
 
Reliable mobile test automation
Reliable mobile test automationReliable mobile test automation
Reliable mobile test automationVishal Banthia
 
Continuous delivery is more than dev ops
Continuous delivery is more than dev opsContinuous delivery is more than dev ops
Continuous delivery is more than dev opsAgile Montréal
 
Prototyping for mobile
Prototyping for mobilePrototyping for mobile
Prototyping for mobileMemi Beltrame
 
So you-want-to-go-faster
So you-want-to-go-fasterSo you-want-to-go-faster
So you-want-to-go-fasterOoblioob
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsPantheon
 
What to Do—Develop Your Own Automation or Use Crowdsourced Testing?
What to Do—Develop Your Own Automation or Use Crowdsourced Testing?What to Do—Develop Your Own Automation or Use Crowdsourced Testing?
What to Do—Develop Your Own Automation or Use Crowdsourced Testing?TechWell
 
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...Applitools
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & DebuggingIvano Malavolta
 

Semelhante a Tdd Primer (20)

Of microservices and microservices
Of microservices and microservicesOf microservices and microservices
Of microservices and microservices
 
Of Microservices and Microservices - Robert Munteanu
Of Microservices and Microservices -  Robert MunteanuOf Microservices and Microservices -  Robert Munteanu
Of Microservices and Microservices - Robert Munteanu
 
Apache Sling as a Microservices Gateway
Apache Sling as a Microservices GatewayApache Sling as a Microservices Gateway
Apache Sling as a Microservices Gateway
 
Secure by Default Web Applications with Apache Sling
Secure by Default Web Applications with Apache SlingSecure by Default Web Applications with Apache Sling
Secure by Default Web Applications with Apache Sling
 
PyCon UK 2013 "Python Adventures in Startup Land"
PyCon UK 2013 "Python Adventures in Startup Land"PyCon UK 2013 "Python Adventures in Startup Land"
PyCon UK 2013 "Python Adventures in Startup Land"
 
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014
 
It's a Jungle Out There – IoT and MRuby
It's a Jungle Out There – IoT and MRubyIt's a Jungle Out There – IoT and MRuby
It's a Jungle Out There – IoT and MRuby
 
DevOps Pipelines and Metrics Driven Feedback Loops
DevOps Pipelines and Metrics Driven Feedback LoopsDevOps Pipelines and Metrics Driven Feedback Loops
DevOps Pipelines and Metrics Driven Feedback Loops
 
Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015
 
Do you really want to go fully micro?
Do you really want to go fully micro?Do you really want to go fully micro?
Do you really want to go fully micro?
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?
 
Reliable mobile test automation
Reliable mobile test automationReliable mobile test automation
Reliable mobile test automation
 
Continuous delivery is more than dev ops
Continuous delivery is more than dev opsContinuous delivery is more than dev ops
Continuous delivery is more than dev ops
 
聊聊測試左移
聊聊測試左移聊聊測試左移
聊聊測試左移
 
Prototyping for mobile
Prototyping for mobilePrototyping for mobile
Prototyping for mobile
 
So you-want-to-go-faster
So you-want-to-go-fasterSo you-want-to-go-faster
So you-want-to-go-faster
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
 
What to Do—Develop Your Own Automation or Use Crowdsourced Testing?
What to Do—Develop Your Own Automation or Use Crowdsourced Testing?What to Do—Develop Your Own Automation or Use Crowdsourced Testing?
What to Do—Develop Your Own Automation or Use Crowdsourced Testing?
 
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
Unlocking the Power of ChatGPT and AI in Testing - NextSteps, presented by Ap...
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & Debugging
 

Mais de Robert Munteanu

Secure by Default Web Applications
Secure by Default Web ApplicationsSecure by Default Web Applications
Secure by Default Web ApplicationsRobert Munteanu
 
Sling Applications - A DevOps perspective
Sling Applications - A DevOps perspectiveSling Applications - A DevOps perspective
Sling Applications - A DevOps perspectiveRobert Munteanu
 
Will it blend? Java agents and OSGi
Will it blend? Java agents and OSGiWill it blend? Java agents and OSGi
Will it blend? Java agents and OSGiRobert Munteanu
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceEscape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceRobert Munteanu
 
Crash course in Kubernetes monitoring
Crash course in Kubernetes monitoringCrash course in Kubernetes monitoring
Crash course in Kubernetes monitoringRobert Munteanu
 
Java agents for fun and (not so much) profit
Java agents for fun and (not so much) profitJava agents for fun and (not so much) profit
Java agents for fun and (not so much) profitRobert Munteanu
 
Will it blend? Java agents and OSGi
Will it blend? Java agents and OSGiWill it blend? Java agents and OSGi
Will it blend? Java agents and OSGiRobert Munteanu
 
Cloud-native legacy applications
Cloud-native legacy applicationsCloud-native legacy applications
Cloud-native legacy applicationsRobert Munteanu
 
From Monolith to Modules - breaking apart a one size fits all product into mo...
From Monolith to Modules - breaking apart a one size fits all product into mo...From Monolith to Modules - breaking apart a one size fits all product into mo...
From Monolith to Modules - breaking apart a one size fits all product into mo...Robert Munteanu
 
What's new in the Sling developer tooling?
What's new in the Sling developer tooling?What's new in the Sling developer tooling?
What's new in the Sling developer tooling?Robert Munteanu
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code baseRobert Munteanu
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code baseRobert Munteanu
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code baseRobert Munteanu
 
Zero downtime deployments for Sling application using Docker
Zero downtime deployments for Sling application using DockerZero downtime deployments for Sling application using Docker
Zero downtime deployments for Sling application using DockerRobert Munteanu
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code baseRobert Munteanu
 
Slide IDE Tooling (adaptTo 2016)
Slide IDE Tooling (adaptTo 2016)Slide IDE Tooling (adaptTo 2016)
Slide IDE Tooling (adaptTo 2016)Robert Munteanu
 
Apache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareRobert Munteanu
 
Effective Web Application Development with Apache Sling
Effective Web Application Development with Apache SlingEffective Web Application Development with Apache Sling
Effective Web Application Development with Apache SlingRobert Munteanu
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Robert Munteanu
 

Mais de Robert Munteanu (20)

Secure by Default Web Applications
Secure by Default Web ApplicationsSecure by Default Web Applications
Secure by Default Web Applications
 
Sling Applications - A DevOps perspective
Sling Applications - A DevOps perspectiveSling Applications - A DevOps perspective
Sling Applications - A DevOps perspective
 
Will it blend? Java agents and OSGi
Will it blend? Java agents and OSGiWill it blend? Java agents and OSGi
Will it blend? Java agents and OSGi
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceEscape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud Service
 
Crash course in Kubernetes monitoring
Crash course in Kubernetes monitoringCrash course in Kubernetes monitoring
Crash course in Kubernetes monitoring
 
Java agents for fun and (not so much) profit
Java agents for fun and (not so much) profitJava agents for fun and (not so much) profit
Java agents for fun and (not so much) profit
 
Will it blend? Java agents and OSGi
Will it blend? Java agents and OSGiWill it blend? Java agents and OSGi
Will it blend? Java agents and OSGi
 
Cloud-native legacy applications
Cloud-native legacy applicationsCloud-native legacy applications
Cloud-native legacy applications
 
Cloud-Native Sling
Cloud-Native SlingCloud-Native Sling
Cloud-Native Sling
 
From Monolith to Modules - breaking apart a one size fits all product into mo...
From Monolith to Modules - breaking apart a one size fits all product into mo...From Monolith to Modules - breaking apart a one size fits all product into mo...
From Monolith to Modules - breaking apart a one size fits all product into mo...
 
What's new in the Sling developer tooling?
What's new in the Sling developer tooling?What's new in the Sling developer tooling?
What's new in the Sling developer tooling?
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
Zero downtime deployments for Sling application using Docker
Zero downtime deployments for Sling application using DockerZero downtime deployments for Sling application using Docker
Zero downtime deployments for Sling application using Docker
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
Slide IDE Tooling (adaptTo 2016)
Slide IDE Tooling (adaptTo 2016)Slide IDE Tooling (adaptTo 2016)
Slide IDE Tooling (adaptTo 2016)
 
Apache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middleware
 
Effective Web Application Development with Apache Sling
Effective Web Application Development with Apache SlingEffective Web Application Development with Apache Sling
Effective Web Application Development with Apache Sling
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...
 

Último

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 

Último (20)

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 

Tdd Primer

Notas do Editor

  1. Bun venit la prezentare Repet titlul prezentării
  2. Contribuitor la proiecte open source - partial for fun, parțial ca să keep up to date și sa încerc alte tehnologii - CS la Adobe, lucrez cu platforma CQ - baza open source a platformei este Apache Sling și astfel am avut contact Hai să vedem despre voi – câți aveți o minimă experiență în limbaje de programare high-level ( Java, PHP, Ruby etc ) ; dar C/C++ ; dar ASM? - câți ați testat automat un program de calculator ( dacă da, cu ce, share un pic la experiență )
  3. Acestea sunt cele patru puncte pe care vreau să le ating. Avem destul timp la dispoziție și putem devia oricând. Dacă sunt lucruri pe care vreți să le discutăm mai în detaliu opriți-mă și întrebați. Prefer să fiu întrerupt, sigur nu uit poezia :-) Nu este necesar să folosiți calculatorul sau un program pentru a lucra. Eu voi avea și câteva demo-uri ; daca vreți să le încercați și voi e OK ( aveți nevoie de acces la rețea ) dar nu este obligatoriu. Demo-urile vor fi în Java, dar nu este necesar decât să puteți să citiți Java.
  4. Testarea ca și domeniu de discuție e fantastic de mare și o să ne limităm la testarea automată legată de funcționarea codului în condiții normale să-i spunem. Accentul va fi pe test-driven development ca și specializare a practicii de testare automată. Dacă vreți să discutăm despre subiectele de mai sus sau despre alte subiecte de testare o putem face în ultima dintre sesiuni, cea de practici generale.
  5. Când avem un flow de tipul eu scriu cod, tu testezi, de multe ori e un semn al unui proces de tip waterfall care s-a propagat în stilul de lucru al echipei. Am încercat să fiu subtil cu poza :-) Este cineva familiar cu modelul de dezoltare waterfall? Pe scurt, avem Cerințe → Design → Implementare → Verificare → Mentenanță. Fără buclă de feedback. Ce înseamnă asta în practică ? Eu ca dezvoltator primesc rezultatele testării cu întârziere ( eventual în timp ce lucrez la altceva ) ; tester-ul e o resursă care probabil nu e alocată mereu echipei ; o viteză scăzută de reacție și timp de dezvoltare scăzut.
  6. Putem să avem și altă extremă, cea în care nu există tester, iar dezvoltatorul testează totul automat. Cum vă sună asta, e bine sau rău? Evident, e bine și rău :-) Bine pentru că arată o înclinație înspre testare, și clar bucla de feedback pe care o am de la un test rulat local pe calculatorul meu ( < 1 secundă ) este mult mai scurtă decât câteva ore ( în cazul bun ) în cazul unui tester. Multe probleme vor fi rezolvate foarte rapid. Rău este că dezvoltatorul nu poate testa tot – el a scris codul și inconștient va testa ce a scris ; dacă ar fi știut ce nu merge n-ar mai fi scris codul astfel. În plus, un dev nu poate face ca un tester fuzzing, security testing etc
  7. Aici e cumva o situație ideală, în care avem un dezvoltator, un dezvoltator QE ( sau SET etc ) și un tester, fiecare cu rolul lui. QE dev-ul se ocupă de framework-uri de testare, 'promoveză' ideea de software testabil și de calitate internă și poate să scrie anumite teste. Dev-ul își scrie și el testele. La final un tester face partea manuală, fie pentru că e prea complicat de automatizat, fie pentru că nu trebuie automatizată ( fuzzing, penetrating testing etc ) Totul pare bine și frumos aici dar … banii :-)
  8. Nu am pus acest slide doar pentru valoarea artistică :-) Se întâmlă mai des decât ați crede. Și înainte de acest meme am întâlnit expresia “cel mai bun test este producția”. Și chiar asta era abordarea. Ce ar fi bun aici? Timpul dezvoltatorului, lipsă de stres :-) Ce ar fi rău? Calitatea se duce de râpă, dificultatea în testare, nu există teste de regresie, nu există pași clar de reproducere... Cam tot e rău aici.
  9. Testarea automată se face în general cu sprijinul unui framework de testare. Fiecare limbaj de programare are unul ; am găsit de la Java la C la PHP la PL/SQL Nu mai avem nevoie de a scrie cod de infrastructură pentru teste, e suficient să includem o bibliotecă externă în proiectul nostru și putem să scriem teste automate.
  10. Aici avem un foarte simplu exemplu de o clasă de testat și de un test. Este timpul de cod pe care nu îl scriem niciodată, dar este un exemplu perfect pentru demonstrație. În clasa de producție avem o funcție, iar în clasa de test avem un caz de test. Cazul de test este concis, ușor de înțeles, și chiar se poate citi cu voce tare: assertThat add(1,1) is (2). Testul se poate rula din linie de comandă sau dintr-un IDE, spre exemplu.
  11. În timp de dezvolt nu am decât de dat un click de dreapta pe clasa de test și Run As → Junit test . Voi vedea toate metodele testate și apoi văd care au trecut, care au picat, motivele pentru care au picat și un stack trace dacă e cazul. De asta prefer un IDE față de un editor de text simplu. Ăsta e un sfat general pe care vi l-aș da, nu neapărat legat de testare. Alegeți-vă cu grijă uneltele cu care lucrați, vă pot ține în loc sau vă pot ajuta să fiți mult, mult mai productivi.
  12. Piramida testării este o modalitate utilă de a vizualiza ce fel de teste putem scrie și mai ales cum să le împărțim. Compartimentarea sugerează că avem o bază de teste unitare, un strat de testare a serviciilor și un vârf al testelor care interacționează cu interfața. Ca și volum al testelor recomandarea este să avem cât mai multe teste unitare, un număr redus de teste care interacționează cu serviciilor și un număr minim de teste care interacționează cu interfața. Explicația este că pe verticală crește complexitatea, timpul de execuție și instabilitatea.
  13. Testele unitare sunt poate cel mai la îndemână mod de teste pe care îl avem. Clasa (trivială) pe care am văzut-o mai devreme este un exemplu de test unitar. Testele unitare testează o unitate de cod, fără a lua în calcul alte unități/sisteme. În Java, unitatea este în mod normal o clasă. Interacțiunile cu alte sisteme 1) introduc elemente aleatoare în test ( cum ar fi un test unitate care transferă 250 MB prin FTP? ) și 2) reduc viteza de rulare. Teste extrem de rapide duc la posibilitatea de a rula întreaga baterie de teste foarte rapid. Cum ar fi să rulezi 10,000 de teste în mai puțin de o secundă?
  14. De cele mai multe ori nu este posibil să nu interacționezi cu alte sisteme. O bază de date ( SQL sau nu ) , Web Service-uri, un ORM ca Hibernate sunt foarte dificil de testat în izolare. Mai mult, de cele mai multe ori preferi să testezi un SELECT și să fi sigur că întoarce datele corecte, chiar dacă nu e la fel de ușor de scris ca un unit test. De genul ai o bază de date in-memory ( H2 ) pe care o creezi special pentru testul tău unitate, o populezi cu date și apoi rulezi un SELECT. La sfârșit cureți baza de date. Clar este mai încet, dar este foarte util.
  15. De multe ori este util să ai teste care validează aplicația end-to-end, de la interfață la baza de date la rutinele low-level. De asemenea, sunt singurele teste care validează că aplicația chiar merge. Degeaba ai testele unitare care trec toate dacă ai o eroare de javascript pe home page. Sunt lente, lente, LENTE. De asemenea, sunt instabile. E o problemă dificilă să controlezi programatic un browser, să inspectezi controalele de pe pagină, sa lansezi acțiuni etc. Plus că mai nou toate aplicațiile sunt javascript-enhanced sau chiar single-page application, ceea ce complică și mai mult efortul de testare. Au rolul lor, dar trebuie ținute sub control ca număr, timp de execuție și complexitate de implementare.
  16. Unele din avantaje nu sunt exclusive TDD, țin și de partea de automated testing. Clar cu TDD ai cel mai rapid feeback pentru schimbările tale. Un alt punct bun este că ne ajută să avem implementări și API-uri ( ce sunt API-urile? ) minimale. Ca programatori avem tendința să avem implementări complicate, care pe termen lung sunt un bagaj inutil. YAGNI – you ain't gonna need it. Timpul și costul necesare reparării unui bug sunt cele mai mici la începutul procesului de dezvoltare. Un bug prins în ciclul de testare automată de dezvoltator este cel mai ieftin. Un bug în faza de testare e ceva mai OK, dar în producție poate fi dezastruos de scump. Un algoritm de criptare slab duce la probleme de securitate, să nu mai vorbim dacă e cazul de aparatură medicală sau de soft pentru autovehicule.
  17. În caz că nu v-am convins logic, poate cu benzi desenate merge ;-)
  18. Un demo de câteva minute în care trecem prin pașii clasici ai TDD 1. adaug un test 2. rulez toate testele și văd dacă pică vreunul 3. scriu cod 4. rulez toate testele și văd dacă pică vreunul 5. refactor 6. GOTO 1
  19. Un demo de câteva minute în care trecem prin pașii clasici ai TDD 1. adaug un test 2. rulez toate testele și văd dacă pică vreunul 3. scriu cod 4. rulez toate testele și văd dacă pică vreunul 5. refactor 6. GOTO 1
  20. Într-adevăr, clasele care nu interacționează cu nimeni și nimic sunt foarte simplu de testat. Dar ce facem cu clasele care au colaboratori? Dacă folosim colaboratorii în test, nu mai este un test unitar, cu toate problemele care pot apare ( instabilitate, timp de execuție crescut, complexitate ). Abordarea preferată este de a înlocui un colaborator real cu unul fals, care reacționează așa cum îl instruim noi. Astfel de colaboratori se numesc în general stubs sau mocks, în funcție de cât de deștepți sunt. Un stub are răspunsuri predefinite. Un mock are comportament mai complex, poate să arunce excepții în anumite condiții etc
  21. Un demo despre stub-uri.
  22. Acum că am trecut prin tehnicile uzuale pentru testele unitare e vremea să vedem cum punem cap la cap un test care interacționează cu un serviciu extern, în cazul nostru o bază de date. Nu voi folosi un mock sau un stub, pentru că API-ul de JDBC nu e chiar simplu de mock-uit, și mă interesează dacă am scris bine un SELECT. Testul va folosi H2 – o bază de data Java, care poate fi pornită și oprită în același proces. Are avantajul de a fi foarte rapidă și ușor de folosit în teste. Dezavantajul este că de multe ori nu este folosită în producție, doar în teste, și atunci dacă sintaxa bazei de date folosite în producție diferă, apar probleme. Cum se pot rezolva? 1. Cu atenție, 2. cu teste rulate și pe baza de date de prod 3. Cu un ORM cum este hibernate.
  23. Demo cu DAO.
  24. Vârful piramidei e rezervat pentru testele care exersează UI-ul. Aceste teste sunt lente, mai puțin stabile, dar verifică aplicația pe de-a întregul. Folosirea acestor teste în model TDD se mai numește și ATDD – Acceptance-Driven Test development. Practic testele de UI pot fi folosite pentru a verifica în ce măsură aplicația dezvoltată corespunde cerințelor – dacă este acceptată de către client sau nu. Vom vedea cum putem scrie și executa teste de UI folosing Selenium și un wrapper peste aceasta – Thucydides.
  25. Demo cu Selenium + Thucydides De review - Page object - Selenium model - Testul în sine - Rapoartele Thucydides
  26. În aplicații mari testele pot ajunge la dimensiuni respectabile, poate chiar să depășească dpdv al liniilor codul productiv. Atunci este esențial ca testele să aibă o calitate ridicată. Testele lente nu vor fi rulate suficient de des. Testele instabile vor fi ignorate. Testele care nu testează nimic important vor trece tot timpul și nu aduc valoare.
  27. Code coverage-ul ne indică în ce măsură testele noastre acoperă tot codul de producție. Sunt mai mulți indicatori – line, statement, branch . Important este să tratăm code coverage-ul ca o informație calitativă pentru a gestiona riscul, și nu ca un prag care trebuie atins.
  28. Dacă testele sunt legate de mașina ta sau de un IDE, sunt inutile. Automatizează tot procesul, de la compilare aplicației până la împachetare ( make, ant, maven, gradle, sbt, whatever ).
  29. Jenkins e un sistem de continuous integration ; pe scurt – la fiecare commit ( sau periodic, sau manual, sau … ) rulează un set de comenzi pe un proiect software. Cel mai adesea setul standard – compilare, testare, împachetare. Poate ține evoluția în timp a anumitor indicatori – număr de teste, teste trecute/picate etc. Extensibil până la absurd. Testele automatizate pe Jenkins au o vizibilitate sporită – mai ales când pică build-ul și vin mailuri :-)
  30. Jenkins permite constuirea unui 'build pipeline', o înseriere de job-uri, care pot să separe pașii pentru un feedback mai rapid. Unii pași pot fi manuali, alții automați. Testele de acceptanță, mai lente, sunt un candidat ideal pentru un job separat care să fie rulat numai după ce trec testele unitare.
  31. Din nou, Jenkins are un plugin :-) care permite configurarea unui job în funcție de un parametru variabil – axa. Este ideal – spre exemplu – pentru a putea testa aplicația pe mai multe browsere sau pe mai multe tipuri de baze de date.