Download - 09 OO Testing and Test Cases
![Page 1: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/1.jpg)
1
OO testing and testing strategies
• Testing object-oriented software
• Testing strategies
• Higher-order testing
![Page 2: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/2.jpg)
2
Object - oriented testing
• begins by evaluating the correctness and consistency of the OOA and OOD models
• testing strategy changesthe concept of the ‘unit’ broadens due to encapsulation
integration focuses on classes and their execution across a ‘thread’ or in the context of a usage scenario
validation uses conventional black box methods
• test case design draws on conventional methods, but also encompasses special features
![Page 3: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/3.jpg)
3
OOT strategy
• classes are the smallest testable unit
• inheritance defines new context for methods– behavior of inherited methods can be changed because of methods that are
called within
– methods have to be tested per class
• objects have states: testing methods have to take that into account
• class testing is the equivalent of unit testing– operations within the class are tested
– the state behavior of the class is examined
• OO testing concentrates on the states of the objects and their interactions
![Page 4: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/4.jpg)
4
Integration applied three different strategies
• thread-based testing• integrates the set of classes required to respond to one
input or event
• use-case based testing• integrates the set of classes required to respond to one use
class
• starts with independent (ground) classes
• cluster testing• integrates the set of classes required to demonstrate one
collaboration
![Page 5: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/5.jpg)
5
OOT - test case design (1)
Berard [BER93] proposes the following approach:
1. each test case should be uniquely identified and should be explicitly associated with the class to be tested,
2. the purpose of the test should be stated,
3. a list of testing steps should be developed for each test and should contain [BER94]:
![Page 6: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/6.jpg)
6
OOT - test case design (2)
A a list of specified states for the object that is to be tested
B a list of messages and operations that will be exercised as a consequence of the test
C a list of exceptions that may occur as the object is tested
D a list of external conditions (i.e., changes in the environment external to the software that
must exist in order to properly conduct the test)
E supplementary information that will aid in understanding or implementing the test.
![Page 7: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/7.jpg)
7
Problems in testing OO software
• Testing shall report errorsinternal state of object
• Encapsulation hides internal things
• Inheritance: test cases of the superclass may may have to be adapted
![Page 8: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/8.jpg)
8
OOT methods: Scenario-based testing
• Concentrates on what the user does NOT what the system does
• Based on use cases
• Described by– a test– specific user needs
![Page 9: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/9.jpg)
9
OOT methods: random testing
• random testingidentify operations applicable to a class
define constraints on their use
identify a minimum test sequence• an operation sequence that defines the minimum
life history of the class (object)
generate a variety of random (but valid) test sequences
• exercise other (more complex) class instance life histories
![Page 10: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/10.jpg)
10
OOT methods: partition testing (1)
• Partition testingreduces the number of test cases required to
test a class in much the same way as equivalence partitioning for conventional software
state-based partitioning• categorize and test operations based on their
ability to change the state of a class
![Page 11: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/11.jpg)
11
OOT methods: partition testing (2)
• Partition testingattribute-based partitioning
• categorize and test operations based on the attributes that they use
category-based partitioning• categorize and test operations based on the
generic function each performs e.g.– initialization
– state changing
– queries
– termination
![Page 12: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/12.jpg)
12
State diagram based testing
• Use state diagram to determine a sequence of events
• Tests should achieve all state coverage
• All transitions should be tested at least once
• Test invalid events
![Page 13: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/13.jpg)
13
OOT methods: Inter-class testing (1)
• Inter-class testingFor each client class, use the list of class
operators to generate a series of random test sequences. The operators will send messages to other server classes.
For each message that is generated, determine the collaborator class and the corresponding operator in the server object.
![Page 14: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/14.jpg)
14
OOT methods: Inter-class testing (2)
• Inter-class testingFor each operator in the server object ( that
has been invoked by messages sent from the client object), determine the messages that it transmits.
For each of the messages, determine the next level of operators that are invoked and incorporate these into the test sequence
![Page 15: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/15.jpg)
15
OO testing and testing strategies
• Testing object-oriented software
• Testing strategies
• Higher-order testing
![Page 16: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/16.jpg)
16
Verification & validation
• Verification: Are we building the product right
• Validation: Are we building the right product
![Page 17: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/17.jpg)
17
Testing strategy
code
design
requirementshigh-order
tests
integration test
unittest
![Page 18: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/18.jpg)
18
Unit testing
Test cases
Moduleinterface
local data structures
boundary conditions
independent paths
error handling paths
![Page 19: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/19.jpg)
19
Unit testing environment
Test cases
interface
local data structures
boundary conditions
independent paths
error handling paths
driver
Module
stub stub
RESULTS
![Page 20: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/20.jpg)
20
Why integration testing?
• If all units work individually, why doubt that they work together?
• Putting units together - interfacing
![Page 21: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/21.jpg)
21
Integration testing
BigBang!
incrementalconstruction
strategy
incremental“builds”
regressiontesting
![Page 22: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/22.jpg)
22
Top down integration
A
GFB
E
C
D
top module is tested with stubs
stubs are replaced one at a time, “depth first”
as new modules are integrated,some subset of tests is re-run
![Page 23: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/23.jpg)
23
Bottom-up integration
A
GFB
E
C
D
drivers are replaced one at a time, “depth first”
worker modules are grouped intobuilds and integrated
cluster
![Page 24: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/24.jpg)
24
Sandwich testing
A
GFB
E
C
Dworker modules are grouped intobuilds and integrated
cluster
top modules are tested with stubs
![Page 25: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/25.jpg)
25
OO testing and testing strategies
• Testing object-oriented software
• Testing strategies
• Higher-order testing
![Page 26: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/26.jpg)
26
High-order testing
• validation test
• system test
• alpha and beta test
• other specialized testing
![Page 27: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/27.jpg)
27
Alpha & Beta test
software
developer site customer site
customer tests
Alpha test
software
developer site customer site
customertests
Beta test
developerreviews
![Page 28: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/28.jpg)
28
Test specification (1)
1. Scope of testing
2. Test plan
3. Test procedure n (description of test for build n)
4. Actual test results
5. References
6. Appendices
![Page 29: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/29.jpg)
29
Test specification (2)
2. Test planA. test phases and builds
B. schedule
C. overhead software
D. environment and resources
![Page 30: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/30.jpg)
30
Test specification (3)
3. Test procedure n A. order of integration
1. purpose
2. modules to be tested
B. unit tests for modules in build1. description of tests for module n
2. overhead software description
3. expected results
![Page 31: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/31.jpg)
31
Test specification (4)
3. Test procedure n C. test environment
1. special tools or techniques
2. overhead software description
D. test case data
E. expected results for build n
![Page 32: 09 OO Testing and Test Cases](https://reader036.vdocument.in/reader036/viewer/2022062701/55388a794a79599a678b477a/html5/thumbnails/32.jpg)
32
Debugging: Symptoms & causes
• Symptom and cause may be geographically separated
• symptom may disappear when another problem is fixed
• cause may be due to a combination of non-errors
• cause may be due to a system or compiler error
• cause may be due to assumptions that everyone believes
• symptom may be intermittentcausesymptom