SlideShare a Scribd company logo
TDD & CI/CD Overview of TDD and
CI/CD
Agenda
• Section: 1
• What is TDD?
• Why do we need to use it?
• How do we use it?
• Section 2:
• What is CI?
• What Continuous Delivery &
Continuous Deployment?
• Why do we use CI/CD?
• How do we use it?
• Section 3:
• CI/CD - Demo
TDD ( Test Driven
Development)
• “Test Driven Development
(TDD) is a technique for
building software that guides
software development by
writing tests” –
Martin Fowler’s Definition
Step 1: Write test that fails
• Red - Write a little test
that doesn’t work,
perhaps doesn’t even
compile at first.
Step 2: Make test pass
• Green - Make the test
work quickly, committing
Step 3: Refactor/ Cleanup code
• Refactor – Eliminate all
the duplication and
smells created in just
getting the test to work.
TDD
Frameworks
• Junit – Assert , Hamcrest
• Mockito – Mockito, EasyMock, PowerMock, JMock
• Stub
• Mock
• File
• DataSet
• Cucumber (BDD – Extensions of TDD)
Java:
• Rspec
• Factorygirl
• Mocha
• Cucumber
Ruby:
Assertions
• Assertions verify that expected conditions are met. Each assertion
has different overloaded methods to accespt different parameters.
• assertTrue
• assertFalse
• assertNull
• assertNotNull
• assertEquals
• assertNotEquals
• assertArrayEquals
• assertIterableEquals
• assertSame and assertNotSame
• assertAll
• assertThrows
• assertTimeout
• assertLinesMatch
• fail
Different Annotations in Junit and Jupitor
JUnit4 Junit Jupitor
@Before @BeforeEach
@After @AfterEach
@BeforeClass @BeforeAll
@AfterClass @AfterAll
@Ignore @Diabled
@Category @Tag
@RunWith @ExtendWith
JUnit – Assert
Hamcrest
• Using Assert:
Assert.assertEquals(“Shan”, user.firstName());
//or Using Assert static imports
assertEquals(“Shan”, user.firstName());
• Using Hamcrest
MatcherAssert.assertThat(user.firstName().IsEqua
l.equalTo(“Shan”));
//Or Using static imports
assertThat(user.firstName(), equalTo(“Shan”));
Mockito
EasyMock
JMock
• Methods under test often leverage
dependencies
• Test with dependencies created challenges
• Live database needed
• Multiple developers testing simultaneously
• Incomplete dependency implementation
• Mocking frameworks give you control
• Implement the mocked functionality in a class -
Tedious & Obscure
• Leverage a mocking framework
• Avoid class creation & Leverages the proxy
pattern
Creating Mock
Instances
• Mockito.mock(Class<?>class) is the core
method for creating mocks
• @Mock is an alternavtive
• Example
Class BookServiceTest {
protected @Mock BookDao mockBookDao;
@Before
public void setup(){
MockitoAnnotations.initMocks(this);
}
}
Using
MockSettings
• The MockSettings interface provides added
control for mock creation
@Test
Public void test_getBookDetails {
MockSettings settings = Mockito.withSettings();
BookDao mockBookDao =
Mockito.mock(BookDao.class, settings);
}
Mockito
• Support Unit testing Cycle
• Creating the Mock
BookDao mockBookDao = Mockito.mock(BookDao.class)
• Setup – Method Stubbing
Mockito.when(mockBookDao.findByTitle(bookTitle)).thenReturn(BookFixture)
• Verification
Mockito.verify(mockBookDao).findByTitle(bookTitle)
Setup Execution Verification Teardown
Mockito -
Verification
• Mockito.verify(..) is used to verify an intended
mock operation was called
• Example
• Setup
Mockito.when(mockBookService.getBookDeta
ils(bookId)).thenReturn(bookDetail);
• Verification
Mockito.verify(mockBookService).getBookDet
ails(bookId);
Verification –
Cont.
• VerificationMode allows extra verification of the operation
• Times(n)
• atLeastOnce(n)
• atLeast(n)
• atMost(n)
• Never()
//setup
Mockito.when(mockBookService.getBookDetails(bookId)).thenRe
turn(bookDetails);
//verification
Mockito.verify(mockBookService,
VerificationSettings.times(2)).getBookDetails(bookId);
• Verifying no interactions globally
• Mockito.verify(..).zeroInteractions()
• Mockito.verify(..).noMoreInteactions()
Test Fixtures
• A Test fixture is a fixed state of a set of objects
used as a baseline for running tests.
• Ensure that there is a well known and fixed
environment in which tests are run so that
results are repeatable.
• Type of Fixtures:
• Object
• Mock
• Database – DataSet, Query DataSet,
Replacement DataSet
• Files – Excel, XML, FlatXML
Section: 2
CI/CD&CD
What is Continuous integration?
What is Continuous Delivery?
What is Continuos Deployment?
Why do we need to use it?
How do we use it?
CI/CD – What are the frameworks available to do
ci/cd?
Demo!
CI/CD – Cont.,
• Agile
• Refactor
• Educate Everyone
• Be Small
• Practice TDD
Define Your CD Pipeline As Code
• Have a Fast Pipeline
• Consider Fixing a Failed Pipeline As Highest
Priority
• Run the CD Pipeline
• Commit only to the Master Branch(Single
branching strategy) Or (Use Short-Lived Feature
Branch)
Continuous Integration
• Continuous Integration
(CI) is development
practice that requires
developers to integrate
code into a shared
repository serveral times
a day
CI Principles
Have a single place where all the code lives
Everyone commits to the mainline every day
Automate the build process
- Fix the broken build immediately
- Make and keep the build fast
Every commit triggers a build
Automate the testing process
Everyone has access to the latest results
Everyone can see everything
CI Benefits:
Integration takes less effort
Issue will come up more early
Automation means less issues
The process is more visible
Improved team communication
Short Integration iterations means more flexibility
The code is ready to be delivered more often
What can CI
Accomplish?
Higher Quality
Faster Delivery
Lower Costs
More Flexibility
Integration
High Chance of Errors(Bugs & Reworks)
Defects are found late(Causing extra works)
Lots of effort in integration
Difficult to reproduce the release
Can only release once per iteration
Release
• High Chance of Errors
• Lots of effort in deployment
• Difficult to reproduce deployment
• Inconsistency in environments
• Deployments are scary
• slow delivery of functionality
CI: Summary
Continuous Integration
• Integrate centrally every day
• Automate
• Build
• Test
Higher Quality
Faster Delivery
Lower Costs
More Flexibility
CD – Continuos Delivery
• Continuous Delivery is a
Software discipline where
software can be released
to production at any time
Continuous Delivery
QA
Developers Manual Test
Release Approval
Operations Build Pipeline Release Pipeline
SC Build Test deployCreate Test
ProdOn DemandAutomated
CD
Principles
Have Continuous integration in place
Development and Operations should work well together
Treat Infrastructure as a code artifact
Automate the environment creation process
Automate the release process
- Automate acceptance tests
Include release do definition of done
Releasing should be on-demand
Everyone has access to the latest result
Everyone can see everything
CD Benefits:
Releasing take less effort
Releasing is more
- Reliable
- Repeatable
Put control of release in the hands of business
Release more often
Get feedback earlier
What can
CD
Accomplish?
Higher Quality
Faster Delivery
Lower Costs
More Flexibility
Continuous
Deployment
• Software is automatically deployed to
production all the time.
CD
Summary
Delivery != Deployment
You need Continuous integration
Continuous delivery
- Release pipeline
- Automated release
- Automated acceptance tests
Higher Quality
Faster Delivery
Lower Costs
More Flexibility
CI & CD Summary : Cont.,
Automate
everything
1
Developers and
operations work
together
2
CI& CD are very
Powerful
3
CI/CD Tools:
SCM – GitHub, GitLab, BitBucket, SVN, VSS
CI & CD– Jenkins, Bamboo, TeamCity, Travis CI, Stash, Azure Pipeline,
GC Build, Cirrus CI, Circle CI
Ruby: Cloud 66
Container: Docker
Platform: K8
AWS – AWS Commit, AWS Code Pipeline, AWS Deploy
Cloud: AWS, GCP, Pivotal, Predix
• Thank you

More Related Content

What's hot

CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with JenkinsMartin Málek
 
Transforming Organizations with CI/CD
Transforming Organizations with CI/CDTransforming Organizations with CI/CD
Transforming Organizations with CI/CDCprime
 
CI/CD Overview
CI/CD OverviewCI/CD Overview
CI/CD OverviewAn Nguyen
 
Flusso Continuous Integration & Continuous Delivery
Flusso Continuous Integration & Continuous DeliveryFlusso Continuous Integration & Continuous Delivery
Flusso Continuous Integration & Continuous DeliveryJoost van der Griendt
 
CI/CD 101
CI/CD 101CI/CD 101
CI/CD 101djdule
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationamscanne
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CIColCh
 
CI/CD (DevOps) 101
CI/CD (DevOps) 101CI/CD (DevOps) 101
CI/CD (DevOps) 101Hazzim Anaya
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICDKnoldus Inc.
 
CI/CD Best Practices for Your DevOps Journey
CI/CD Best  Practices for Your DevOps JourneyCI/CD Best  Practices for Your DevOps Journey
CI/CD Best Practices for Your DevOps JourneyDevOps.com
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework IntroductionPekka Klärck
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.skJuraj Hantak
 
Fundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CDFundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CDBatyr Nuryyev
 
The DevOps Journey
The DevOps JourneyThe DevOps Journey
The DevOps JourneyMicro Focus
 

What's hot (20)

CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with Jenkins
 
Transforming Organizations with CI/CD
Transforming Organizations with CI/CDTransforming Organizations with CI/CD
Transforming Organizations with CI/CD
 
CI/CD Overview
CI/CD OverviewCI/CD Overview
CI/CD Overview
 
Gitlab CI/CD
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CD
 
Flusso Continuous Integration & Continuous Delivery
Flusso Continuous Integration & Continuous DeliveryFlusso Continuous Integration & Continuous Delivery
Flusso Continuous Integration & Continuous Delivery
 
CI/CD 101
CI/CD 101CI/CD 101
CI/CD 101
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CI
 
CI/CD (DevOps) 101
CI/CD (DevOps) 101CI/CD (DevOps) 101
CI/CD (DevOps) 101
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 
CI/CD Best Practices for Your DevOps Journey
CI/CD Best  Practices for Your DevOps JourneyCI/CD Best  Practices for Your DevOps Journey
CI/CD Best Practices for Your DevOps Journey
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
DevOps: Age Of CI/CD
DevOps: Age Of CI/CDDevOps: Age Of CI/CD
DevOps: Age Of CI/CD
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework Introduction
 
CICD with Jenkins
CICD with JenkinsCICD with Jenkins
CICD with Jenkins
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
 
Fundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CDFundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CD
 
The DevOps Journey
The DevOps JourneyThe DevOps Journey
The DevOps Journey
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOWCI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
 

Similar to Test Driven Development & CI/CD

Dev ops != Dev+Ops
Dev ops != Dev+OpsDev ops != Dev+Ops
Dev ops != Dev+OpsShalu Ahuja
 
The Continuous delivery value - Funaro
The Continuous delivery value - FunaroThe Continuous delivery value - Funaro
The Continuous delivery value - FunaroCodemotion
 
The Continuous delivery Value @ codemotion 2014
The Continuous delivery Value @ codemotion 2014The Continuous delivery Value @ codemotion 2014
The Continuous delivery Value @ codemotion 2014David Funaro
 
Continuous integration, delivery & deployment
Continuous integration,  delivery & deploymentContinuous integration,  delivery & deployment
Continuous integration, delivery & deploymentMartijn van der Kamp
 
Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersSPC Adriatics
 
Continuous delivery @wcap 5-09-2013
Continuous delivery   @wcap 5-09-2013Continuous delivery   @wcap 5-09-2013
Continuous delivery @wcap 5-09-2013David Funaro
 
Continuous Integration: A Case Study
Continuous Integration: A Case StudyContinuous Integration: A Case Study
Continuous Integration: A Case StudyIndicThreads
 
Definition of Done and Product Backlog refinement
Definition of Done and Product Backlog refinementDefinition of Done and Product Backlog refinement
Definition of Done and Product Backlog refinementChristian Vos
 
SanDiego_DevOps_Meetup_9212016-v8
SanDiego_DevOps_Meetup_9212016-v8SanDiego_DevOps_Meetup_9212016-v8
SanDiego_DevOps_Meetup_9212016-v8Rajwinder Singh
 
SanDiego_DevOps_Meetup_9212016
SanDiego_DevOps_Meetup_9212016SanDiego_DevOps_Meetup_9212016
SanDiego_DevOps_Meetup_9212016w2fong
 
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...WSO2
 
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015Vimal Suba
 
CI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOUCI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOUHanokh Aloni
 
Back To Basics
Back To BasicsBack To Basics
Back To Basicskamalikamj
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOpsEklove Mohan
 
Introduction to Continuous Integration
Introduction to Continuous IntegrationIntroduction to Continuous Integration
Introduction to Continuous IntegrationZahra Golmirzaei
 
Continuous deployment steve povilaitis
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitisSteve Povilaitis
 

Similar to Test Driven Development & CI/CD (20)

Dev ops != Dev+Ops
Dev ops != Dev+OpsDev ops != Dev+Ops
Dev ops != Dev+Ops
 
The Continuous delivery value - Funaro
The Continuous delivery value - FunaroThe Continuous delivery value - Funaro
The Continuous delivery value - Funaro
 
The Continuous delivery Value @ codemotion 2014
The Continuous delivery Value @ codemotion 2014The Continuous delivery Value @ codemotion 2014
The Continuous delivery Value @ codemotion 2014
 
Continuous integration, delivery & deployment
Continuous integration,  delivery & deploymentContinuous integration,  delivery & deployment
Continuous integration, delivery & deployment
 
How to Add Perfecto to Your CI
How to Add Perfecto to Your CIHow to Add Perfecto to Your CI
How to Add Perfecto to Your CI
 
Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill Ayers
 
DevTestOps
DevTestOpsDevTestOps
DevTestOps
 
Continuous delivery @wcap 5-09-2013
Continuous delivery   @wcap 5-09-2013Continuous delivery   @wcap 5-09-2013
Continuous delivery @wcap 5-09-2013
 
Continuous Integration: A Case Study
Continuous Integration: A Case StudyContinuous Integration: A Case Study
Continuous Integration: A Case Study
 
Definition of Done and Product Backlog refinement
Definition of Done and Product Backlog refinementDefinition of Done and Product Backlog refinement
Definition of Done and Product Backlog refinement
 
SanDiego_DevOps_Meetup_9212016-v8
SanDiego_DevOps_Meetup_9212016-v8SanDiego_DevOps_Meetup_9212016-v8
SanDiego_DevOps_Meetup_9212016-v8
 
DevOps in an Embedded World
DevOps in an Embedded WorldDevOps in an Embedded World
DevOps in an Embedded World
 
SanDiego_DevOps_Meetup_9212016
SanDiego_DevOps_Meetup_9212016SanDiego_DevOps_Meetup_9212016
SanDiego_DevOps_Meetup_9212016
 
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
 
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
 
CI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOUCI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOU
 
Back To Basics
Back To BasicsBack To Basics
Back To Basics
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
 
Introduction to Continuous Integration
Introduction to Continuous IntegrationIntroduction to Continuous Integration
Introduction to Continuous Integration
 
Continuous deployment steve povilaitis
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitis
 

Recently uploaded

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 

Recently uploaded (20)

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

Test Driven Development & CI/CD

  • 1. TDD & CI/CD Overview of TDD and CI/CD
  • 2. Agenda • Section: 1 • What is TDD? • Why do we need to use it? • How do we use it? • Section 2: • What is CI? • What Continuous Delivery & Continuous Deployment? • Why do we use CI/CD? • How do we use it? • Section 3: • CI/CD - Demo
  • 3. TDD ( Test Driven Development) • “Test Driven Development (TDD) is a technique for building software that guides software development by writing tests” – Martin Fowler’s Definition
  • 4. Step 1: Write test that fails • Red - Write a little test that doesn’t work, perhaps doesn’t even compile at first.
  • 5. Step 2: Make test pass • Green - Make the test work quickly, committing
  • 6. Step 3: Refactor/ Cleanup code • Refactor – Eliminate all the duplication and smells created in just getting the test to work.
  • 7. TDD Frameworks • Junit – Assert , Hamcrest • Mockito – Mockito, EasyMock, PowerMock, JMock • Stub • Mock • File • DataSet • Cucumber (BDD – Extensions of TDD) Java: • Rspec • Factorygirl • Mocha • Cucumber Ruby:
  • 8. Assertions • Assertions verify that expected conditions are met. Each assertion has different overloaded methods to accespt different parameters. • assertTrue • assertFalse • assertNull • assertNotNull • assertEquals • assertNotEquals • assertArrayEquals • assertIterableEquals • assertSame and assertNotSame • assertAll • assertThrows • assertTimeout • assertLinesMatch • fail
  • 9. Different Annotations in Junit and Jupitor JUnit4 Junit Jupitor @Before @BeforeEach @After @AfterEach @BeforeClass @BeforeAll @AfterClass @AfterAll @Ignore @Diabled @Category @Tag @RunWith @ExtendWith
  • 10. JUnit – Assert Hamcrest • Using Assert: Assert.assertEquals(“Shan”, user.firstName()); //or Using Assert static imports assertEquals(“Shan”, user.firstName()); • Using Hamcrest MatcherAssert.assertThat(user.firstName().IsEqua l.equalTo(“Shan”)); //Or Using static imports assertThat(user.firstName(), equalTo(“Shan”));
  • 11. Mockito EasyMock JMock • Methods under test often leverage dependencies • Test with dependencies created challenges • Live database needed • Multiple developers testing simultaneously • Incomplete dependency implementation • Mocking frameworks give you control • Implement the mocked functionality in a class - Tedious & Obscure • Leverage a mocking framework • Avoid class creation & Leverages the proxy pattern
  • 12. Creating Mock Instances • Mockito.mock(Class<?>class) is the core method for creating mocks • @Mock is an alternavtive • Example Class BookServiceTest { protected @Mock BookDao mockBookDao; @Before public void setup(){ MockitoAnnotations.initMocks(this); } }
  • 13. Using MockSettings • The MockSettings interface provides added control for mock creation @Test Public void test_getBookDetails { MockSettings settings = Mockito.withSettings(); BookDao mockBookDao = Mockito.mock(BookDao.class, settings); }
  • 14. Mockito • Support Unit testing Cycle • Creating the Mock BookDao mockBookDao = Mockito.mock(BookDao.class) • Setup – Method Stubbing Mockito.when(mockBookDao.findByTitle(bookTitle)).thenReturn(BookFixture) • Verification Mockito.verify(mockBookDao).findByTitle(bookTitle) Setup Execution Verification Teardown
  • 15. Mockito - Verification • Mockito.verify(..) is used to verify an intended mock operation was called • Example • Setup Mockito.when(mockBookService.getBookDeta ils(bookId)).thenReturn(bookDetail); • Verification Mockito.verify(mockBookService).getBookDet ails(bookId);
  • 16. Verification – Cont. • VerificationMode allows extra verification of the operation • Times(n) • atLeastOnce(n) • atLeast(n) • atMost(n) • Never() //setup Mockito.when(mockBookService.getBookDetails(bookId)).thenRe turn(bookDetails); //verification Mockito.verify(mockBookService, VerificationSettings.times(2)).getBookDetails(bookId); • Verifying no interactions globally • Mockito.verify(..).zeroInteractions() • Mockito.verify(..).noMoreInteactions()
  • 17. Test Fixtures • A Test fixture is a fixed state of a set of objects used as a baseline for running tests. • Ensure that there is a well known and fixed environment in which tests are run so that results are repeatable. • Type of Fixtures: • Object • Mock • Database – DataSet, Query DataSet, Replacement DataSet • Files – Excel, XML, FlatXML
  • 18. Section: 2 CI/CD&CD What is Continuous integration? What is Continuous Delivery? What is Continuos Deployment? Why do we need to use it? How do we use it? CI/CD – What are the frameworks available to do ci/cd? Demo!
  • 19. CI/CD – Cont., • Agile • Refactor • Educate Everyone • Be Small • Practice TDD Define Your CD Pipeline As Code • Have a Fast Pipeline • Consider Fixing a Failed Pipeline As Highest Priority • Run the CD Pipeline • Commit only to the Master Branch(Single branching strategy) Or (Use Short-Lived Feature Branch)
  • 20. Continuous Integration • Continuous Integration (CI) is development practice that requires developers to integrate code into a shared repository serveral times a day
  • 21. CI Principles Have a single place where all the code lives Everyone commits to the mainline every day Automate the build process - Fix the broken build immediately - Make and keep the build fast Every commit triggers a build Automate the testing process Everyone has access to the latest results Everyone can see everything
  • 22. CI Benefits: Integration takes less effort Issue will come up more early Automation means less issues The process is more visible Improved team communication Short Integration iterations means more flexibility The code is ready to be delivered more often
  • 23. What can CI Accomplish? Higher Quality Faster Delivery Lower Costs More Flexibility
  • 24. Integration High Chance of Errors(Bugs & Reworks) Defects are found late(Causing extra works) Lots of effort in integration Difficult to reproduce the release Can only release once per iteration
  • 25. Release • High Chance of Errors • Lots of effort in deployment • Difficult to reproduce deployment • Inconsistency in environments • Deployments are scary • slow delivery of functionality
  • 26. CI: Summary Continuous Integration • Integrate centrally every day • Automate • Build • Test Higher Quality Faster Delivery Lower Costs More Flexibility
  • 27. CD – Continuos Delivery • Continuous Delivery is a Software discipline where software can be released to production at any time
  • 28. Continuous Delivery QA Developers Manual Test Release Approval Operations Build Pipeline Release Pipeline SC Build Test deployCreate Test ProdOn DemandAutomated
  • 29. CD Principles Have Continuous integration in place Development and Operations should work well together Treat Infrastructure as a code artifact Automate the environment creation process Automate the release process - Automate acceptance tests Include release do definition of done Releasing should be on-demand Everyone has access to the latest result Everyone can see everything
  • 30. CD Benefits: Releasing take less effort Releasing is more - Reliable - Repeatable Put control of release in the hands of business Release more often Get feedback earlier
  • 31. What can CD Accomplish? Higher Quality Faster Delivery Lower Costs More Flexibility
  • 32. Continuous Deployment • Software is automatically deployed to production all the time.
  • 33. CD Summary Delivery != Deployment You need Continuous integration Continuous delivery - Release pipeline - Automated release - Automated acceptance tests Higher Quality Faster Delivery Lower Costs More Flexibility
  • 34. CI & CD Summary : Cont., Automate everything 1 Developers and operations work together 2 CI& CD are very Powerful 3
  • 35. CI/CD Tools: SCM – GitHub, GitLab, BitBucket, SVN, VSS CI & CD– Jenkins, Bamboo, TeamCity, Travis CI, Stash, Azure Pipeline, GC Build, Cirrus CI, Circle CI Ruby: Cloud 66 Container: Docker Platform: K8 AWS – AWS Commit, AWS Code Pipeline, AWS Deploy Cloud: AWS, GCP, Pivotal, Predix