SlideShare a Scribd company logo
Unit Testing
이규원
gyuwon@tidcorp.com
gyuwon@live.com
www.facebook.com/gyuwon.yi
“Know the rules well, so you can break them effectively.”
- Dalai Lama XIV
Automated Testing
Software Regression
“A software bug which makes
a feature stop functioning as
intended after a certain event”
- Wikipedia
R1 R2 R3 R4
SOFTWARE
Features
Costs
Manual(Quality Assurance) Automated
>
Reliability
Manual(Quality Assurance) Automated
<
Arrange
Act
Assert
Cleanup
DEMO
Automated UI Testing
Continuous Integration
“Many, including me, consider that CI without testing is not CI at all.”
- The Architecture Journal, January 2008 by Munjal Budhabhatti
Continuous Build
Continuous Integration
Automated Testing
Unit Tests
Horizontal Separation
Layer D
Layer C
Layer B
Layer A
Functional Testing(Vertical Separation)
SystemUnderTest
Layer D
Layer C
Layer B
Layer A
SystemUnderTest
Layer D
Layer C
Layer B
Layer A
SystemUnderTest
Layer D
Layer C
Layer B
Layer A
Function 1 Function 2 Function 3
*Integration Testing
Layer D
Layer C
Layer B
Layer A
SystemUnderTest
System Under Test
System Under Test
Unit Testing
Layer D
Layer C
Layer B
Layer A System Under Test
System Under Test
System Under Test
System Under Test
Unit Testing
• Fast
• Reliable
• Isolate failures
Test Doubles
Layer D
Layer C
Test Double for Layer B
Layer A
System Under Test
Inversion of Control
“Don't call us, we'll call you.”
Dependency Inversion
A Layer C depends on a Layer B
A Layer C creates a Layer B A Layer C requests a Layer B
Constructor Injection
public class LayerC
{
private LayerB _layerB;
public LayerC()
{
_layerB = new LayerB();
}
}
public class LayerC
{
private LayerB _layerB;
public LayerC(LayerB layerB)
{
_layerB = layerB;
}
}
<< created >>
<< injected >>
*Interface
public interface ILayerB
{
}
public class LayerB : ILayerB
{
}
public class LayerC
{
private ILayerB _layerB;
public LayerC(ILayerB layerB)
{
_layerB = layerB;
}
}
Test Double
The replacement of a real depended-on component
for testing purposes
Test Doubles
Dummy
Stubs
Spies
Mocks
Fake
Passed but never used
Provide canned answers
Record information
Verify expectations
Have working implementations
but not suitable for production
DEMO
Stubs and Mocks
Myth Busting for
Test-Driven Development
Automated testing
TDD
Automated testing with high coverage
TDD
Writing the tests first
TDD
?
Test-Driven Development
Test-Driven Development
Test
Development
TESTS
MAKETH
CODE
Red
GreenRefactor
Write production code
If the test
fails
If all tests
succeed
Clean up code
Write a test
yes
yes
no
no
repeat
DEMO
Test-Driven Development

More Related Content

Similar to Unit testing

testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2
Dr. Ahmed Al Zaidy
 
Software testing
Software testingSoftware testing
Software testing
MohdVais1
 
Testing concepts
Testing conceptsTesting concepts
Testing concepts
sangamesh kumbar
 
Testing ppt
Testing pptTesting ppt
Testing ppt
kiran theja
 
Software Development Life Cycle Testingtypes
Software Development Life Cycle TestingtypesSoftware Development Life Cycle Testingtypes
Software Development Life Cycle Testingtypes
vladimir zaremba
 
CTFL Module 02
CTFL Module 02CTFL Module 02
CTFL Module 02
Davis Thomas
 
V and v model
V and v modelV and v model
V and v model
lokareminakshi
 
Software Testing
Software Testing Software Testing
Software Testing
CHANDAN CHATURVEDI
 
Basic Guide to Manual Testing
Basic Guide to Manual TestingBasic Guide to Manual Testing
Basic Guide to Manual Testing
Hiral Gosani
 
Mobile testing in the cloud
Mobile testing in the cloudMobile testing in the cloud
Mobile testing in the cloud
Diaconu Andrei-Tudor
 
Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...
Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...
Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...
Riccardo Coppola
 
Software Testing
Software TestingSoftware Testing
Software Testing
Abhishek Saxena
 
Fundamentals of software testing
Fundamentals of software testingFundamentals of software testing
Fundamentals of software testing
Noha Gamal
 
Software Testing Foundations Part 2 - Testing in Software Lifecycle
Software Testing Foundations Part 2 - Testing in Software LifecycleSoftware Testing Foundations Part 2 - Testing in Software Lifecycle
Software Testing Foundations Part 2 - Testing in Software Lifecycle
Nikita Knysh
 
Real Time software Training in Nagercoil
Real Time software Training in NagercoilReal Time software Training in Nagercoil
Real Time software Training in Nagercoil
jclick2
 
Android testing part i
Android testing part iAndroid testing part i
Android testing part i
Kan-Han (John) Lu
 
Slides1 - testing
Slides1 - testingSlides1 - testing
Slides1 - testing
Jyothi Vbs
 
IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...
IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...
IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...
IRJET Journal
 
Testing Throughout the Software Life Cycle - Section 2
Testing Throughout the Software Life Cycle - Section 2Testing Throughout the Software Life Cycle - Section 2
Testing Throughout the Software Life Cycle - Section 2
International Personal Finance Plc
 
Pengujian Sistem WebGIS
Pengujian Sistem WebGISPengujian Sistem WebGIS
Pengujian Sistem WebGIS
Dany Laksono
 

Similar to Unit testing (20)

testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2
 
Software testing
Software testingSoftware testing
Software testing
 
Testing concepts
Testing conceptsTesting concepts
Testing concepts
 
Testing ppt
Testing pptTesting ppt
Testing ppt
 
Software Development Life Cycle Testingtypes
Software Development Life Cycle TestingtypesSoftware Development Life Cycle Testingtypes
Software Development Life Cycle Testingtypes
 
CTFL Module 02
CTFL Module 02CTFL Module 02
CTFL Module 02
 
V and v model
V and v modelV and v model
V and v model
 
Software Testing
Software Testing Software Testing
Software Testing
 
Basic Guide to Manual Testing
Basic Guide to Manual TestingBasic Guide to Manual Testing
Basic Guide to Manual Testing
 
Mobile testing in the cloud
Mobile testing in the cloudMobile testing in the cloud
Mobile testing in the cloud
 
Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...
Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...
Automated Generation, Evolution and Maintenance: a perspective for mobile GUI...
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Fundamentals of software testing
Fundamentals of software testingFundamentals of software testing
Fundamentals of software testing
 
Software Testing Foundations Part 2 - Testing in Software Lifecycle
Software Testing Foundations Part 2 - Testing in Software LifecycleSoftware Testing Foundations Part 2 - Testing in Software Lifecycle
Software Testing Foundations Part 2 - Testing in Software Lifecycle
 
Real Time software Training in Nagercoil
Real Time software Training in NagercoilReal Time software Training in Nagercoil
Real Time software Training in Nagercoil
 
Android testing part i
Android testing part iAndroid testing part i
Android testing part i
 
Slides1 - testing
Slides1 - testingSlides1 - testing
Slides1 - testing
 
IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...
IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...
IRJET - A Valuable and Speculative Approach to Manage the Item Testing by usi...
 
Testing Throughout the Software Life Cycle - Section 2
Testing Throughout the Software Life Cycle - Section 2Testing Throughout the Software Life Cycle - Section 2
Testing Throughout the Software Life Cycle - Section 2
 
Pengujian Sistem WebGIS
Pengujian Sistem WebGISPengujian Sistem WebGIS
Pengujian Sistem WebGIS
 

More from Gyuwon Yi

Event sourcing spring camp 2017.public
Event sourcing spring camp 2017.publicEvent sourcing spring camp 2017.public
Event sourcing spring camp 2017.public
Gyuwon Yi
 
Why you always fail with tdd
Why you always fail with tddWhy you always fail with tdd
Why you always fail with tdd
Gyuwon Yi
 
CQRS - Show me the code
CQRS - Show me the codeCQRS - Show me the code
CQRS - Show me the code
Gyuwon Yi
 
CQRS
CQRSCQRS
CQRS
Gyuwon Yi
 
프로그래밍, 설계 그리고 패턴
프로그래밍, 설계 그리고 패턴프로그래밍, 설계 그리고 패턴
프로그래밍, 설계 그리고 패턴
Gyuwon Yi
 
VSTS와 Azure를 이용한 팀 프로세스 관리
VSTS와 Azure를 이용한 팀 프로세스 관리VSTS와 Azure를 이용한 팀 프로세스 관리
VSTS와 Azure를 이용한 팀 프로세스 관리
Gyuwon Yi
 
Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기
Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기
Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기
Gyuwon Yi
 
Xamarin Forms, MVVM and Testing
Xamarin Forms, MVVM and TestingXamarin Forms, MVVM and Testing
Xamarin Forms, MVVM and Testing
Gyuwon Yi
 
Introduction to IoC Container
Introduction to IoC ContainerIntroduction to IoC Container
Introduction to IoC Container
Gyuwon Yi
 
Introduction to TPL
Introduction to TPLIntroduction to TPL
Introduction to TPL
Gyuwon Yi
 

More from Gyuwon Yi (10)

Event sourcing spring camp 2017.public
Event sourcing spring camp 2017.publicEvent sourcing spring camp 2017.public
Event sourcing spring camp 2017.public
 
Why you always fail with tdd
Why you always fail with tddWhy you always fail with tdd
Why you always fail with tdd
 
CQRS - Show me the code
CQRS - Show me the codeCQRS - Show me the code
CQRS - Show me the code
 
CQRS
CQRSCQRS
CQRS
 
프로그래밍, 설계 그리고 패턴
프로그래밍, 설계 그리고 패턴프로그래밍, 설계 그리고 패턴
프로그래밍, 설계 그리고 패턴
 
VSTS와 Azure를 이용한 팀 프로세스 관리
VSTS와 Azure를 이용한 팀 프로세스 관리VSTS와 Azure를 이용한 팀 프로세스 관리
VSTS와 Azure를 이용한 팀 프로세스 관리
 
Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기
Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기
Azure를 이용한 Join 없는 글로벌 분산 시스템 설계하기
 
Xamarin Forms, MVVM and Testing
Xamarin Forms, MVVM and TestingXamarin Forms, MVVM and Testing
Xamarin Forms, MVVM and Testing
 
Introduction to IoC Container
Introduction to IoC ContainerIntroduction to IoC Container
Introduction to IoC Container
 
Introduction to TPL
Introduction to TPLIntroduction to TPL
Introduction to TPL
 

Recently uploaded

Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
narinav14
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
confluent
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
Zycus
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Luigi Fugaro
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
OnePlan Solutions
 

Recently uploaded (20)

Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
Voxxed Days Trieste 2024 - Unleashing the Power of Vector Search and Semantic...
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
 

Unit testing