SlideShare a Scribd company logo
1 of 18
Download to read offline
1
Object Oriented Testing
Chapter 23
Click here to review SW Testing Strategies
2
OO Testing
• Class Testing: Equivalent to unit testing for
conventional SW.
– The concept of a unit changes in the OO context.
– The class or object is the smallest testable unit.
– Testing must focus on each method of the class and the
state behavior of the class.
– It is important to consider the state of the class because this
will effect the behavior, methods, of the class.
– It is often difficult to determine the state of the object.
• You may have to introduce new methods to look at the state
variables for testing purposes.
3
OO Class Testing Example
• A bank account class.
– It may have methods to open the account, deposit
funds, withdraw funds and close the account.
– The states of the account include
• open with positive balance,
• open with negative or zero balance and
• closed.
– How the methods behave depends on the state of
the account.
• An account with a zero or negative balance will not allow
the customer to withdraw funds.
• If positive it might allow customer to go to overdraft once.
• You could introduce a new method to determine the if the
account is open or closed and if balance is positive.
4
OO Testing
• Integration Testing: Because OO SW
does not have a hierarchical control
structure, conventional top-down or
bottom-up integration strategies are not
applicable.
5
Two approaches for OO
Integration testing
• Thread-based testing-
– integrate the set of classes required to respond to
one input or event of the system.
– Each thread is integrated and tested individually.
• Use-based testing –
– first construct and test the classes which use very
few (if any) server classes (these are called the
independent classes).
– The next step is to test the next layer of classes,
the dependent classes, that use the independent
classes.
6
Validation Testing
• Conventional black-box testing derived
from the analysis model can be used to
test the OO software.
• Use cases are a good place to look
when developing test cases.
7
Test cases and the Class
hierarchy
• Methods that are redefined in a subclass
must be tested because it represents a new
design and new code.
• Methods that are inherited must also be
tested.
– A subset of the original tests can be executed to
ensure it works in the derived class.
8
• Random Testing: When a variety of
different operation sequences are
randomly generated.
– Keep in mind the behavior life sequence of
the class.
9
• Partition testing: Very similar to
equivalence class partitioning for conventional
SW. Partition the input and output of the class
and design test cases to exercise each class.
• 3 Examples:
– State-based
– Attribute-based
– Category-based
10
• State-based partitioning:
– Look at the states for the class.
– Determine which operations change the
state of the class and which do not and
design test cases to exercise the class.
– Test each method, while object is in each
state.
– Design test cases to do this.
11
• Attribute-based partitioning:
– Look at the attributes of the class.
– Partition methods into those that use the
attribute, modify it and those that do not
use it.
– Design test cases for each partition.
12
• Category-based partitioning:
– Look at the methods for the class.
– Partition the methods into categories
based on their function.
– Examples:
• initialization operations, computational, queries
and termination operations.
– Design test cases for each partition
13
Student Registration Example
• A student registration class.
– The methods include adding a class, dropping a
class, transferring to a different section of the
class and list classes.
– A student must first be registered with the
university (opened as a student).
– Holds can be placed on a student and this effects
whether he/she can register for a class.
– There are limits on how many credit hours a
student may register for.
– A student may graduate (close a student).
14
Student Registration Example
• Random testing may generate:
– register, add class, transfer, add class,
drop class, add class, hold, release hold,
add class, …
15
Student Registration Example
• State-based partitioning :
– States:
• Registered
• Hold
• Full Load
• Partial Load
• Freedom
– Events:
• Register, Add, Drop, List, transfer, Hold,Release,
Graduate
– Added methods:
• Display Hold
• Display credits
16
OO Test Case Design
• Given the differences between conventional
and OO SW, test case design is slightly
different.
• OO test cases should be defined in the
following way:
– Each test case should be uniquely identified and associated
with the class to be tested.
– The purpose of the test should be stated.
– The following list should be developed for each test:
1. List of object states to be tested.
2. List of messages and operations (methods) to be tested
3. List of exceptions that may occur as the object is tested.
4. List of external conditions (think about system testing) that
may change.
• Anything else needed for the test?
17
OO Test Case Design
• Instead of testing each component, you will
test each class.
• Make sure you identify the class you are
testing.
• You must test each method, in each state for
the class.
– This information will be included in the
purpose/condition.
• If needed, add methods to check state of the
object.
– You could use the result of these methods in your
expected outcome.
18
Click to go to SW Metrics

More Related Content

Similar to Class10_OO_Testing.pdf

LPP application and problem formulation
LPP application and problem formulationLPP application and problem formulation
LPP application and problem formulation
Karishma Chaudhary
 
Mt s11 test_design
Mt s11 test_designMt s11 test_design
Mt s11 test_design
TestingGeeks
 
<p>Software Testing</p>
<p>Software Testing</p><p>Software Testing</p>
<p>Software Testing</p>
Atul Mishra
 
An overview to Software Testing
An overview to Software TestingAn overview to Software Testing
An overview to Software Testing
Atul Mishra
 

Similar to Class10_OO_Testing.pdf (20)

DIFFERENT TYPE OF EDUCATIONAL MEASUREMENT AND EVALUATION TOOLS AND THEIR IMPO...
DIFFERENT TYPE OF EDUCATIONAL MEASUREMENT AND EVALUATION TOOLS AND THEIR IMPO...DIFFERENT TYPE OF EDUCATIONAL MEASUREMENT AND EVALUATION TOOLS AND THEIR IMPO...
DIFFERENT TYPE OF EDUCATIONAL MEASUREMENT AND EVALUATION TOOLS AND THEIR IMPO...
 
41_experimental_ research.pptx
41_experimental_ research.pptx41_experimental_ research.pptx
41_experimental_ research.pptx
 
Chapter24
Chapter24Chapter24
Chapter24
 
types of testing with descriptions and examples
types of testing with descriptions and examplestypes of testing with descriptions and examples
types of testing with descriptions and examples
 
The Do's and Don'ts of Testing in Blackboard: Creating and Publishing your As...
The Do's and Don'ts of Testing in Blackboard: Creating and Publishing your As...The Do's and Don'ts of Testing in Blackboard: Creating and Publishing your As...
The Do's and Don'ts of Testing in Blackboard: Creating and Publishing your As...
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Cross validation.pptx
Cross validation.pptxCross validation.pptx
Cross validation.pptx
 
Test Construction
Test ConstructionTest Construction
Test Construction
 
Stages of test development 2
Stages of test development 2Stages of test development 2
Stages of test development 2
 
researchdesign2018-180826053804.pptx
researchdesign2018-180826053804.pptxresearchdesign2018-180826053804.pptx
researchdesign2018-180826053804.pptx
 
Experimental designs
Experimental designsExperimental designs
Experimental designs
 
LPP application and problem formulation
LPP application and problem formulationLPP application and problem formulation
LPP application and problem formulation
 
Mt s11 test_design
Mt s11 test_designMt s11 test_design
Mt s11 test_design
 
Chap02
Chap02Chap02
Chap02
 
<p>Software Testing</p>
<p>Software Testing</p><p>Software Testing</p>
<p>Software Testing</p>
 
An overview to Software Testing
An overview to Software TestingAn overview to Software Testing
An overview to Software Testing
 
Resarch design
Resarch designResarch design
Resarch design
 
classfeb24.ppt
classfeb24.pptclassfeb24.ppt
classfeb24.ppt
 
classfeb24.ppt
classfeb24.pptclassfeb24.ppt
classfeb24.ppt
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 

More from AamirMaqsood8

More from AamirMaqsood8 (20)

DEEPLEARNING recurrent neural networs.pdf
DEEPLEARNING recurrent neural networs.pdfDEEPLEARNING recurrent neural networs.pdf
DEEPLEARNING recurrent neural networs.pdf
 
WIRELESSPPT.pptx
WIRELESSPPT.pptxWIRELESSPPT.pptx
WIRELESSPPT.pptx
 
Activation Function.pptx
Activation Function.pptxActivation Function.pptx
Activation Function.pptx
 
12th.pptx
12th.pptx12th.pptx
12th.pptx
 
Research Methodology3_Measurement.pptx
Research Methodology3_Measurement.pptxResearch Methodology3_Measurement.pptx
Research Methodology3_Measurement.pptx
 
iram,sadaf.pptx
iram,sadaf.pptxiram,sadaf.pptx
iram,sadaf.pptx
 
Research Methodology2.pptx
Research Methodology2.pptxResearch Methodology2.pptx
Research Methodology2.pptx
 
LOSTANDFOUND.pptx
LOSTANDFOUND.pptxLOSTANDFOUND.pptx
LOSTANDFOUND.pptx
 
BARRIER.pptx
BARRIER.pptxBARRIER.pptx
BARRIER.pptx
 
HPA.pptx
HPA.pptxHPA.pptx
HPA.pptx
 
Unit2-RM.pptx
Unit2-RM.pptxUnit2-RM.pptx
Unit2-RM.pptx
 
2202cukmr01.pptx
2202cukmr01.pptx2202cukmr01.pptx
2202cukmr01.pptx
 
Research Methodology_Intro.pptx
Research Methodology_Intro.pptxResearch Methodology_Intro.pptx
Research Methodology_Intro.pptx
 
sdnppt-140325015756-phpapp01.pptx
sdnppt-140325015756-phpapp01.pptxsdnppt-140325015756-phpapp01.pptx
sdnppt-140325015756-phpapp01.pptx
 
Computer-Networks.pptx
Computer-Networks.pptxComputer-Networks.pptx
Computer-Networks.pptx
 
asrar ppt^.^.^^.pptx
asrar ppt^.^.^^.pptxasrar ppt^.^.^^.pptx
asrar ppt^.^.^^.pptx
 
asrarsjsjsj.pptx
asrarsjsjsj.pptxasrarsjsjsj.pptx
asrarsjsjsj.pptx
 
videographyppt.pptx
videographyppt.pptxvideographyppt.pptx
videographyppt.pptx
 
stacks and queues.pptx
stacks and queues.pptxstacks and queues.pptx
stacks and queues.pptx
 
9TH CLASS.pptx
9TH CLASS.pptx9TH CLASS.pptx
9TH CLASS.pptx
 

Recently uploaded

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 

Recently uploaded (20)

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

Class10_OO_Testing.pdf

  • 1. 1 Object Oriented Testing Chapter 23 Click here to review SW Testing Strategies
  • 2. 2 OO Testing • Class Testing: Equivalent to unit testing for conventional SW. – The concept of a unit changes in the OO context. – The class or object is the smallest testable unit. – Testing must focus on each method of the class and the state behavior of the class. – It is important to consider the state of the class because this will effect the behavior, methods, of the class. – It is often difficult to determine the state of the object. • You may have to introduce new methods to look at the state variables for testing purposes.
  • 3. 3 OO Class Testing Example • A bank account class. – It may have methods to open the account, deposit funds, withdraw funds and close the account. – The states of the account include • open with positive balance, • open with negative or zero balance and • closed. – How the methods behave depends on the state of the account. • An account with a zero or negative balance will not allow the customer to withdraw funds. • If positive it might allow customer to go to overdraft once. • You could introduce a new method to determine the if the account is open or closed and if balance is positive.
  • 4. 4 OO Testing • Integration Testing: Because OO SW does not have a hierarchical control structure, conventional top-down or bottom-up integration strategies are not applicable.
  • 5. 5 Two approaches for OO Integration testing • Thread-based testing- – integrate the set of classes required to respond to one input or event of the system. – Each thread is integrated and tested individually. • Use-based testing – – first construct and test the classes which use very few (if any) server classes (these are called the independent classes). – The next step is to test the next layer of classes, the dependent classes, that use the independent classes.
  • 6. 6 Validation Testing • Conventional black-box testing derived from the analysis model can be used to test the OO software. • Use cases are a good place to look when developing test cases.
  • 7. 7 Test cases and the Class hierarchy • Methods that are redefined in a subclass must be tested because it represents a new design and new code. • Methods that are inherited must also be tested. – A subset of the original tests can be executed to ensure it works in the derived class.
  • 8. 8 • Random Testing: When a variety of different operation sequences are randomly generated. – Keep in mind the behavior life sequence of the class.
  • 9. 9 • Partition testing: Very similar to equivalence class partitioning for conventional SW. Partition the input and output of the class and design test cases to exercise each class. • 3 Examples: – State-based – Attribute-based – Category-based
  • 10. 10 • State-based partitioning: – Look at the states for the class. – Determine which operations change the state of the class and which do not and design test cases to exercise the class. – Test each method, while object is in each state. – Design test cases to do this.
  • 11. 11 • Attribute-based partitioning: – Look at the attributes of the class. – Partition methods into those that use the attribute, modify it and those that do not use it. – Design test cases for each partition.
  • 12. 12 • Category-based partitioning: – Look at the methods for the class. – Partition the methods into categories based on their function. – Examples: • initialization operations, computational, queries and termination operations. – Design test cases for each partition
  • 13. 13 Student Registration Example • A student registration class. – The methods include adding a class, dropping a class, transferring to a different section of the class and list classes. – A student must first be registered with the university (opened as a student). – Holds can be placed on a student and this effects whether he/she can register for a class. – There are limits on how many credit hours a student may register for. – A student may graduate (close a student).
  • 14. 14 Student Registration Example • Random testing may generate: – register, add class, transfer, add class, drop class, add class, hold, release hold, add class, …
  • 15. 15 Student Registration Example • State-based partitioning : – States: • Registered • Hold • Full Load • Partial Load • Freedom – Events: • Register, Add, Drop, List, transfer, Hold,Release, Graduate – Added methods: • Display Hold • Display credits
  • 16. 16 OO Test Case Design • Given the differences between conventional and OO SW, test case design is slightly different. • OO test cases should be defined in the following way: – Each test case should be uniquely identified and associated with the class to be tested. – The purpose of the test should be stated. – The following list should be developed for each test: 1. List of object states to be tested. 2. List of messages and operations (methods) to be tested 3. List of exceptions that may occur as the object is tested. 4. List of external conditions (think about system testing) that may change. • Anything else needed for the test?
  • 17. 17 OO Test Case Design • Instead of testing each component, you will test each class. • Make sure you identify the class you are testing. • You must test each method, in each state for the class. – This information will be included in the purpose/condition. • If needed, add methods to check state of the object. – You could use the result of these methods in your expected outcome.
  • 18. 18 Click to go to SW Metrics