SlideShare a Scribd company logo
1 of 19
Download to read offline
Unit Testing 
By Mohamad Asmar a.k.a DaiGooR
Me! 
Mohamed AsmerDeveloper 
daigoor@gmail.com 
www.daigoor.com@daigoor 
(+970) 598 917 280
Developer life ! 
the more pressure you feel, the fewer tests you writes. The fewer tests you write, the less productive you are and the less stable your code becomes. The less productive and accurate you are, the more pressure you feel.
Def. 
Wikipedia :unit testingis asoftware testingmethod by which individual units ofsource code 
In a simple way … validate each and every unit of the software perform as designed.
Def. Cont. 
A Unit is the smallest part of code 
›{function or procedure} 
›The smallest part that can be compiled by it self.
Ex 
public int stringToInt( String str ){ return Integer.parseInt(str); } 
stringToInt(null); 
stringToInt(“TEXT”) 
stringToInt(“1234567890987654321”)
Why ? 
Without it defects will appear at the end of the cycle! 
Trace bugs is time consuming , hard and complex 
Check new feature if they are feasible 
Check input and output values 
Correct outputs fast
Why ? -_- 
Reduce future cost ! 
Faster development 
Better design 
Faster debugging 
Excellent regression tool + 
it provide sort of documentation
Categories 
White-Box : function exe and checked 
Black-Box : input/output & app-interface
Types 
Positive test (end user testing) 
›Valid parameter 
Negative test 
›Not valid parameter
Ex 
public int stringToInt( String str ){ return Integer.parseInt(str); } 
stringToInt(null)//N 
stringToInt(“TEXT”)//N 
stringToInt(“1234567890987654321”)//N 
stringToInt(“1234”)//P
When to write the test? 
“Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead.”...
story 
:$
Traditional Testing Strategies 
Print Statements 
Use of Debugger 
Debugger Expressions
Ex. 
... List<?> getVersionsForProductId(Long id){ … return List<?> } 
The Tests That AreNeeded 
Startingfromtheeasiesttothehardest: 
Ifthere’snoproductforthatid,thenanexceptionisthrown. 
Ifthere’snoversionsforavalidproductid,thenanemptylistisreturned. 
Ifthereareversionsforaproductid,thenanon-emptylistofalltheversionsisreturned.
Live Show 
Eclipse 
IntelliJ Idea
Keep Unit tests small and fast We should run them after each checkin 
keep them UN-dependent They should not depend on each other 
They should be simple 
Fix error immediately
Its all about unit There should be a test class per each class .. no more no less ! You should not right an application to test another application. 
Start with the simple test 
Code convention

More Related Content

What's hot

03 conditions loops
03   conditions loops03   conditions loops
03 conditions loopsManzoor ALam
 
Introduction to unit testing in python
Introduction to unit testing in pythonIntroduction to unit testing in python
Introduction to unit testing in pythonAnirudh
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With PythonSiddhi
 
Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingMike Clement
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentalscbcunc
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummiesHarry Potter
 
White Box Testing (Introduction to)
White Box Testing (Introduction to)White Box Testing (Introduction to)
White Box Testing (Introduction to)Henry Muccini
 
Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Timo Stollenwerk
 
JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...
JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...
JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...Andrzej Jóźwiak
 
Control structures in java
Control structures in javaControl structures in java
Control structures in javaVINOTH R
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaRavikiran J
 

What's hot (19)

07 flow control
07   flow control07   flow control
07 flow control
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
 
Introduction to unit testing in python
Introduction to unit testing in pythonIntroduction to unit testing in python
Introduction to unit testing in python
 
Md04 flow control
Md04 flow controlMd04 flow control
Md04 flow control
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With Python
 
Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit Testing
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
 
Unit testing 101
Unit testing 101Unit testing 101
Unit testing 101
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Java Control Statements
Java Control StatementsJava Control Statements
Java Control Statements
 
Golang dot-testing-lite
Golang dot-testing-liteGolang dot-testing-lite
Golang dot-testing-lite
 
White Box Testing (Introduction to)
White Box Testing (Introduction to)White Box Testing (Introduction to)
White Box Testing (Introduction to)
 
Template Method Design Pattern
Template Method Design PatternTemplate Method Design Pattern
Template Method Design Pattern
 
Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...
 
JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...
JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...
JUnit 4 Can it still teach us something? - Andrzej Jóźwiak - Kariera IT Łodź ...
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Exception handling in python
Exception handling in pythonException handling in python
Exception handling in python
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran Janardhana
 

Viewers also liked

Rotation & Revolution
Rotation & RevolutionRotation & Revolution
Rotation & Revolutionkmacdevitt
 
Andrea Bocelli..
Andrea Bocelli..Andrea Bocelli..
Andrea Bocelli..RoThia
 
Aula revoluo russa editora moderna
Aula revoluo russa editora modernaAula revoluo russa editora moderna
Aula revoluo russa editora modernasesi8
 
Pedacinhos da minha vida
Pedacinhos da minha vidaPedacinhos da minha vida
Pedacinhos da minha vidaluciana2808
 
Mrs Jackson's Sight Words for Thanksgiving
Mrs Jackson's Sight Words for ThanksgivingMrs Jackson's Sight Words for Thanksgiving
Mrs Jackson's Sight Words for ThanksgivingLee Kraus
 
Little Ann Predicament
Little Ann PredicamentLittle Ann Predicament
Little Ann Predicamentjeanslover1225
 
S1170009 final-stage5
S1170009 final-stage5S1170009 final-stage5
S1170009 final-stage5s1170009
 
Assis, m tu, só tu, puro amor
Assis, m   tu, só tu, puro amorAssis, m   tu, só tu, puro amor
Assis, m tu, só tu, puro amorNicolas Pelicioni
 
My Fake Grandma Rocks
My Fake Grandma RocksMy Fake Grandma Rocks
My Fake Grandma Rocksnzyvonne
 
Portifolio 2
Portifolio 2Portifolio 2
Portifolio 2ongplay
 
Optimal regulatory regime and competition
Optimal regulatory regime and competitionOptimal regulatory regime and competition
Optimal regulatory regime and competitionanucrawfordphd
 
2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte 7 - 8b ...
2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte  7 - 8b ...2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte  7 - 8b ...
2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte 7 - 8b ...O Ciclista
 

Viewers also liked (20)

Rotation & Revolution
Rotation & RevolutionRotation & Revolution
Rotation & Revolution
 
Andrea Bocelli..
Andrea Bocelli..Andrea Bocelli..
Andrea Bocelli..
 
Aula revoluo russa editora moderna
Aula revoluo russa editora modernaAula revoluo russa editora moderna
Aula revoluo russa editora moderna
 
Pedacinhos da minha vida
Pedacinhos da minha vidaPedacinhos da minha vida
Pedacinhos da minha vida
 
Mrs Jackson's Sight Words for Thanksgiving
Mrs Jackson's Sight Words for ThanksgivingMrs Jackson's Sight Words for Thanksgiving
Mrs Jackson's Sight Words for Thanksgiving
 
Samba enredo
Samba enredoSamba enredo
Samba enredo
 
Little Ann Predicament
Little Ann PredicamentLittle Ann Predicament
Little Ann Predicament
 
S1170009 final-stage5
S1170009 final-stage5S1170009 final-stage5
S1170009 final-stage5
 
Voluntarios ceara
Voluntarios cearaVoluntarios ceara
Voluntarios ceara
 
Animais
AnimaisAnimais
Animais
 
Assis, m tu, só tu, puro amor
Assis, m   tu, só tu, puro amorAssis, m   tu, só tu, puro amor
Assis, m tu, só tu, puro amor
 
Decreto n° 3994-A
Decreto n° 3994-ADecreto n° 3994-A
Decreto n° 3994-A
 
O Presente
O PresenteO Presente
O Presente
 
Rádio
RádioRádio
Rádio
 
La biblia y la ciencia
La biblia y la cienciaLa biblia y la ciencia
La biblia y la ciencia
 
My Fake Grandma Rocks
My Fake Grandma RocksMy Fake Grandma Rocks
My Fake Grandma Rocks
 
Amor e luz
Amor e luzAmor e luz
Amor e luz
 
Portifolio 2
Portifolio 2Portifolio 2
Portifolio 2
 
Optimal regulatory regime and competition
Optimal regulatory regime and competitionOptimal regulatory regime and competition
Optimal regulatory regime and competition
 
2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte 7 - 8b ...
2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte  7 - 8b ...2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte  7 - 8b ...
2014 09-04 - ler aprender gn 3 ceb - vencedor - ups - beatriz duarte 7 - 8b ...
 

Similar to Unit testing

DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)Steve Upton
 
Software Testing for Data Scientists
Software Testing for Data ScientistsSoftware Testing for Data Scientists
Software Testing for Data ScientistsAjay Ohri
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingMax Kleiner
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Babul Mirdha
 
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
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testingdn
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testingmalcolmt
 
[XCode] Automating UI Testing
[XCode] Automating UI Testing[XCode] Automating UI Testing
[XCode] Automating UI TestingPhineas Huang
 
Unit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of PurityUnit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of PurityVictor Rentea
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Testing - Is This Even a Thing?
Testing - Is This Even a Thing?Testing - Is This Even a Thing?
Testing - Is This Even a Thing?Nick George
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkHumberto Marchezi
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
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
 
Mutation Testing: Testing your tests
Mutation Testing: Testing your testsMutation Testing: Testing your tests
Mutation Testing: Testing your testsStephen Leigh
 
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,..."Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...Vladimir Ivanov
 

Similar to Unit testing (20)

DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Software Testing for Data Scientists
Software Testing for Data ScientistsSoftware Testing for Data Scientists
Software Testing for Data Scientists
 
maXbox Starter 36 Software Testing
maXbox Starter 36 Software TestingmaXbox Starter 36 Software Testing
maXbox Starter 36 Software Testing
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testing
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testing
 
[XCode] Automating UI Testing
[XCode] Automating UI Testing[XCode] Automating UI Testing
[XCode] Automating UI Testing
 
Unit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of PurityUnit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of Purity
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Testing - Is This Even a Thing?
Testing - Is This Even a Thing?Testing - Is This Even a Thing?
Testing - Is This Even a Thing?
 
Tdd in practice
Tdd in practiceTdd in practice
Tdd in practice
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing Framework
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Mutation Testing: Testing your tests
Mutation Testing: Testing your testsMutation Testing: Testing your tests
Mutation Testing: Testing your tests
 
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,..."Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 

Recently uploaded (20)

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 

Unit testing

  • 1. Unit Testing By Mohamad Asmar a.k.a DaiGooR
  • 2. Me! Mohamed AsmerDeveloper daigoor@gmail.com www.daigoor.com@daigoor (+970) 598 917 280
  • 3. Developer life ! the more pressure you feel, the fewer tests you writes. The fewer tests you write, the less productive you are and the less stable your code becomes. The less productive and accurate you are, the more pressure you feel.
  • 4. Def. Wikipedia :unit testingis asoftware testingmethod by which individual units ofsource code In a simple way … validate each and every unit of the software perform as designed.
  • 5. Def. Cont. A Unit is the smallest part of code ›{function or procedure} ›The smallest part that can be compiled by it self.
  • 6. Ex public int stringToInt( String str ){ return Integer.parseInt(str); } stringToInt(null); stringToInt(“TEXT”) stringToInt(“1234567890987654321”)
  • 7. Why ? Without it defects will appear at the end of the cycle! Trace bugs is time consuming , hard and complex Check new feature if they are feasible Check input and output values Correct outputs fast
  • 8. Why ? -_- Reduce future cost ! Faster development Better design Faster debugging Excellent regression tool + it provide sort of documentation
  • 9.
  • 10. Categories White-Box : function exe and checked Black-Box : input/output & app-interface
  • 11. Types Positive test (end user testing) ›Valid parameter Negative test ›Not valid parameter
  • 12. Ex public int stringToInt( String str ){ return Integer.parseInt(str); } stringToInt(null)//N stringToInt(“TEXT”)//N stringToInt(“1234567890987654321”)//N stringToInt(“1234”)//P
  • 13. When to write the test? “Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead.”...
  • 15. Traditional Testing Strategies Print Statements Use of Debugger Debugger Expressions
  • 16. Ex. ... List<?> getVersionsForProductId(Long id){ … return List<?> } The Tests That AreNeeded Startingfromtheeasiesttothehardest: Ifthere’snoproductforthatid,thenanexceptionisthrown. Ifthere’snoversionsforavalidproductid,thenanemptylistisreturned. Ifthereareversionsforaproductid,thenanon-emptylistofalltheversionsisreturned.
  • 17. Live Show Eclipse IntelliJ Idea
  • 18. Keep Unit tests small and fast We should run them after each checkin keep them UN-dependent They should not depend on each other They should be simple Fix error immediately
  • 19. Its all about unit There should be a test class per each class .. no more no less ! You should not right an application to test another application. Start with the simple test Code convention