Skip to main content
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI
Department of Computer Science and Engineering
CS6502 - OBJECT ORIENTED ANALYSIS AND DESIGN
2 & 16 Mark Questions & Answers
Year / Semester: III / V
Regulation: 2013
Academic year: 2017 - 2018
UNIT V
PART A
1. List the steps involved in mapping design to code.
The steps involved in mapping design to code are,
(2 Marks)
1. Class and interface definitions
The required visibility and associations between classes are indicated by the
interaction diagrams.
2. Method definitions
A method body implementation may be shown in a UML note box. It should be placed
with in braces, it is semantic influence. The syntax may be pseudo-code, or any language.
It is common to exclude the method signature (public void ...), but it is legal to include it.
2. What is State-Independent and State-Dependent Objects? (2 Marks)
If an object always responds the same way to an event, then it is considered state independent
(or modeless) with respect to that event.
If for all events of interest, an object always reacts the same way, it is a state-independent
object. By contrast, state-dependent objects react differently to events depending on their state
or mode.
3. Write the attribute presentation suggested by UML? (2 Marks)
OCL can be used during the design phase to define the class attributes .The following is the attribute
presentation suggested by UML.
Visibility name: type –expression-initial-value where visibility
is + public visibility
# protected visibility
- private visibility
Type – expression is language dependent specification .Initial – value is language dependent
expression for the initial value of a newly created object.
4. What are the three relationships that can be shown in UML diagram? Define them. (2 Marks)
The three relationships are:
1. Association how are objects associated? This information will guide us in designing classes.
2. Super-Sub Structure How are objects organized into super classes and sub classes? This
information provides us the direction of inheritance.
3. Aggregation and a part of Structure what is the composition of complex classes?
This information guides as in defining mechanisms that properly manage object
within object.
5. Define – Database Models (2 Marks)
A database model is a collection of logical constructs representing the data structure and data
relationship within the database.
Database models is of two categories
1. Conceptual model
2. Implementation model
Conceptual Model: Focuses on logical nature of data. It deals with what is represented in the
database.
Implementation Model: is concerned with how it is represented.
6. Define – Testing (2 Marks)
Testing is generally described as a group of procedures carried out to evaluate some aspect of a
piece of software.
Testing can be described as a process used for revealing defects in software and for establishing
that the software has attained a specified degree of quality with respect to selected attributes.
7. State some of the important test related issues.
There is a demand for software of high quality with low defects;
(2 Marks)
Process is important in the software engineering discipline; Software
testing is an important software development sub process;
Existing software evaluation and improvement models have not adequately addressed testing
issues.
8. What are the two major goals considered for integrated testing? (2 Marks)
to detect defects that occur on the interfaces of units;
to assemble the individual units into working subsystems and finally a complete system that is
ready for system test.
9. List the issues of class testing. (2 Marks)
Issue1: Adequately testing classes
Issue2: Observation of object states and state changes.
Issue3: The retesting of classes-I
Issue4: The retesting of classes-II
10. What are the challenges of class testing?
OO class is the target for test case design.
(2 Marks)
Encapsulation:
Difficult to obtain a snapshot of a class without building extra methods which display the classes’
state
Inheritance and polymorphism:
Each new context of use (subclass) requires re-testing because a method may be implemented
differently (polymorphism).
Other unaltered methods within the subclass may use the redefined method and need to be tested.
11. How is class testing different from conventional testing? (2 Marks)
Conventional testing focuses on input-process-output, whereas class testing focuses on each
method, then designing sequences of methods to exercise states of a class.
12. Write the impact of OO programming on testing. (2 Marks)
When an operation is invoked, it may be hard to tell exactly what code gets exercised. It can be
hard to determine the exact type or class of a parameter. OO operations are smaller, more time needed
for integration. So integration faults become more plausible.
13. List the class testing techniques.
State transition testing
(2 Marks)
Transaction flow testing
Exception testing
14. What are the three different incremental strategies of integration testing? (2 Marks)
Thread-based testing
Use-based testing
Cluster testing
15. List the types
(2 Marks)
Messaging errors
o
f
errors found during integration testing.
User interface errors
16
.
What are the challenges of
(2 Marks)
GUI testing?
– Documentation; GUIs are slower that APIs
Observing visible GUI state is difficult
Observing invisible GUI state is tricky almost
impossible Controlling GUI actions is difficult
17
.
List th
e
automated GUI testin
g
tools.
(2 Marks)
Capture/Replay testing tools
Random testing
Unit testing
Model-Based testing
PART B
1. Explain in detail, the Object Oriented Testing Strategies.
While there are efforts underway to develop more automated testing processes from test
models of the object model characteristics (for example states, data flows, or associations), testing is
still based on the creation of test cases and test data by team members using a structural (White Box
Testing) and/or a functional (SeeBlack Box Testing) strategy.
Overview of Object Orientated Unit Testing
Implications of Object Oriented Testing
Once a class is testing thoroughly it can be reused without being unit tested again
UML class state charts can help with selection of test cases for classes
Classes easily mirror units in traditional software testing
Objective of OO is to facilitate easy code reuse in the form of classes
To allow this each class has to be rigiriously unit tested
Due to classes potentially used in unforeseeable ways when composed in new systems
Example: A XML parser for a web browser
Classes must be created in a way promoting loose coupling and strong cohesion
CLASS TESTING:
Class testing is testing that ensures a class and its instances (objects) perform as defined.
(Source: Object Testing Patterns).
When designing a society of classes, an excellent goal is to structure classes so they can be
tested with a minimum of fuss. After all, a class that requires compiling the application,
starting the application, logging into the application, navigating to a particular point in the
application ...will likely not get rigorously tested.
In computer programming, unit testing is a software testing method by which individual
units of source code, sets of one or more computer program modules together with associated
control data, usage procedures, and operating procedures, are tested to determine whether they are
fit for use.
Intuitively, one can view a unit as the smallest testable part of an application. In procedural
programming, a unit could be an entire module, but it is more commonly an individual function or
procedure.
In object-oriented programming, a unit is often an entire interface, such as a class, but could
be an individual method.
Unit tests are short code fragments created by programmers or occasionally by white box
testers during the development process. It forms the basis for component testing.
Ideally, each test case is independent from the others. Substitutes such as method stubs, mock
objects,[5] fakes, and test harnesses can be used to assist testing a module in isolation. Unit tests are
typically written and run by software developers to ensure that code meets its design and behaves as
intended.
OO INTEGRATION TESTING:
Research confirms that testing methods proposed for procedural approach are
not adequate for OO approach
Ex. Statement coverage
OO software testing poses additional problems due to the distinguishing characteristics of OO
Ex. Inheritance
Testing time for OO software found to be increased compared to testing procedural software
Typical OO software characteristics that impact testing ...
State dependent behavior
Encapsulation
Inheritance
Polymorphism and dynamic
Binding
Abstract and generic classes
Exception handling
Procedural software
unit = single program, function, or procedure Object oriented software
unit = class
unit testing =intra-class testing
integration testing = inter-class testing
cluster of classes dealing with single methods separately is usually too expensive (complex
scaffolding), so methods are usually tested in the context of the class they belong to.
2. Describe in detail, the GUI Testing and OO System Testing.
Overview
‰ This chapter discusses the testing of object-oriented systems. The process of testing object-
oriented systems begins with a review of the object-oriented analysis and design models. Once
the code is written object-oriented testing (OOT) begins by testing "in the small" with class
testing (class operations and collaborations). As classes are integrated to become subsystems
class collaboration problems are investigated. Finally, use-cases from the OOA model are used
to uncover software validation errors.
‰ OOT similar to testing conventional software in that test cases are developed to exercise the
classes, their collaborations, and behavior.
‰ OOT differs from conventional software testing in that more emphasis is placed assessing the
completeness and consistency of the OOA and OOD models as they are built.
‰ OOT tends to focus more on integration problems than on unit testing.
Object-Oriented Testing Activities
‰ Review OOA and OOD models
‰ Class testing after code is written
‰ Integration testing within subsystems
‰ Integration testing as subsystems are added to the system
‰ Validation testing based on OOA use-cases
Testing OOA and OOD Models
‰ OOA and OOD cannot be tested but can review the correctness and consistency.
‰ Correctness of OOA and OOD models
Syntactic Semantic
Judged by ensuring that proper Based on the model's
modeling conformance to the real world
conventions and symbolism have problem domain
been used
‰ Consistency of OOA and OOD Models
x Assess the class-responsibility-collaborator (CRC) model and object-relationship diagram
Review system design (examine the object-behavior model to check mapping of system
behavior to subsystems, review concurrency and task allocation, use use-case scenarios to
exercise user interface design)
x Test object model against the object relationship network to ensure that all design object
contain necessary attributes and operations needed to implement the collaborations defined
for each CRC card
x Review detailed specifications of algorithms used to implement operations
using conventional inspection techniques
‰ Object-Oriented Testing Strategies
‰ Unit testing in the OO context
x Smallest testable unit is the encapsulated class or object
x Similar to system testing of conventional software
x Do not test operations in isolation from one another
x Driven by class operations and state behavior, not algorithmic detail and data flow
across module interface
x Complete test coverage of a class involves
- Testing all operations associated with an object
- Setting and interrogating all object attributes
- Exercising the object in all possible states
x Design of test for a class uses a verity of methods:
- fault-based testing
- random testing
- partition testing
x each of these methods exercises the operations encapsulated by the class
x test sequences are designed to ensure that relevant operations are exercised
x state of the class (the values of its attributes) is examined to determine if errors
exist ‰ Integration testing in the OO context
focuses on groups of classes that collaborate or communicate in some
manner integration of operations one at a time into classes is often
meaningless
thread-based testing (testing all classes required to respond to one system input or event)
use-based testing (begins by testing independent classes first and the dependent classes
that make use of them)
cluster testing (groups of collaborating classes are tested for interaction errors) regression
testing is important as each thread, cluster, or subsystem is added to the system Levels of
integration are less distinct in object-oriented systems
‰ Validation testing in the OO context
x focuses on visible user actions and user recognizable outputs from the system
x validation tests are based on the use-case scenarios, the object-behavior model, and
the event flow diagram created in the OOA model
x conventional black-box testing methods can be used to drive the validation tests
3. Describe in detail the Test Case Design for OO Software.
‰ Each test case should be uniquely identified and be explicitly associated with a class to
be tested
‰ State the purpose of each test
‰ List the testing steps for each test including:
x list of states to test for each object involved in the test
x list of messages and operations to exercised as a consequence of the test
x list of exceptions that may occur as the object is tested
x list of external conditions needed to be changed for the test
x supplementary information required to understand or implement the test
‰ Testing Surface Structure and Deep Structure
x Testing surface structure (exercising the structure observable by end-user, this
often involves observing and interviewing users as they manipulate system
objects)
x Testing deep structure (exercising internal program structure - the dependencies,
behaviors, and communications mechanisms established as part of the system and
object design)
‰ Testing Methods Applicable at The Class Level
Random testing - requires large numbers data permutations and combinations, and can
be inefficient
o Identify operations applicable to a
class o Define constraints on their use
o Identify a minimum test sequence
o Generate a variety of random test sequences.
Partition testing - reduces the number of test cases required to test a class
o state-based partitioning - tests designed in way so that operations that cause
state changes are tested separately from those that do not.
o attribute-based partitioning - for each class attribute, operations are classified according
to those that use the attribute, those that modify the attribute, and those that do not use
or modify the attribute
o category-based partitioning - operations are categorized according to the function
they perform: initialization, computation, query, termination
‰ Fault-based testing
x best reserved for operations and the class level uses the inheritance structure
x tester examines the OOA model and hypothesizes a set of plausible defects that may be
encountered in operation calls and message connections and builds appropriate test
cases
x misses incorrect specification and errors in subsystem interactions
‰ Inter-Class Test Case Design
x Test case design becomes more complicated as integration of the OO system begins –
testing of collaboration between classes
x Multiple class testing
o for each client class use the list of class operators to generate random test sequences that
send messages to other server classes
o for each message generated determine the collaborator class and the corresponding
server object operator
o for each server class operator (invoked by a client object message) determine the
message it transmits
o for each message, determine the next level of operators that are invoked and incorporate
them into the test sequence
x Tests derived from behavior models
o Use the state transition diagram (STD) as a model that represent the dynamic behavior of
a class.
o test cases must cover all states in the STD
o breadth first traversal of the state model can be used (test one transition at a time and
only make use of previously tested transitions when testing a new transition)
o test cases can also be derived to ensure that all behaviors for the class have been
adequately exercised
‰ Testing Methods Applicable at Inter-Class Level
Cluster Testing
Is concerned with integrating and testing clusters of cooperating objects
Identify clusters using knowledge of the operation of objects and the system features that
are implemented by these clusters
x Approaches to Cluster Testing
o Use-case or scenario testing
ƒ Testing is based on a user interactions with the system
ƒ Has the advantage that it tests system features as experienced by users
o Thread testing – tests the systems response to events as processing threads through
the system
o Object interaction testing – tests sequences of object interactions that stop when
an object operation does not call on services from another object
Use Case
Scenario-based Testing
x Based on
o use cases
o corresponding sequence diagrams
x Identify scenarios from use-cases and supplement these with interaction diagrams that show
the objects involved in the scenario
x Concentrates on (functional)
requirements o Every use case
o Every fully expanded extension (<<extend>>) combination
o Every fully expanded uses (<<uses>>) combination
o Tests normal as well as exceptional behavior x
A scenario is a path through sequence diagram
x Many different scenarios may be associated with a sequence diagram
x using the user tasks described in the use-cases and building the test cases from the tasks
and their variants
x uncovers errors that occur when any actor interacts with the OO software
x concentrates on what the use does, not what the product does
x you can get a higher return on your effort by spending more time on reviewing the use-
cases as they are created, than spending more time on use-case testing
‰ OO Test Design Issues
‰ White-box testing methods can be applied to testing the code used to implement
class operations, but not much else
‰ Black-box testing methods are appropriate for testing OO systems
‰ Object-oriented programming brings additional testing concerns
x classes may contain operations that are inherited from super classes
x subclasses may contain operations that were redefined rather than inherited
x all classes derived from an previously tested base class need to be thoroughly tested