Testing: 5.1 Object Oriented Mehodologies
Testing: 5.1 Object Oriented Mehodologies
Unit
TESTING
Object Model:-
Object model describes the structure of objects in a system, their identity and relationships
to other objects, attributes, and operations.
Client
client Account
account
First name Number
Last name Balance
Deposit
Withdraw Create
Checking
Checking savings account
account Savings account
Withdraw
Account has
Nothing is
been selected
Selected Select
checking or checking
Select transaction
type(withdraw, Enter the
deposit and
Confirmation
Testing 5.3
State transition diagrams for the bank application user interface.
• Round boxes represents states
• Arrows represents transitions
• Conceptualization.
Establish the core requirements and develop a prototype.
• Evolution or implementation.
Refine the system through much iteration.
• Maintenance.
Make localized changes to the system to add new requirements and eliminate bugs.
Enabled
Sound alarm
Silenced Sounding
Silence alarm
Enable Disable
Disabled
Jacobson Methodology:
• Object-oriented business engineering (OOBE)
• Object-oriented software engineering (OOSE)
Testing 5.5
• It covers the entire life cycle
• Stress traceability(enables reuse of analysis and design work) both forward and
backward
• Use cases
• Scenarios for understanding system requirements.
• Non formal text with no clear flow of events.
• Text easy to read.
• Formal style using pseudo code.
• Can be viewed as concrete or abstract (not initiated by actors).
• Understanding system requirements
• Interaction between user and system
• It captures the goal of the user and responsibility of the system to its users
Checking out
books
Getting an supplier
member
interlibraryloan
Doing research
Reading books,
newspapers
Purchasing
use-case model
Ok
Not
• Implementation model:
The implementation model represents the implementation of the system
• Test model:-
The test model constitutes the test plans, specification and reports.
FRAMEWORKS:
Frameworks are a way of delivering application development patterns to support best
practice sharing during application development .
A frame work is a way of presenting a generic solution to a problem that can be applied to
all levels in a development. Several design patterns in fact a framework can be viewed as the
implementation of a system of design patterns.
Testing Strategies: -
• The objective of s/w testing is to uncover errors. The various testing strategies
constitutes –
◦ Unit Testing – Black Box testing, White black testing
◦ Integration Testing – Top–down testing, Bottom–up testing, Regression testing
5.12 Object Oriented Analysis and Design
◦ Validation Testing – Alpha test, Beta test and
◦ System Testing – Recovery testing, Security testing, Stress testing, Performance
testing o Tom Gilb argues following issues for successful s/w testing strategy is to
be implemented:
1) Specify product requirements in a quantifiable manner long before testing
commences
2) State testing objectives explicitly
3) Understand the users of s/w and develop a profile for each user category
4) Develop a testing plan that emphasizes “rapid cycle testing”
5) Build “robust” s/w that is designed to test itself
6) Use effective formal technical reviews as a filter prior to testing
7) Conduct formal technical reviews to assess the test strategy and test cases
themselves
8) Develop a continuous improvement approach for testing process
• Unit and integration
incorporation of tests concentrate on functional verification of a module and
• modules into a program structure. Validation testing demonstrates traceability to s/w
requirements and system testing validates s/w once it has been incorporated into a
larger system
1) Unit test focuses verification effort on smallest unit of s/w design the module. It
constitutes two inner types of testing – White box testing and Black box testing
Black box testing: The concept of black box is used to represent a system
that’s inside working are
not available for inspection. In black box testing, we try various inputs and
examine resulting output though which we learn what the box does nor how
conversion takes place
White box testing: White box testing assumes that specific logic important and
must be tested to guarantee system’s proper functioning. One form of white
box testing called path testing, makes certain that each path in a object’s
method is executed at least once during testing & is of types
1) Statement testing coverage: Its aim is to test every statement in object’s
method at least once
2) Branch testing coverage: Idea is to perform enough tests ensuring all
branches are perfect
• Integration Testing: It is a systematic technique for constructing the program
structure while conducting tests to uncover errors associated with interfacing. The
object is to take unit tested modules and build a program structure that has been
dictated by design. It has again 3 testing patterns: Top–down testing, Bottom – up
testing and regression testing
Testing 5.13
• Top–down testing: It assumes that main logic or object interactions and system
messages of application need more testing than an individual object’s method or
supporting logic. This strategy can detect serious flaws early in implementation
• Bottom–Up testing: It starts with details of system and proceeds to higher levels by a
progressive aggregation of details until they collectively fit requirements for system
i.e., start with methods and classes then to level up. It makes sense as it checks
behavior of piece of code before it is used
• Regression testing: It is activity that helps ensure that changes (due to testing or other
reasons) do not introduce unintended behavior or additional errors. The regression test
suite contain three different classes of test cases:
◦ A representative sample of tests that will exercise all s/w functions
◦ Additional tests that focus on s/w functions that are likely to be affected by change
◦ Tests that focus on s/w components that have been changed
• Validation Testing: After integration testing, s/w is completely assembled as a
package: interfacing errors have been uncovered and corrected and final series of s/w
tests – validating testing – begins. It is nothing but continuous execution on s/w by
number of times & users. It is again implemented either by one of two methods: Alpha
testing or Beta testing
• Alpha test is conducted in controlled environment at developer’s site by a customer.
The s/w is used in setting with developer “looking over shoulder” of user, recording
errors & usage problems
• Beta test is conducted at one or more customer sites by end user(s) of the s/w. Its live
application of s/w where customer records all problems that are encountered during
beta testing and reports
• System Testing: It is a series of different tests whose primary purpose is to fully
exercise the computer – based system. Although each test has a different purpose, all
work to verify that all system elements have been properly integrated and perform
allocated functions. The different tests in series are Recovery, security, stress and
performance testing
• Recovery testing is a system test that forces s/w to fail in a variety of ways and verifies
that recovery is properly performed. If recovery is automatic, re – initialization,
checkpoint mechanisms, data recovery and restart are each evaluated for correctness
• Security testing attempts to verify that protection mechanisms built into a system will
in fact protect it from improper penetration. During this test, tester plays the role(s) of
individual who desires to penetrate system. The role of system designer is to make
penetration cost greater than value of information that will be obtained
• Stress testing executes a system in a manner that demands resources in abnormal
quantity, frequency or volume. A variation of stress testing is a technique called
sensitivity testing. In some situations, a very small range of data contained within the
bunds of valid data for a programs may cause extreme and even erroneous processing
or profound performance degradation
5.14 Object Oriented Analysis and Design
• Performance testing is designed to test run –time performance of s/w within context
of an integrated system. It occurs throughout all steps in testing process. Performance
tests are often coupled with stress testing and often require both h/w and s/w
instrumentation
5.3 IMPACT OF OBJECT ORIENTATION ON TESTING
The impact of an object orientation on testing can be summarized as follows:
1) Some types of errors could become less plausible (not worth for testing)
2) Some types of errors could become more plausible (worth testing for now)
3) Some new types of errors might appear
State-based
Testing
Object-oriented
Testing Methods
Scenario-
Fault-based
based
Testing
Testing
For this testing, finite-state machine (FSM) or state-transition diagram representing the
possible states of the object and how state transition occurs is built. In addition, state-based testing
generates test cases, which check whether the method is able to change the state of object as
expected. If any method of the class does not change the object state as expected, the method is
said to contain errors.
Testing 5.17
To perform state-based testing, a number of steps are followed, which are listed below.
1) Derive a new class from an existing class with some additional features, which are
used to examine and set the state of the object.
2) Next, the test driver is written. This test driver contains a main program to create an
object, send messages to set the state of the object, send messages to invoke methods
of the class that is being tested and send messages to check the final state of the object.
3) Finally, stubs are written. These stubs call the untested methods.
Fault-based Testing
1) Fault-based testing is used to determine or uncover a set of plausible faults. In
other words, the focus of tester in this testing is to detect the presence of
possible faults. Fault-based testing starts by examining the analysis and design
models of OO software as these models may provide an idea of problems in the
implementation of software. With the knowledge of system under test and experience
in the application domain, tester designs test cases where each test case targets to
uncover some particular faults.
2) The effectiveness of this testing depends highly on tester experience in application
domain and the system under test. This is because if he fails to perceive real faults in
the system to be plausible, testing may leave many faults undetected. However,
examining analysis and design models may enable tester to detect large number of
errors with less effort. As testing only proves the existence and not the absence of
errors, this testing approach is considered to be an effective method and hence is
often used when security or safety of a system is to be tested.
Scenario-based Testing
Scenario-based testing is used to detect errors that are caused due to incorrect
specifications and improper interactions among various segments of the software. Incorrect
interactions often lead to incorrect outputs that can cause malfunctioning of some segments of the
software. The use of scenarios in testing is a common way of describing how a user might
accomplish a task or achieve a goal within a specific context or environment. Note that these
scenarios are more context- and user specific instead of being product-specific. Generally, the
structure of a scenario includes the following points.
A condition under which the scenario runs.
A goal to achieve, which can also be a name of the scenario.
A set of steps of actions.
An end condition at which the goal is achieved.
A possible set of extensions written as scenario fragments.
Scenario- based testing combines all the classes that support a use-case (scenarios are
subset of use-cases) and executes a test case to test them. Execution of all the test cases ensures
that all methods in all the classes are executed at least once during testing. However, testing all the
5.18 Object Oriented Analysis and Design
objects (present in the classes combined together) collectively is difficult. Thus, rather than testing
all objects collectively, they are tested using either top-down or bottom-up integration approach.
This testing is considered to be the most effective method as scenarios can be organized in
such a manner that the most likely scenarios are tested first with unusual or exceptional scenarios
considered later in the testing process. This satisfies a fundamental principle of testing that most
testing effort should be devoted to those paths of the system that are mostly used.
Encapsulation of attributes and methods in class may create obstacles while testing. As
methods are invoked through the object of corresponding class, testing cannot be accomplished
without object. In addition, the state of object at the time of invocation of method affects its
behavior. Hence, testing depends not only on the object but on the state of object also, which is
very difficult to acquire.
Inheritance and polymorphism also introduce problems that are not found in traditional
software. Test cases designed for base class are not applicable to derived class always (especially,
when derived class is used in different context). Thus, most testing methods require some kind of
adaptation in order to function properly in an OO environment.