Chapter 6. Object Oriented Testing
Chapter 6. Object Oriented Testing
Software Testing:
Software testing is a process used to identify the correctness, completeness and quality of
developed computer software.
It is the process of executing a program / application under positive and negative conditions
by manual or automated means.
It checks for Specification, Functionality and Performance
It is a validation and verification process.
Testing = Verification + Validation
Verification: Static testing (no run)
Validation: Dynamic testing (code running)
Objectives of Software Testing:
Uncover as many as errors (or bugs) as possible in a given product.
Demonstrate a given software product matching its requirement specifications.
Validate the quality of a software testing using the minimum cost and efforts.
Generate high quality test cases, perform effective tests, and issue correct and helpful
problem reports.
Verification:
It is the process to make sure the product satisfies the conditions imposed at the start of the
development phase.
To make sure the product behaves the way we want it to.
Validation:
Validation is the process to make sure the product satisfies the specified requirements at
the end of the development phase.
To make sure the product is built as per customer requirements.
Difference between Verification and Validation
Error: An error is a human action that produces the incorrect result that results in a fault.
Bug: The presence of error at the time of execution of the software.
Fault: State of software caused by an error.
Failure: Deviation of the software from its expected result. It is an event.
Test data: A test data is the inputs which have been devised to test the system.
Test Case: A test case is the triplet (I,0], where I is the data input to the system, S is the
state of the system at which data is input, and 0 is the expected output of the system or
Inputs to test the system and the predicted outputs from these inputs if the system operates
according to its specification.
Importance of Software Testing
Provide confidence in the system Identify areas of weakness
Establish the degree of quality
Establish the extent that the requirements have been met
To provide an understanding of the overall system
To prove that the software is both usable and operable
Techniques of Testing:
White-box testing
Whitebox Testing is a software testing method in which the internal structure of the item
being tested is known to the tester.
White box testing is often used for verification.
White box testing is done by the Developers.
Also called Open testing, Clear-box testing, Code-based testing, Glass-box testing, Logic-
coverage testing, Logic-driven testing, Structural testing, Structure-based testing, etc.
Example: A Car mechanic should know the internal structure of the car engine to repair it.
In this example,
CAR is the AUT (Application under Test).
User is the black box tester.
Mechanic is the white box tester.
Blackbox Testing
Blackbox Testing is a software testing method in which the internal structure of the item
being tested is not known to the tester.
o In it, testing will be done by visualizing the application as a black box.
Blackbox testing is often used for Validation.
Black box testing is done by the professional testing team.
Also called Specification-Based Testing, Closed Testing.
Example:
A simple example of black-box testing is a TV (Television). As a user, we watch the TV but we
don’t need the knowledge of how the TV is built and how it works, etc. We just need to know how
to operate the remote control to switch on, switch off, change channels, increase/decrease volume,
etc.
In this example,
The TV is your AUT (Application under Test).
The remote control is the User Interface (UI) that you use to test.
You just need to know how to use the application.
Levels of Testing
3. System Testing:
It is a level of software testing where a complete, integrated system is tested.
The purpose of this test is to evaluate system’s compliance with the specified requirements.
After integration testing, fully integrated application is tested to check that where the
system meets its software requirements specification (SRS).
Falls under black box testing
It is carried out to check the behavior of the application, software design and expectation
of the end user.
4. Acceptance Testing:
It is a test conducted to find if the requirements of a specification or contract are met as per
its delivery.
It is basically done by the user or customer. However, other stockholders can be involved
in this process.
Types of Acceptance Testing:
i. Alpha Testing:
It is a type of acceptance testing; performed to identify all possible issues and bugs before
releasing the final product to the end users.
Alpha testing is carried out by the testers who are internal employees of the organization.
The main goal is to identify the tasks that a typical user might perform and test them.
Advantages of Alpha Testing:
Provides better view about the reliability of the software at an early stage
Helps simulate real time user behavior and environment.
Detect many showstopper or serious errors
Ability to provide early detection of errors with respect to design and functionality
Disadvantages of Alpha Testing:
In depth, functionality cannot be tested as software is still under development stage.
Sometimes developers and testers are dissatisfied with the results of alpha testing.
ii. Beta Testing:
It is performed by “real users” of the software application in “real environment” and it can
be considered as a form of external User Acceptance Testing.
It is the final test before shipping a product to the customers. Direct feedback from
customers is a major advantage of Beta Testing. This testing helps to test products in
customer’s environment.
Beta version of the software is released to a limited number of end-users of the product to
obtain feedback on the product quality. Beta testing reduces product failure risks and
provides increased quality of the product through customer validation.
Advantages of Beta Testing
Reduces product failure risk via customer validation.
Beta Testing allows a company to test post-launch infrastructure.
Improves product quality via customer feedback
Cost effective compared to similar data gathering methods
Creates goodwill with customers and increases customer satisfaction
Disadvantages of Beta Testing
Test Management is an issue. As compared to other testing types which are usually
executed inside a company in a controlled environment, beta testing is executed out in the
real world where you seldom have control.
Finding the right beta users and maintaining their participation could be a challenge
Alpha Testing Beta Testing
i. It is always done by developers at the software i. It is always performed by customers at their
development site. own site.
ii. It involves the use of both white box and black ii. It incorporates the use of black box technique
box testing techniques. in testing.
iii. It is performed in a simulated or virtual iii. It is executed in real time environment.
environment at the developer's site.
iv. Alpha testing is done in the absence of the iv. Beta testing is performed in the absence of the
targeted end user base. development/QA team.
v. It is performed at a stage when the user v. It is also performed at a time when the software
requirements are required. product is required to be marketed to the
targeted clients/users.
vi. It is not open to the market and public. vi. It is open to market and public.
vii. It is not useful in incorporating user feedback vii. It incorporates user feedback towards
and issues. improving the product quality.
viii. It is used for software applications and projects. viii. It is used for software products.
Conventional Vs OO Systems
The structural differences:
₋ There are only functions, modules and subsystems in a conventional program whereas there
are function members defined in a class, classes, groups of classes and subsystems in OO
systems.
The behavior of the programs:
₋ There is a defined control flow among the active processes in a conventional program. But
in an OO program, there are several active processes running on multiple processes to
complete a function.
Dependencies:
₋ In conventional systems, there are data dependencies between variables, calling
dependencies between modules, functional dependencies between a module and the
variables it computes, definitional dependencies between a variable and its type; on the
other hand, OO systems have additional dependencies such as class to class dependencies,
class to method dependencies
Object Oriented Testing:
It is a collection of testing techniques to verify and validate object-oriented software.
Whenever large scale systems are designed, object oriented testing is done rather than
conventional testing strategies as the concept of object oriented programming is way
different from that of conventional ones.
The whole object oriented testing revolves around the fundamental entity called “class”.
With the help of “class” concept, larger system can be divided into small well defined units
which may then be implemented separately.
The object oriented testing can be classified as like conventional systems. These are called
levels for testing.
When should testing begin?
₋ Analysis and Design
₋ Programming
To complete the OOT cycle mention below testing are required
₋ Requirement Testing
₋ Analysis and Design Testing
₋ Code Testing
₋ Integration Tests
₋ System Tests
₋ User Testing
2. Integration testing:
It is also called as interclass or subsystem testing.
Inter class testing involves the testing of modules or sub-systems and their coordination
with other modules.
Different strategies for integration testing of OO systems:
a. Thread-based testing:
Integrates classes required to respond to one input or event.
Thread-based testing integrates the set of classes required to respond to one input or
event for the system. Each thread is integrated and tested individually.
b. Use-based testing:
It begins the construction of the system by testing those classes (called independent
classes) that use very few (if any) of server classes.
After the Independent classes are tested, the next layer of classes, called dependent
classes, that use the independent classes are tested.
This sequence of testing layers of dependent classes continue until the entire system is
constructed.
c. Cluster testing:
A cluster of collaborating classes (determined by examine the CRC and object-
relationship model) is exercised by designing test cases that attempt to uncover errors
in the collaborations.
3. Validation Testing:
It focuses on user-visible actions and user-recognizable output from the system.
To assist in the derivation of validation testing, the tester should work upon the use-
cases that are part of the analysis model.
The use-case provides a scenario that has a high likelihood of uncovered errors in the
user interaction requirements.
Conventional black-box testing methods can be used to drive validation tests.
In addition, test cases may be derived from the object-behavior model and from event
flow diagram created as part of OOA.
4. System Testing:
Software may be part of a larger system. This often leads to “finger pointing” by other
system dev teams.
Finger pointing defence:
i. Design error-handling paths that test external information
ii. Conduct a series of tests that simulate bad data
iii. Record the results of tests to use as evidence
Types of System Testing:
i. Recovery testing: how well and quickly does the system recover from faults
ii. Security testing: verify that protection mechanisms built into the system will protect
from unauthorized access (hackers, disgruntled employees, fraudsters)
iii. Stress testing: place abnormal load on the system
iv. Performance testing: investigate the run-time performance within the context of an
integrated system
Issues in OO Methods Testing
Traditional testing methods are not directly applicable to OO programs as they involve OO
concepts including polymorphism, inheritance and polymorphism. These concepts leads to issues
which are yet to be resolved. Some of the issues are:
Basic Unit of Unit Testing:
The class is natural unit for unit test case design.
The methods are meaningless apart from their class.
Testing a class instance (an object) can validate a class in isolation.
When individually validated classes are used to create more complex classes in an
application system, the entire subsystem must be tested as whole before it can be
considered to be validated (integration testing).
Encapsulation Issues:
Encapsulation requires that classes are only aware of their own properties, and are able to
operate independently.
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.
If you violate encapsulation for testing purposes, then the validity of test could be
questionable.
Inheritance Issues:
Inheritance is an important part of the object oriented paradigm.
It introduce problems that are not found in traditional software.
OO 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.
Implication of Genericity
Genericity is basically change in underlying structure.
We need to apply white box testing techniques that exercise this change.
Polymorphism Issues:
Each possible binding of polymorphic component requires a separate set of test cases.
Many server classes may need to be integrated before a client class can be tested.
It is difficult to determine such bindings.
It complicates the integration planning and testing.
Implications for testing processes
Re-examine all testing techniques and processes.
Object-oriented testing methods
Fault Based Testing:
This type of checking permits for coming up with test cases supported the consumer
specification or the code or both.
It tries to identify possible faults (areas of design or code that may lead to errors.). For all
of these faults, a test case is developed to “flush” the errors out. These tests also force each
time of code to be executed.
This method of testing does not find all types of errors. However, incorrect specification
and interface errors can be missed. These types of errors can be uncovered by function
testing in the traditional testing model.
In the object-oriented model, interaction errors can be uncovered by scenario-based testing.
This form of Object oriented-testing can only test against the client’s specifications, so
interface errors are still missed.
Scenario-Based Test Design:
Fault-based testing misses two main types of errors:
₋ incorrect specifications and
₋ Interactions among subsystems.
When errors associated with an incorrect specification occur, the product doesn’t do what
the customer wants. It might do the wrong thing or omit important functionality.
But in either circumstance, quality (conformance to requirements) suffers. Errors
associated with subsystem interaction occur when the behavior of one subsystem creates
circumstances (e.g., events, data flow) that cause another subsystem to fail.
Scenario-based testing concentrates on what the user does, not what the product does.
This means capturing the tasks (via use cases) that the user has to perform and then
applying them and their variants as tests. Scenarios uncover interaction errors.
But to accomplish this, test cases must be more complex and more realistic than fault-based
tests. Scenario-based testing tends to exercise multiple subsystems in a single test (users
do not limit themselves to the use of one subsystem at a time.
Develop Test Cases and Test Plans
Test Case:
It is a set of actions executed to verify a particular feature or functionality of your software
application.
A test case is a specification of the inputs, execution conditions, testing procedure, and
expected results that define a single test to be executed to achieve a particular software
testing objective, such as to exercise a particular program path or to verify compliance with
a specific requirement.
A test case is a set of conditions or variables under which a tester will determine whether
a system under test satisfies requirements or works correctly.
Test Case Design for OO software
An overall approach to OO test case design has been defined by Berard:
Each test case should be uniquely identified and explicitly associated with the class to be
tested.
The purpose of the test should be stated.
A list of testing steps should be developed for each test and should contain:
₋ A list of specified states for the object that is to be tested.
₋ A list of messages and operations that will be executed as a consequence of the test.
₋ A list of exceptions that may occur as the object is being tested.
₋ A list of external conditions (i.e., the changes in the environment external to the
software that must exist in order to properly conduct the test.)
₋ Supplementary information that will aid in understanding or implementing the test.
Unlike conventional test case design, which is driven by an input-process-output view of
software or the algorithmic detail of individual modules.
Object-oriented testing focuses on designing appropriate sequences of operations to
exercise the states of a class.
CRC Cards
• Class: A Class represents a collection of similar objects. The Class
name appears across the top of the CRC card.
• Responsibility: A Responsibility is anything that the class knows or
does. It appear along the left side of the CRC card.
• Collaborator: A Collaborator is another class that is used to get
information for, or perform actions for the class at hand. It often
works with a particular class to complete a step (or steps) in a
scenario. The Collaborators of a class appear along the right side of
the CRC card
CRC Cards
Class Name
Responsibilities Collaborators