SlideShare une entreprise Scribd logo
1  sur  27
Journey to Unit Testing : A Lesson
Learned
Avicienna Ulhaq
@noxymon
Workin’ Ground Truth!
Program testing can be used
to show the presence of
bugs, but never to show
their absence!
(Dijkstra, 1970)
Edsger W. Dijkstra (1930 - 2002)
Notes on Structured Programming, Technological
University Eindhoven
Why ?
Rotten Code
Write-Ignore-Rot
Beck, Kent. 2 Hat Of Developer
Refactoring
When you're wearing the refactoring
hat, every change you make
preservers observable behavior,
keeps the tests green, and allows you
to make many small changes without
going near a debugger.
Adding function.
When you add function, however,
things are more open ended as you
will add tests and break existing
tests. The adding function hat is
more stressful and riskier, so it's
nice to wear the refactoring hat as
much as possible.
“All code is guilty until
proven it innocent”
Key of Agile Development
The heart of Scrum is a Sprint, a time-box of one month or less during
which a "Done", useable, and potentially releasable product
Increment is created.
(Shuterland and Schwaber)
What ?
It’s a Tools
Level of Testing
Does the whole system work?
Does our code work against
code we can’t change?
Do our objects do the right
thing, are they convenient to
work with?
How ?
Single Responsibility Principle
A class should have only one reason to change.
Function Always Do One Thing
Functions should do one thing. They should do it well. They should do it only.
Abstrak
Function Always Do One Thing
VIOLATESALLOWED
Dependecy Injection
Setup of dependency, is responsibility of the caller. Not The Dependent.
OrderService
DriverOjek
+ saveTarif()
<<use>>
DB
OrderService DriverOjek
Example :
Not Testable
Testable
Mocking Tools
mock objects are simulated objects that mimic the
behavior of real objects in controlled ways
● Verify behavior
● Mimic behavior
Use the DI Trick
Verify the behavior
FIRST Principle
● [F]ast ‒ imagine, every you stroke ctrl+s
● [I]solated ‒ avoid dependency to other unit test
● [R]epeatable ‒ it’s not truth, if not constant
● [S]elf-Validating ‒ avoid manual thing: setup, verification
● [T]imely ‒ later means never
Mimic the behavior
Mimic the behavior
Right Are the results right
B Are all the boundary conditions correct
I Can you check inverse relationship
C Can you cross-check result using others means
?
E Can you force error conditions to happen ?
P Are performance characteristics within bounds
?
Right-BICEP
3 Laws of TDD*
1. You are not allowed to write any
production code unless it is to make a
failing unit test pass.
2. You are not allowed to write any more
of a unit test than is sufficient to fail;
and compilation failures are failures.
3. You are not allowed to write any more
production code than is sufficient to
pass the one failing unit test.
*iya, emang susah.
Further Reading
● Clean Code by Robert C Martin
● Pragmatic Unit Testing in Java 8 with JUnit by Jeff
Langr
● Google Clean Code Talks,
https://www.youtube.com/watch?v=wEhu57pih5w
● Three Laws of TDD,
https://www.youtube.com/watch?v=qkblc5WRn-U
● Uncle Bob Test Workshop,
https://www.youtube.com/watch?v=K7yR--yL0bc
Happy Code !

Contenu connexe

Tendances

QA Fest 2017. Jeremias Rößler. Applying AI to testing
QA Fest 2017. Jeremias Rößler. Applying AI to testingQA Fest 2017. Jeremias Rößler. Applying AI to testing
QA Fest 2017. Jeremias Rößler. Applying AI to testingQAFest
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Myeongseok Baek
 
TDD - Test Driven Dvelopment | Test First Design
TDD -  Test Driven Dvelopment | Test First DesignTDD -  Test Driven Dvelopment | Test First Design
TDD - Test Driven Dvelopment | Test First DesignQuang Nguyễn Bá
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)Foyzul Karim
 
How to push a react js application in production and sleep better
How to push a react js application in production and sleep betterHow to push a react js application in production and sleep better
How to push a react js application in production and sleep betterEmanuele Rampichini
 
Ohira icsm2012
Ohira icsm2012Ohira icsm2012
Ohira icsm2012SAIL_QU
 
Giving automated tests the love they deserve at Listings
Giving automated tests the love they deserve at ListingsGiving automated tests the love they deserve at Listings
Giving automated tests the love they deserve at ListingsJordi Pradel
 
Page Objects - You're Doing it Wrong by Titus Fortner
Page Objects - You're Doing it Wrong by Titus FortnerPage Objects - You're Doing it Wrong by Titus Fortner
Page Objects - You're Doing it Wrong by Titus FortnerSauce Labs
 
Dot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarDot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarGiel Tettelaar
 
Quality Assurance
Quality Assurance Quality Assurance
Quality Assurance Puchpa Oks
 
The art of being an agile programmer
The art of being an agile programmerThe art of being an agile programmer
The art of being an agile programmerClaudia Rosu
 
Defect life cycle
Defect life cycleDefect life cycle
Defect life cycleBapi Sahoo
 

Tendances (14)

QA Fest 2017. Jeremias Rößler. Applying AI to testing
QA Fest 2017. Jeremias Rößler. Applying AI to testingQA Fest 2017. Jeremias Rößler. Applying AI to testing
QA Fest 2017. Jeremias Rößler. Applying AI to testing
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
TDD - Test Driven Dvelopment | Test First Design
TDD -  Test Driven Dvelopment | Test First DesignTDD -  Test Driven Dvelopment | Test First Design
TDD - Test Driven Dvelopment | Test First Design
 
TDD: Facts and Fallacies
TDD: Facts and FallaciesTDD: Facts and Fallacies
TDD: Facts and Fallacies
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
 
How to push a react js application in production and sleep better
How to push a react js application in production and sleep betterHow to push a react js application in production and sleep better
How to push a react js application in production and sleep better
 
Ohira icsm2012
Ohira icsm2012Ohira icsm2012
Ohira icsm2012
 
Giving automated tests the love they deserve at Listings
Giving automated tests the love they deserve at ListingsGiving automated tests the love they deserve at Listings
Giving automated tests the love they deserve at Listings
 
Page Objects - You're Doing it Wrong by Titus Fortner
Page Objects - You're Doing it Wrong by Titus FortnerPage Objects - You're Doing it Wrong by Titus Fortner
Page Objects - You're Doing it Wrong by Titus Fortner
 
Dot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarDot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel Tettelar
 
Tdd
TddTdd
Tdd
 
Quality Assurance
Quality Assurance Quality Assurance
Quality Assurance
 
The art of being an agile programmer
The art of being an agile programmerThe art of being an agile programmer
The art of being an agile programmer
 
Defect life cycle
Defect life cycleDefect life cycle
Defect life cycle
 

Similaire à Journey to unit testing

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Test driven development
Test driven developmentTest driven development
Test driven developmentnamkha87
 
[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development
[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development
[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean DevelopmentRakuten Group, Inc.
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In ActionJon Kruger
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Babul Mirdha
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testingmarkstory
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentEffective
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentJohn Blanco
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentEffectiveUI
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012Pietro Di Bello
 

Similaire à Journey to unit testing (20)

TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development
[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development
[Rakuten TechConf2014] [G-4] Beyond Agile Testing to Lean Development
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Unit testing basic
Unit testing basicUnit testing basic
Unit testing basic
 
Unit Testing in Android
Unit Testing in AndroidUnit Testing in Android
Unit Testing in Android
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testing
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 

Plus de Scrum Day Bandung

How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...
How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...
How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...Scrum Day Bandung
 
Mob Programming: What I've been Learning from Woody Zuill - Ivan Darmawan
Mob Programming: What I've been Learning from Woody Zuill - Ivan DarmawanMob Programming: What I've been Learning from Woody Zuill - Ivan Darmawan
Mob Programming: What I've been Learning from Woody Zuill - Ivan DarmawanScrum Day Bandung
 
Journey toward Quality Assistance - Agustinus Verdy & Fachrul
Journey toward Quality Assistance - Agustinus Verdy & FachrulJourney toward Quality Assistance - Agustinus Verdy & Fachrul
Journey toward Quality Assistance - Agustinus Verdy & FachrulScrum Day Bandung
 
How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...
How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...
How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...Scrum Day Bandung
 
Unconventional HR Practices - Sky You
Unconventional HR Practices - Sky YouUnconventional HR Practices - Sky You
Unconventional HR Practices - Sky YouScrum Day Bandung
 
Escaping the Drama Triangle - Christine Anna Rumawas
Escaping the Drama Triangle - Christine Anna RumawasEscaping the Drama Triangle - Christine Anna Rumawas
Escaping the Drama Triangle - Christine Anna RumawasScrum Day Bandung
 
How to Coach Difficult People - Rendy Aries Fajrin & Raka Dipura
How to Coach Difficult People - Rendy Aries Fajrin & Raka DipuraHow to Coach Difficult People - Rendy Aries Fajrin & Raka Dipura
How to Coach Difficult People - Rendy Aries Fajrin & Raka DipuraScrum Day Bandung
 
Traits of A Successful Zombie Product Owner - Kevin Yudistira
Traits of A Successful Zombie Product Owner - Kevin YudistiraTraits of A Successful Zombie Product Owner - Kevin Yudistira
Traits of A Successful Zombie Product Owner - Kevin YudistiraScrum Day Bandung
 
Be a survivor in transition process from BA chronicle to product mastery - Ar...
Be a survivor in transition process from BA chronicle to product mastery - Ar...Be a survivor in transition process from BA chronicle to product mastery - Ar...
Be a survivor in transition process from BA chronicle to product mastery - Ar...Scrum Day Bandung
 
How to Successfully Increase Agility in Your Organization by being a Silo Mas...
How to Successfully Increase Agility in Your Organization by being a Silo Mas...How to Successfully Increase Agility in Your Organization by being a Silo Mas...
How to Successfully Increase Agility in Your Organization by being a Silo Mas...Scrum Day Bandung
 
The Secret Life of Product Owner - Linawaty Dwi Halianto
The Secret Life of Product Owner - Linawaty Dwi HaliantoThe Secret Life of Product Owner - Linawaty Dwi Halianto
The Secret Life of Product Owner - Linawaty Dwi HaliantoScrum Day Bandung
 
Enhance Your Business with Agile Contract & Procurement - Yusuf Kurniawan
Enhance Your Business with Agile Contract & Procurement  - Yusuf KurniawanEnhance Your Business with Agile Contract & Procurement  - Yusuf Kurniawan
Enhance Your Business with Agile Contract & Procurement - Yusuf KurniawanScrum Day Bandung
 
Scrum Around the World - Scrum Day Bandung
Scrum Around the World - Scrum Day BandungScrum Around the World - Scrum Day Bandung
Scrum Around the World - Scrum Day BandungScrum Day Bandung
 
Managing Technical Debt - Scrum Day Bandung
Managing Technical Debt - Scrum Day BandungManaging Technical Debt - Scrum Day Bandung
Managing Technical Debt - Scrum Day BandungScrum Day Bandung
 
Data Driven Product Management
Data Driven Product ManagementData Driven Product Management
Data Driven Product ManagementScrum Day Bandung
 
Path to Agility at DOKU - Scrum Day Bandung
Path to Agility at DOKU - Scrum Day BandungPath to Agility at DOKU - Scrum Day Bandung
Path to Agility at DOKU - Scrum Day BandungScrum Day Bandung
 
Developing the Midtrans - Scrum Day Bandung
Developing the Midtrans - Scrum Day BandungDeveloping the Midtrans - Scrum Day Bandung
Developing the Midtrans - Scrum Day BandungScrum Day Bandung
 
Fixed Price Contract is a Big Lie and Unethical - Scrum Day Bandung
Fixed Price Contract is a Big Lie and Unethical - Scrum Day BandungFixed Price Contract is a Big Lie and Unethical - Scrum Day Bandung
Fixed Price Contract is a Big Lie and Unethical - Scrum Day BandungScrum Day Bandung
 
BCA Executive Agile - Scrum Day Bandung
BCA Executive Agile - Scrum Day BandungBCA Executive Agile - Scrum Day Bandung
BCA Executive Agile - Scrum Day BandungScrum Day Bandung
 

Plus de Scrum Day Bandung (19)

How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...
How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...
How (can) Scrum and DevOps Walk Together to Build a High-Quality Product Deli...
 
Mob Programming: What I've been Learning from Woody Zuill - Ivan Darmawan
Mob Programming: What I've been Learning from Woody Zuill - Ivan DarmawanMob Programming: What I've been Learning from Woody Zuill - Ivan Darmawan
Mob Programming: What I've been Learning from Woody Zuill - Ivan Darmawan
 
Journey toward Quality Assistance - Agustinus Verdy & Fachrul
Journey toward Quality Assistance - Agustinus Verdy & FachrulJourney toward Quality Assistance - Agustinus Verdy & Fachrul
Journey toward Quality Assistance - Agustinus Verdy & Fachrul
 
How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...
How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...
How Crucial a Performance Appraisal Practice Inside the Self-organizing Team?...
 
Unconventional HR Practices - Sky You
Unconventional HR Practices - Sky YouUnconventional HR Practices - Sky You
Unconventional HR Practices - Sky You
 
Escaping the Drama Triangle - Christine Anna Rumawas
Escaping the Drama Triangle - Christine Anna RumawasEscaping the Drama Triangle - Christine Anna Rumawas
Escaping the Drama Triangle - Christine Anna Rumawas
 
How to Coach Difficult People - Rendy Aries Fajrin & Raka Dipura
How to Coach Difficult People - Rendy Aries Fajrin & Raka DipuraHow to Coach Difficult People - Rendy Aries Fajrin & Raka Dipura
How to Coach Difficult People - Rendy Aries Fajrin & Raka Dipura
 
Traits of A Successful Zombie Product Owner - Kevin Yudistira
Traits of A Successful Zombie Product Owner - Kevin YudistiraTraits of A Successful Zombie Product Owner - Kevin Yudistira
Traits of A Successful Zombie Product Owner - Kevin Yudistira
 
Be a survivor in transition process from BA chronicle to product mastery - Ar...
Be a survivor in transition process from BA chronicle to product mastery - Ar...Be a survivor in transition process from BA chronicle to product mastery - Ar...
Be a survivor in transition process from BA chronicle to product mastery - Ar...
 
How to Successfully Increase Agility in Your Organization by being a Silo Mas...
How to Successfully Increase Agility in Your Organization by being a Silo Mas...How to Successfully Increase Agility in Your Organization by being a Silo Mas...
How to Successfully Increase Agility in Your Organization by being a Silo Mas...
 
The Secret Life of Product Owner - Linawaty Dwi Halianto
The Secret Life of Product Owner - Linawaty Dwi HaliantoThe Secret Life of Product Owner - Linawaty Dwi Halianto
The Secret Life of Product Owner - Linawaty Dwi Halianto
 
Enhance Your Business with Agile Contract & Procurement - Yusuf Kurniawan
Enhance Your Business with Agile Contract & Procurement  - Yusuf KurniawanEnhance Your Business with Agile Contract & Procurement  - Yusuf Kurniawan
Enhance Your Business with Agile Contract & Procurement - Yusuf Kurniawan
 
Scrum Around the World - Scrum Day Bandung
Scrum Around the World - Scrum Day BandungScrum Around the World - Scrum Day Bandung
Scrum Around the World - Scrum Day Bandung
 
Managing Technical Debt - Scrum Day Bandung
Managing Technical Debt - Scrum Day BandungManaging Technical Debt - Scrum Day Bandung
Managing Technical Debt - Scrum Day Bandung
 
Data Driven Product Management
Data Driven Product ManagementData Driven Product Management
Data Driven Product Management
 
Path to Agility at DOKU - Scrum Day Bandung
Path to Agility at DOKU - Scrum Day BandungPath to Agility at DOKU - Scrum Day Bandung
Path to Agility at DOKU - Scrum Day Bandung
 
Developing the Midtrans - Scrum Day Bandung
Developing the Midtrans - Scrum Day BandungDeveloping the Midtrans - Scrum Day Bandung
Developing the Midtrans - Scrum Day Bandung
 
Fixed Price Contract is a Big Lie and Unethical - Scrum Day Bandung
Fixed Price Contract is a Big Lie and Unethical - Scrum Day BandungFixed Price Contract is a Big Lie and Unethical - Scrum Day Bandung
Fixed Price Contract is a Big Lie and Unethical - Scrum Day Bandung
 
BCA Executive Agile - Scrum Day Bandung
BCA Executive Agile - Scrum Day BandungBCA Executive Agile - Scrum Day Bandung
BCA Executive Agile - Scrum Day Bandung
 

Dernier

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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 productivityPrincipled Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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.pdfsudhanshuwaghmare1
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Dernier (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Journey to unit testing

  • 1. Journey to Unit Testing : A Lesson Learned Avicienna Ulhaq @noxymon
  • 3. Program testing can be used to show the presence of bugs, but never to show their absence! (Dijkstra, 1970) Edsger W. Dijkstra (1930 - 2002) Notes on Structured Programming, Technological University Eindhoven
  • 6. Beck, Kent. 2 Hat Of Developer Refactoring When you're wearing the refactoring hat, every change you make preservers observable behavior, keeps the tests green, and allows you to make many small changes without going near a debugger. Adding function. When you add function, however, things are more open ended as you will add tests and break existing tests. The adding function hat is more stressful and riskier, so it's nice to wear the refactoring hat as much as possible.
  • 7. “All code is guilty until proven it innocent”
  • 8. Key of Agile Development The heart of Scrum is a Sprint, a time-box of one month or less during which a "Done", useable, and potentially releasable product Increment is created. (Shuterland and Schwaber)
  • 11. Level of Testing Does the whole system work? Does our code work against code we can’t change? Do our objects do the right thing, are they convenient to work with?
  • 12. How ?
  • 13. Single Responsibility Principle A class should have only one reason to change.
  • 14. Function Always Do One Thing Functions should do one thing. They should do it well. They should do it only. Abstrak
  • 15. Function Always Do One Thing VIOLATESALLOWED
  • 16. Dependecy Injection Setup of dependency, is responsibility of the caller. Not The Dependent. OrderService DriverOjek + saveTarif() <<use>> DB OrderService DriverOjek
  • 18. Mocking Tools mock objects are simulated objects that mimic the behavior of real objects in controlled ways ● Verify behavior ● Mimic behavior
  • 19. Use the DI Trick
  • 21. FIRST Principle ● [F]ast ‒ imagine, every you stroke ctrl+s ● [I]solated ‒ avoid dependency to other unit test ● [R]epeatable ‒ it’s not truth, if not constant ● [S]elf-Validating ‒ avoid manual thing: setup, verification ● [T]imely ‒ later means never
  • 24. Right Are the results right B Are all the boundary conditions correct I Can you check inverse relationship C Can you cross-check result using others means ? E Can you force error conditions to happen ? P Are performance characteristics within bounds ? Right-BICEP
  • 25. 3 Laws of TDD* 1. You are not allowed to write any production code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test. *iya, emang susah.
  • 26. Further Reading ● Clean Code by Robert C Martin ● Pragmatic Unit Testing in Java 8 with JUnit by Jeff Langr ● Google Clean Code Talks, https://www.youtube.com/watch?v=wEhu57pih5w ● Three Laws of TDD, https://www.youtube.com/watch?v=qkblc5WRn-U ● Uncle Bob Test Workshop, https://www.youtube.com/watch?v=K7yR--yL0bc

Notes de l'éditeur

  1. Untuk mencapai poin [F]ast ‒ imagine, every you stroke ctrl+s [I]solated ‒ avoid dependency to other unit test [R]epeatable ‒ it’s not truth, if not constant, Dibutuhkan other skills of mocking : mimic bheavior
  2. Untuk melakukan mimic beheavior, mockito menyediakan static function when().thenreturn().
  3. So, out test will be like :
  4. boundary conditions : error json inverse relationship : For mathematic computations, this is often the case: you can verify division with multiplication, addition with subtraction, and so on. cross-check result using others means : pembukuan di akunting, atau order di amount oracle sama postgre force error conditions : throw expection using mock performance characteristics : profiling test
  5. Conformance : email format Ordering :