SlideShare ist ein Scribd-Unternehmen logo
1 von 36
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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
CI/CD Overview
CI/CD OverviewCI/CD Overview
CI/CD Overview
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
 
Continuous Integration, Build Pipelines and Continuous Deployment
Continuous Integration, Build Pipelines and Continuous DeploymentContinuous Integration, Build Pipelines and Continuous Deployment
Continuous Integration, Build Pipelines and Continuous Deployment
 
CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with Jenkins
 
DevOps Overview in my own words
DevOps Overview in my own wordsDevOps Overview in my own words
DevOps Overview in my own words
 
Introduction to DevOps. Continuous Integration by Myroslav Dmytrus
Introduction to DevOps. Continuous Integration by Myroslav Dmytrus Introduction to DevOps. Continuous Integration by Myroslav Dmytrus
Introduction to DevOps. Continuous Integration by Myroslav Dmytrus
 
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
 
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
 
SAFe and DevOps - better together
SAFe and DevOps - better togetherSAFe and DevOps - better together
SAFe and DevOps - better together
 
Continuous Delivery Maturity Model
Continuous Delivery Maturity ModelContinuous Delivery Maturity Model
Continuous Delivery Maturity Model
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins Introduction
 
CI CD Basics
CI CD BasicsCI CD Basics
CI CD Basics
 
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
DevOps or DevSecOps
DevOps or DevSecOpsDevOps or DevSecOps
DevOps or DevSecOps
 
Testing in Agile Development
Testing in Agile DevelopmentTesting in Agile Development
Testing in Agile Development
 
devops
devops devops
devops
 
Cypress testing
Cypress testingCypress testing
Cypress testing
 

Ähnlich wie Test Driven Development & CI/CD

SanDiego_DevOps_Meetup_9212016-v8
SanDiego_DevOps_Meetup_9212016-v8SanDiego_DevOps_Meetup_9212016-v8
SanDiego_DevOps_Meetup_9212016-v8
Rajwinder Singh
 
SanDiego_DevOps_Meetup_9212016
SanDiego_DevOps_Meetup_9212016SanDiego_DevOps_Meetup_9212016
SanDiego_DevOps_Meetup_9212016
w2fong
 
Continuous deployment steve povilaitis
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitis
Steve Povilaitis
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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