SlideShare a Scribd company logo
1 of 57
Download to read offline
Introduction to Test Driven
Development (TDD)
Ahmed MISBAH
06/02/2021
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
A little about me
• Software Architect
• Speaker at:
– Java Developer Conference
– Google Developer Group
– Africa and Middle East Conference
on Software Engineering
– DevOpsDays Cairo
– Orange DevTest Days
A little about me
• Degrees and Certifications:
– BSc. and MSc. Degree in Computer Science
– Sun Certified Enterprise Java Architect, Java
Developer, Mobile Developer, Web
Developer, Webservice Developer
– Oracle Certified Expert - JPA Developer
– Certified Scrum Master
– AWS Solution Architect - Associate
• Topics of interest:
– Agile and Lean
– DevOps
– Java
– Software Architecture
– Aviation
– Astronomy and space travel
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Shift-left Mindset
Shift-left Mindset
“Most defects end up costing more than it would
have cost to prevent them. Defects are expensive
when they occur, both the direct costs of fixing
the defects and the indirect costs because of
damaged relationships, lost business, and lost
development time.”
Kent Beck, Extreme Programming Explained
Shift-left Mindset
Shift-left Mindset
Shift-left Mindset
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Lean Thinking
Lean (SWD or Manufacturing) is a systematic method in
which the core idea is to maximize customer value while
minimizing waste
• Value is everything that your customer is willing to pay
money for
• Waste is any action or step in a process that does not
add value to the customer. In other words, waste is any
process that the customer does not want to pay for
• Muda ("non-value-adding work")
o Type 1: A non-value-added activity for an end customer but it is
necessary. It is targeted to minimize this type of wastage
o Type 2: A non-value-added activity for an end customer which is
not necessary. It is targeted to eliminate this type of wastage
Types of waste in Lean
Waste Type Production Software Development
Transport
Moving parts and materials
from one place to another
Task switching, interruptions,
handoffs
Inventory Undelivered products or parts
Undelivered code. Undelivered
features (i.e., partially done
work)
Motion
Unnecessary movement of the
worker
Unnecessary meetings, extra
effort to find information
Waiting Waiting Waiting (i.e., delays)
Overproduction Too many parts Features nobody uses
Over-processing
Spending a lot of time on a
given task
Unnecessary complex
algorithms solving simple
problems, manual tests (i.e.,
repeating the repeated)
Defects Broken parts Bugs
Poke-Yoke
• It’s a quality assurance process introduced by Japanese
engineer Shigeo Shingo. This term is used in the Japanese
language as “Poka” meaning mistake and “Yoke” meaning
prevent i.e., mistake preventing or mistake-proofing
technique.
• The purpose of Poka-Yoke is to develop processes to reduce
defects by avoiding or correcting (design to show alerts or
warning messages to the user) mistakes in early design and
development phases. This technique is mostly used in
manufacturing industries but now this effective technique
is also adapted to software development processes as well.
Poke-Yoke
Defect Detection vs. Prevention
• Test-devices were designed to inexpensively check if a
product was defective. Poka-yoke tests were inexpensive,
repeatable and reliable. They could be given to workers on
the manufacturing line, to check a product straight after
they make it.
• Checking at the source, rather than on the end, was one of
the most important ideas described by Shigeo Shingo in his
book on Zero Quality Control. Mary Poppendieck often
comments on those ideas that ‘inspection to find defects is
waste, inspection to prevent defects is essential’. That is
basically what test-driven development is all about.
To sum up….
Shift-left mindset and Poke-Yoke promote the idea
of testing early to:
1. Prevent defects rather than inspect for defects
2. Reduce the cost of fixing defects
3. Build your product to meet quality standards and
functional requirements (i.e., mistake-proof design)
And here comes TDD!
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
What is TDD?
• Test-Driven Development (TDD) is a software
development process relying on software
requirements being converted to test
cases before software is fully developed
• This is opposed to software being developed
first and test cases created and executed later
• Kent Beck is credited with having developed
or 'rediscovered’ the technique
Rediscovering TDD
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
How to do TDD?
How to do TDD?
The three laws of TDD
• First Law: You may not write production code
until you have written a failing unit test.
• Second Law: You may not write more of a unit
test than is sufficient to fail, and not compiling
is failing.
• Third Law: You may not write more
production code than is sufficient to pass the
currently failing test.
TDD and eXtreme Programming
• Testing in XP:
– All code must have unit tests
– All code must pass all unit tests before it can be
released.
– When a bug is found tests are created before the
bug is addressed (a bug is not an error in logic, it is
a test that was not written)
– Acceptance tests are run often, and the results are
published
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
What is a Test Case?
A test case is a specification of the inputs,
execution conditions, testing procedure, and
expected results that define a single test to be
executed
Test Case ID Test Case
Description
Prerequisites Test Steps Test Data Expected Results Actual Results Pass/Fail
TC01 Check
Customer
Login with
valid Data
Customer data
exists in the
DB
1. Go to
site
2. Enter
UserId
3. Enter
Passwor
d
4. Click
Submit
• Email
address =
ahmed
• Password =
1234
User should login
to the application
As expected Pass
How do we derive Test Cases?
Test Design Techniques
Black-box Techniques
• Boundary Value Analysis
• Equivalence Partitioning
• Decision Tables
• State Transition
• Pairwise Testing
• Use case Testing
Code Design
• TDD can also stand for Test Driven Design
• Use the Russian design philosophy
“Nakayanki”, that translates as "working with
a piece of paper on your knee"
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Advantges of TDD
1. Better software design and higher code quality
2. Detailed code documentation
3. Code flexibility and easier maintenance
4. You get a reliable solution
5. More courage!
6. Continous testing to find injected bugs
7. Time required for project development is
reduced
8. Save project costs in the long run
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Test Structure
1) Setup: Put the Unit Under Test (UUT) or the overall test
system (SUT) in the state needed to run the test.
2) Execution: Trigger/drive the UUT to perform the target
behavior and capture all output, such as return values and
output parameters.
3) Validation/Verification: Ensure the results of the test are
correct. These results may include explicit outputs
captured during execution or state changes in the UUT.
This step is also known as Assertion in some test
frameworks.
4) Cleanup: Restore the UUT or the SUT to the pre-test state.
This restoration permits another test to execute
immediately after this one. In some cases, in order to
preserve the information for possible test failure analysis
the cleanup should be starting the test just before the
test's setup run
F.I.R.S.T Rules
• Fast Tests should be fast. They should run quickly. When tests run
slow, you won’t want to run them frequently. If you don’t run them
frequently, you won’t find problems early enough to fix them easily.
You won’t feel as free to clean up the code. Eventually the code will
begin to rot.
• Independent Tests should not depend on each other. One test
should not set up the conditions for the next test. You should be
able to run each test independently and run the tests in any order
you like. When tests depend on each other, then the first one to fail
causes a cascade of downstream failures, making diagnosis difficult
and hiding downstream defects.
• Repeatable Tests should be repeatable in any environment. You
should be able to run the tests in the production environment, in
the QA environment, and on your laptop while riding home on the
train without a network. If your tests aren’t repeatable in any
environment, then you’ll always have an excuse for why they fail.
You’ll also find yourself unable to run the tests when the
environment isn’t available.
F.I.R.S.T Rules
• Self-Validating The tests should have a boolean output.
Either they pass or fail. You should not have to read
through a log file to tell whether the tests pass. You should
not have to manually compare two different text files to
see whether the tests pass. If the tests aren’t self-
validating, then failure can become subjective and running
the tests can require a long manual evaluation.
• Timely The tests need to be written in a timely fashion.
Unit tests should be written just before the production
code that makes them pass. If you write tests after the
production code, then you may find the production code to
be hard to test. You may decide that some production code
is too hard to test. You may not design the production code
to be testable.
Use GWT notation
The Given-When-Then formula is a template intended to guide the
writing of acceptance tests for a User Story:
• Given - Describes the preconditions and initial state before the start
of a test and allows for any pre-test setup that may occur
• When - Describes actions taken by a user during a test
• Then - Describes the outcome resulting from actions taken in the
When clause
An example:
• Given my bank account is in credit, and I made no withdrawals
recently,
• When I attempt to withdraw an amount less than my card’s limit,
• Then the withdrawal should complete without errors or warnings
Other best practices
1. Don’t treat test code as a second-class citizen
2. One assertion per test (disputable)
3. Single Concept per Test
4. Fake it till you make it (using mocks, stubs,
simulators, spies and dummies)
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
String Sum - User Story
As a user
I want to add two real numbers in string format
So that I would see their sum
Acceptance Criteria:
• A real number is any number >=0
• A real number is a number with no decimals
• My method should take two strings as an input and return a
long value as output
• My method should throw an error in case a non real number
is provided
String Sum – Test Design
Black-box test techniques that can be used:
o Boundary Value Analysis
o Equivalence Partitioning
o Decision Tables
String Sum – Decision Table
Rules String a String b Output
Add two strings that
are real numbers
10 150 160
Add two strings that
are real numbers at
their boundaries
0
9,223,372,036,854,775
,807
9,223,372,036,854,775
,807
Add two strings that
are real numbers that
start with zero
015 015 30
Add two strings with
one number that is
negative
-1 5 Error
Add two strings with
one number that has a
decimal
0.5 15 Error
Add two strings with
one value as
characters
aaaaa 55 Error
Let’s code!
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Test Automation Pyramid
Test Automation Pyramid
Code Coverage
Agenda
1. A little about me
2. Introduction (Why?)
o Shift-left mindset
o Lean Thinking, Waste and Poke-Yoke
3. Test Driven Development (What and how?)
o What is TDD?
o How to do TDD?
o Deriving Test cases and Code Design
o Advantages of TDD
o Best Practices
4. Workshop – String Sum Kata
5. Advanced TDD
o Test Automation Pyramid
o Applying TDD in a multi-layer application
Spring Boot Application Structure
Spring Boot Application
Spring MVC - Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Some Data store or
queue
An External API
Unit Tests
Spring MVC - Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities (Mock)
Unit tests Service (Mock)
Data Store (Stub)
Unit tests
Unit tests
Repository (Mock)
Unit Tests
• Unit tests will run in CI server
• Tests will be part of the Spring Boot application
• jUnit 5 or TestNG can be used
• Mockito can be used for mocking
• Controller tests will use @WebMvcTest annotation:
https://reflectoring.io/spring-boot-web-controller-test/
• Repository tests will use @DataTestJPA annotation, which
implicitly used H2 and tests ORM as well:
https://reflectoring.io/spring-boot-data-jpa-test/
• Liquibase will be used to create schemas at the start of
each test class
• Sprint @Sql annotation will be used to remove and insert
data before each test case:
https://www.javarticles.com/2016/02/spring-sql-annotation-
example.html
Component Tests
Spring MVC - Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Component tests
Data Store (Stub)
Web server (Stub)
Component Tests
• Component tests will run in CI server
• Tests will be part of the Spring Boot
application
• jUnit 5 or TestNG can be used
• Tests will use @SpringBootTest annotation
• REST/SOAP APIs will be stubbed using
WireMock, Mock Server or Postman:
https://www.baeldung.com/introduction-to-
wiremock
Component Tests
• MySQL will be stubbed using H2
• Liquibase will be used to create schemas at
the start of each test class
• Sprint @Sql annotation will be used to remove
and insert data before each test case:
https://www.javarticles.com/2016/02/spring-
sql-annotation-example.html
Thank You!
https://twitter.com/AhmedMisbahTech https://www.linkedin.com/in/ahmed-misbah-msc-251a3a32/ https://www.youtube.com/channel/UCZxEBqvA1fGKLusLwoadf_w
References

More Related Content

What's hot

Software Testing Overview
Software Testing OverviewSoftware Testing Overview
Software Testing OverviewHawkman Academy
 
Scrum Plus Extreme Programming (XP) for Hyper Productivity
Scrum Plus Extreme Programming (XP) for Hyper ProductivityScrum Plus Extreme Programming (XP) for Hyper Productivity
Scrum Plus Extreme Programming (XP) for Hyper ProductivityRon Quartel
 
(Agile) engineering best practices - What every project manager should know
(Agile) engineering best practices - What every project manager should know(Agile) engineering best practices - What every project manager should know
(Agile) engineering best practices - What every project manager should knowRichard Cheng
 
Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоSigma Software
 
Global Day of Coderetreat'14 - Istanbul Event
Global Day of Coderetreat'14 - Istanbul EventGlobal Day of Coderetreat'14 - Istanbul Event
Global Day of Coderetreat'14 - Istanbul EventLemi Orhan Ergin
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Jason Tice
 
Agile and test driven development
Agile and test driven developmentAgile and test driven development
Agile and test driven developmentAhmed El-Deeb
 
2 anton muzhailo - team development techniques you must know to be a valuab...
2   anton muzhailo - team development techniques you must know to be a valuab...2   anton muzhailo - team development techniques you must know to be a valuab...
2 anton muzhailo - team development techniques you must know to be a valuab...Ievgenii Katsan
 
Quality Jam: BDD, TDD and ATDD for the Enterprise
Quality Jam: BDD, TDD and ATDD for the EnterpriseQuality Jam: BDD, TDD and ATDD for the Enterprise
Quality Jam: BDD, TDD and ATDD for the EnterpriseQASymphony
 
Extreme Programming
Extreme ProgrammingExtreme Programming
Extreme ProgrammingKnoldus Inc.
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for TestingSQALab
 
Engineering practices within scrum
Engineering practices within scrumEngineering practices within scrum
Engineering practices within scrumSoftServe
 
GMO'less Software Development Practices
GMO'less Software Development PracticesGMO'less Software Development Practices
GMO'less Software Development PracticesLemi Orhan Ergin
 
Presentation of agile engineering practices
Presentation of agile engineering practicesPresentation of agile engineering practices
Presentation of agile engineering practicesRoberto Bettazzoni
 

What's hot (20)

Software Testing Overview
Software Testing OverviewSoftware Testing Overview
Software Testing Overview
 
Scrum Plus Extreme Programming (XP) for Hyper Productivity
Scrum Plus Extreme Programming (XP) for Hyper ProductivityScrum Plus Extreme Programming (XP) for Hyper Productivity
Scrum Plus Extreme Programming (XP) for Hyper Productivity
 
(Agile) engineering best practices - What every project manager should know
(Agile) engineering best practices - What every project manager should know(Agile) engineering best practices - What every project manager should know
(Agile) engineering best practices - What every project manager should know
 
Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон Мужайло
 
Career path in IT
Career path in IT  Career path in IT
Career path in IT
 
What is Agile Testing?
What is Agile Testing? What is Agile Testing?
What is Agile Testing?
 
New model
New modelNew model
New model
 
Global Day of Coderetreat'14 - Istanbul Event
Global Day of Coderetreat'14 - Istanbul EventGlobal Day of Coderetreat'14 - Istanbul Event
Global Day of Coderetreat'14 - Istanbul Event
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
 
Agile and test driven development
Agile and test driven developmentAgile and test driven development
Agile and test driven development
 
2 anton muzhailo - team development techniques you must know to be a valuab...
2   anton muzhailo - team development techniques you must know to be a valuab...2   anton muzhailo - team development techniques you must know to be a valuab...
2 anton muzhailo - team development techniques you must know to be a valuab...
 
Quality Jam: BDD, TDD and ATDD for the Enterprise
Quality Jam: BDD, TDD and ATDD for the EnterpriseQuality Jam: BDD, TDD and ATDD for the Enterprise
Quality Jam: BDD, TDD and ATDD for the Enterprise
 
Extreme Programming
Extreme ProgrammingExtreme Programming
Extreme Programming
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for Testing
 
Engineering practices within scrum
Engineering practices within scrumEngineering practices within scrum
Engineering practices within scrum
 
GMO'less Software Development Practices
GMO'less Software Development PracticesGMO'less Software Development Practices
GMO'less Software Development Practices
 
Presentation of agile engineering practices
Presentation of agile engineering practicesPresentation of agile engineering practices
Presentation of agile engineering practices
 
DevTestOps
DevTestOpsDevTestOps
DevTestOps
 
Kku2011
Kku2011Kku2011
Kku2011
 
Pair Programming
Pair ProgrammingPair Programming
Pair Programming
 

Similar to Introduction to TDD

When develpment met test(shift left testing)
When develpment met test(shift left testing)When develpment met test(shift left testing)
When develpment met test(shift left testing)SangIn Choung
 
TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012Alan Christensen
 
TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)Ahmed Misbah
 
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Perfecto Mobile
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)Peter Kofler
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentMichael Denomy
 
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)Nacho Cougil
 
10 Lessons learned in test automation
10 Lessons learned in test automation10 Lessons learned in test automation
10 Lessons learned in test automationRomania Testing
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentSiva Arunachalam
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia eventXebia India
 
Test-Driven Development in the Corporate Workplace
Test-Driven Development in the Corporate WorkplaceTest-Driven Development in the Corporate Workplace
Test-Driven Development in the Corporate WorkplaceAhmed Owian
 

Similar to Introduction to TDD (20)

TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
When develpment met test(shift left testing)
When develpment met test(shift left testing)When develpment met test(shift left testing)
When develpment met test(shift left testing)
 
TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012
 
TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)
 
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
tem7
tem7tem7
tem7
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Tdd
TddTdd
Tdd
 
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
 
Agile Practices
Agile PracticesAgile Practices
Agile Practices
 
10 Lessons learned in test automation
10 Lessons learned in test automation10 Lessons learned in test automation
10 Lessons learned in test automation
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia event
 
Test-Driven Development in the Corporate Workplace
Test-Driven Development in the Corporate WorkplaceTest-Driven Development in the Corporate Workplace
Test-Driven Development in the Corporate Workplace
 

More from Ahmed Misbah

6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)Ahmed Misbah
 
Migrating to Microservices Patterns and Technologies (edition 2023)
 Migrating to Microservices Patterns and Technologies (edition 2023) Migrating to Microservices Patterns and Technologies (edition 2023)
Migrating to Microservices Patterns and Technologies (edition 2023)Ahmed Misbah
 
Practical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfPractical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfAhmed Misbah
 
Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Ahmed Misbah
 
DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)Ahmed Misbah
 
Implementing FaaS on Kubernetes using Kubeless
Implementing FaaS on Kubernetes using KubelessImplementing FaaS on Kubernetes using Kubeless
Implementing FaaS on Kubernetes using KubelessAhmed Misbah
 
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Ahmed Misbah
 
DevOps for absolute beginners
DevOps for absolute beginnersDevOps for absolute beginners
DevOps for absolute beginnersAhmed Misbah
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioAhmed Misbah
 
Cucumber jvm best practices v3
Cucumber jvm best practices v3Cucumber jvm best practices v3
Cucumber jvm best practices v3Ahmed Misbah
 
Welcome to the Professional World
Welcome to the Professional WorldWelcome to the Professional World
Welcome to the Professional WorldAhmed Misbah
 
More topics on Java
More topics on JavaMore topics on Java
More topics on JavaAhmed Misbah
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story WritingAhmed Misbah
 
Software Architecture
Software ArchitectureSoftware Architecture
Software ArchitectureAhmed Misbah
 
The Road to DevOps V3
The Road to DevOps V3The Road to DevOps V3
The Road to DevOps V3Ahmed Misbah
 
How Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous DeliveryHow Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous DeliveryAhmed Misbah
 
Theory of alienation in the software industry
Theory of alienation in the software industryTheory of alienation in the software industry
Theory of alienation in the software industryAhmed Misbah
 

More from Ahmed Misbah (19)

6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)
 
Migrating to Microservices Patterns and Technologies (edition 2023)
 Migrating to Microservices Patterns and Technologies (edition 2023) Migrating to Microservices Patterns and Technologies (edition 2023)
Migrating to Microservices Patterns and Technologies (edition 2023)
 
Practical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfPractical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdf
 
Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)
 
DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)
 
Implementing FaaS on Kubernetes using Kubeless
Implementing FaaS on Kubernetes using KubelessImplementing FaaS on Kubernetes using Kubeless
Implementing FaaS on Kubernetes using Kubeless
 
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
 
DevOps for absolute beginners
DevOps for absolute beginnersDevOps for absolute beginners
DevOps for absolute beginners
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and Istio
 
Cucumber jvm best practices v3
Cucumber jvm best practices v3Cucumber jvm best practices v3
Cucumber jvm best practices v3
 
Welcome to the Professional World
Welcome to the Professional WorldWelcome to the Professional World
Welcome to the Professional World
 
More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story Writing
 
AndGen+
AndGen+AndGen+
AndGen+
 
Big Data for QAs
Big Data for QAsBig Data for QAs
Big Data for QAs
 
Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
 
The Road to DevOps V3
The Road to DevOps V3The Road to DevOps V3
The Road to DevOps V3
 
How Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous DeliveryHow Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous Delivery
 
Theory of alienation in the software industry
Theory of alienation in the software industryTheory of alienation in the software industry
Theory of alienation in the software industry
 

Recently uploaded

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 

Recently uploaded (20)

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 

Introduction to TDD

  • 1. Introduction to Test Driven Development (TDD) Ahmed MISBAH 06/02/2021
  • 2. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 3. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 4. A little about me • Software Architect • Speaker at: – Java Developer Conference – Google Developer Group – Africa and Middle East Conference on Software Engineering – DevOpsDays Cairo – Orange DevTest Days
  • 5. A little about me • Degrees and Certifications: – BSc. and MSc. Degree in Computer Science – Sun Certified Enterprise Java Architect, Java Developer, Mobile Developer, Web Developer, Webservice Developer – Oracle Certified Expert - JPA Developer – Certified Scrum Master – AWS Solution Architect - Associate • Topics of interest: – Agile and Lean – DevOps – Java – Software Architecture – Aviation – Astronomy and space travel
  • 6. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 8. Shift-left Mindset “Most defects end up costing more than it would have cost to prevent them. Defects are expensive when they occur, both the direct costs of fixing the defects and the indirect costs because of damaged relationships, lost business, and lost development time.” Kent Beck, Extreme Programming Explained
  • 12. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 13. Lean Thinking Lean (SWD or Manufacturing) is a systematic method in which the core idea is to maximize customer value while minimizing waste • Value is everything that your customer is willing to pay money for • Waste is any action or step in a process that does not add value to the customer. In other words, waste is any process that the customer does not want to pay for • Muda ("non-value-adding work") o Type 1: A non-value-added activity for an end customer but it is necessary. It is targeted to minimize this type of wastage o Type 2: A non-value-added activity for an end customer which is not necessary. It is targeted to eliminate this type of wastage
  • 14. Types of waste in Lean Waste Type Production Software Development Transport Moving parts and materials from one place to another Task switching, interruptions, handoffs Inventory Undelivered products or parts Undelivered code. Undelivered features (i.e., partially done work) Motion Unnecessary movement of the worker Unnecessary meetings, extra effort to find information Waiting Waiting Waiting (i.e., delays) Overproduction Too many parts Features nobody uses Over-processing Spending a lot of time on a given task Unnecessary complex algorithms solving simple problems, manual tests (i.e., repeating the repeated) Defects Broken parts Bugs
  • 15. Poke-Yoke • It’s a quality assurance process introduced by Japanese engineer Shigeo Shingo. This term is used in the Japanese language as “Poka” meaning mistake and “Yoke” meaning prevent i.e., mistake preventing or mistake-proofing technique. • The purpose of Poka-Yoke is to develop processes to reduce defects by avoiding or correcting (design to show alerts or warning messages to the user) mistakes in early design and development phases. This technique is mostly used in manufacturing industries but now this effective technique is also adapted to software development processes as well.
  • 17. Defect Detection vs. Prevention • Test-devices were designed to inexpensively check if a product was defective. Poka-yoke tests were inexpensive, repeatable and reliable. They could be given to workers on the manufacturing line, to check a product straight after they make it. • Checking at the source, rather than on the end, was one of the most important ideas described by Shigeo Shingo in his book on Zero Quality Control. Mary Poppendieck often comments on those ideas that ‘inspection to find defects is waste, inspection to prevent defects is essential’. That is basically what test-driven development is all about.
  • 18. To sum up…. Shift-left mindset and Poke-Yoke promote the idea of testing early to: 1. Prevent defects rather than inspect for defects 2. Reduce the cost of fixing defects 3. Build your product to meet quality standards and functional requirements (i.e., mistake-proof design) And here comes TDD!
  • 19. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 20. What is TDD? • Test-Driven Development (TDD) is a software development process relying on software requirements being converted to test cases before software is fully developed • This is opposed to software being developed first and test cases created and executed later • Kent Beck is credited with having developed or 'rediscovered’ the technique
  • 22. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 23. How to do TDD?
  • 24. How to do TDD?
  • 25. The three laws of TDD • First Law: You may not write production code until you have written a failing unit test. • Second Law: You may not write more of a unit test than is sufficient to fail, and not compiling is failing. • Third Law: You may not write more production code than is sufficient to pass the currently failing test.
  • 26. TDD and eXtreme Programming • Testing in XP: – All code must have unit tests – All code must pass all unit tests before it can be released. – When a bug is found tests are created before the bug is addressed (a bug is not an error in logic, it is a test that was not written) – Acceptance tests are run often, and the results are published
  • 27. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 28. What is a Test Case? A test case is a specification of the inputs, execution conditions, testing procedure, and expected results that define a single test to be executed
  • 29. Test Case ID Test Case Description Prerequisites Test Steps Test Data Expected Results Actual Results Pass/Fail TC01 Check Customer Login with valid Data Customer data exists in the DB 1. Go to site 2. Enter UserId 3. Enter Passwor d 4. Click Submit • Email address = ahmed • Password = 1234 User should login to the application As expected Pass
  • 30. How do we derive Test Cases? Test Design Techniques Black-box Techniques • Boundary Value Analysis • Equivalence Partitioning • Decision Tables • State Transition • Pairwise Testing • Use case Testing
  • 31. Code Design • TDD can also stand for Test Driven Design • Use the Russian design philosophy “Nakayanki”, that translates as "working with a piece of paper on your knee"
  • 32. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 33. Advantges of TDD 1. Better software design and higher code quality 2. Detailed code documentation 3. Code flexibility and easier maintenance 4. You get a reliable solution 5. More courage! 6. Continous testing to find injected bugs 7. Time required for project development is reduced 8. Save project costs in the long run
  • 34. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 35. Test Structure 1) Setup: Put the Unit Under Test (UUT) or the overall test system (SUT) in the state needed to run the test. 2) Execution: Trigger/drive the UUT to perform the target behavior and capture all output, such as return values and output parameters. 3) Validation/Verification: Ensure the results of the test are correct. These results may include explicit outputs captured during execution or state changes in the UUT. This step is also known as Assertion in some test frameworks. 4) Cleanup: Restore the UUT or the SUT to the pre-test state. This restoration permits another test to execute immediately after this one. In some cases, in order to preserve the information for possible test failure analysis the cleanup should be starting the test just before the test's setup run
  • 36. F.I.R.S.T Rules • Fast Tests should be fast. They should run quickly. When tests run slow, you won’t want to run them frequently. If you don’t run them frequently, you won’t find problems early enough to fix them easily. You won’t feel as free to clean up the code. Eventually the code will begin to rot. • Independent Tests should not depend on each other. One test should not set up the conditions for the next test. You should be able to run each test independently and run the tests in any order you like. When tests depend on each other, then the first one to fail causes a cascade of downstream failures, making diagnosis difficult and hiding downstream defects. • Repeatable Tests should be repeatable in any environment. You should be able to run the tests in the production environment, in the QA environment, and on your laptop while riding home on the train without a network. If your tests aren’t repeatable in any environment, then you’ll always have an excuse for why they fail. You’ll also find yourself unable to run the tests when the environment isn’t available.
  • 37. F.I.R.S.T Rules • Self-Validating The tests should have a boolean output. Either they pass or fail. You should not have to read through a log file to tell whether the tests pass. You should not have to manually compare two different text files to see whether the tests pass. If the tests aren’t self- validating, then failure can become subjective and running the tests can require a long manual evaluation. • Timely The tests need to be written in a timely fashion. Unit tests should be written just before the production code that makes them pass. If you write tests after the production code, then you may find the production code to be hard to test. You may decide that some production code is too hard to test. You may not design the production code to be testable.
  • 38. Use GWT notation The Given-When-Then formula is a template intended to guide the writing of acceptance tests for a User Story: • Given - Describes the preconditions and initial state before the start of a test and allows for any pre-test setup that may occur • When - Describes actions taken by a user during a test • Then - Describes the outcome resulting from actions taken in the When clause An example: • Given my bank account is in credit, and I made no withdrawals recently, • When I attempt to withdraw an amount less than my card’s limit, • Then the withdrawal should complete without errors or warnings
  • 39. Other best practices 1. Don’t treat test code as a second-class citizen 2. One assertion per test (disputable) 3. Single Concept per Test 4. Fake it till you make it (using mocks, stubs, simulators, spies and dummies)
  • 40. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 41. String Sum - User Story As a user I want to add two real numbers in string format So that I would see their sum Acceptance Criteria: • A real number is any number >=0 • A real number is a number with no decimals • My method should take two strings as an input and return a long value as output • My method should throw an error in case a non real number is provided
  • 42. String Sum – Test Design Black-box test techniques that can be used: o Boundary Value Analysis o Equivalence Partitioning o Decision Tables
  • 43. String Sum – Decision Table Rules String a String b Output Add two strings that are real numbers 10 150 160 Add two strings that are real numbers at their boundaries 0 9,223,372,036,854,775 ,807 9,223,372,036,854,775 ,807 Add two strings that are real numbers that start with zero 015 015 30 Add two strings with one number that is negative -1 5 Error Add two strings with one number that has a decimal 0.5 15 Error Add two strings with one value as characters aaaaa 55 Error
  • 45. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 49. Agenda 1. A little about me 2. Introduction (Why?) o Shift-left mindset o Lean Thinking, Waste and Poke-Yoke 3. Test Driven Development (What and how?) o What is TDD? o How to do TDD? o Deriving Test cases and Code Design o Advantages of TDD o Best Practices 4. Workshop – String Sum Kata 5. Advanced TDD o Test Automation Pyramid o Applying TDD in a multi-layer application
  • 50. Spring Boot Application Structure Spring Boot Application Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Some Data store or queue An External API
  • 51. Unit Tests Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities (Mock) Unit tests Service (Mock) Data Store (Stub) Unit tests Unit tests Repository (Mock)
  • 52. Unit Tests • Unit tests will run in CI server • Tests will be part of the Spring Boot application • jUnit 5 or TestNG can be used • Mockito can be used for mocking • Controller tests will use @WebMvcTest annotation: https://reflectoring.io/spring-boot-web-controller-test/ • Repository tests will use @DataTestJPA annotation, which implicitly used H2 and tests ORM as well: https://reflectoring.io/spring-boot-data-jpa-test/ • Liquibase will be used to create schemas at the start of each test class • Sprint @Sql annotation will be used to remove and insert data before each test case: https://www.javarticles.com/2016/02/spring-sql-annotation- example.html
  • 53. Component Tests Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Component tests Data Store (Stub) Web server (Stub)
  • 54. Component Tests • Component tests will run in CI server • Tests will be part of the Spring Boot application • jUnit 5 or TestNG can be used • Tests will use @SpringBootTest annotation • REST/SOAP APIs will be stubbed using WireMock, Mock Server or Postman: https://www.baeldung.com/introduction-to- wiremock
  • 55. Component Tests • MySQL will be stubbed using H2 • Liquibase will be used to create schemas at the start of each test class • Sprint @Sql annotation will be used to remove and insert data before each test case: https://www.javarticles.com/2016/02/spring- sql-annotation-example.html