Software Coding and Testing Strategies
Software Coding and Testing Strategies
Objectives
According to Glen Myers the testing objectives are :
• Testing is a process of executing a program with
the intend of finding an error.
• A good test case is one that has high probability
of finding an undiscovered error.
• A successful test is one that uncovers an as-yet
undiscovered error.
Major objective – to deign tests that systematically
uncover types of error with minimum time & effort.
Who Test the Software
Developer -
• Understands the system but, will test
“gently” &, is driven by “delivery”
• Testing without plan is of no point - It
wastes time & effort
Tester -
• Must learn about the system, but, will
attempt to break it &, is driven by
quality
• Testing need a strategy Development
team needs to work with Test team,
“Egoless Programming”
When to Test the Software?
Verification & Validation
Verification - Are we building the product right?
• The objective of Verification is to make sure that the
product being develop is as per the requirements &
design specifications.
Software development
stages
Testing Strategy
• Unit testing – In this type of testing techniques are
applied to detect the errors from each software
component individually.
• Integration testing – It focuses on issues associated
with verification & program construction as components
begin interacting with one another.
• Validation testing – It provides assurance that the
software validation criteria meets all functional, behavioral
& performance requirements.
• System testing – In system testing all system
elements forming the system is tested as a whole.
Unit testing
• Unit is the smallest part of a software
system which is testable.
• It may include code files, classes and
methods which can be tested
individually for correctness.
• It concentrate on each unit of the software as
implemented in source code.
• It focuses on each component individual, ensuring that it
functions properly as a unit.
• The unit test focuses on the internal processing logic
and data structures within the boundaries of a
component.
Unit testing cont.
The various tests that are conducted during the unit test
are described as :
• Module interfaces are tested for proper information flow in
and out of the program unit.
• Local data are examined to ensure that integrity is
maintained.
• Boundary conditions are tested to ensure that the module
operates properly at boundaries established to limit or
restricted processing.
• All the independent paths are tested for ensuring that all
statements in the module have been executed only once.
• All error handling paths should be tested.
• Drivers & stub software need to be developed to test
incomplete software.
• The unit testing is simplified when a component with high
cohesion is designed.
Driver & Stub (Unit Testing)
• Driver – is a program that accepts
the test data & prints the relevant
results.
• Stub – is a subprogram that uses
the module interfaces & performs
the minimal data manipulation
• Component-testing if may be done in
(Unit Testing)
[Link] rest of the system
isolation
• In such case the missing software is replaced by Stubs
and Drivers and simulate the interface between the
software components in a simple manner
A B C
Driver & Stub (Unit Testing)
cont.–
Driver
• Driver and/or Stub software must be developed for each unit
test
• A driver is nothing more than a "main program"
• Driver
• Used in Bottom up approach
• Lowest modules are tested first.
• Simulates the higher level of components
• Dummy program for Higher level component
Stub –
• Stubs serve to replace modules that are subordinate (called
by) the component to be tested.
• A stub or "dummy subprogram"
• Stubs
• Used in Top down approach
• Top most module is tested first
• Simulates the lower level of components
• Dummy program of lower level components
Integration testing
• Integration testing is a level of
software testing where individual
units / components are combined
and tested as a group.
• It is the process of testing the interface between two
software units or modules
• Objective – to take unit tested components & build a
program structure that has been dictated by software
design.
• The focus of integration testing is to uncover errors in :
• Design & construction of software architecture.
• Integrated functions or operations at subsystem level.
• Interfaces & interactions between them.
• Resource integration and/or environment integration.
Integration testing cont.
• The integration testing can be
carried out using 2 approaches.
• Non-incremental integration
• Incremental integration
Integration testing
approach
Stress Testing
• Determines breakpoint of a system to
establish maximum service level.
• The system is executed in a manner that
demands resources in abnormal quality,
frequency or volume.
• A variation of stress testing is a technique called
sensitivity testing.
• It is a testing in which it’s tried to uncover data
from a large class of valid data that may cause
instability.
Types of System testing
cont.
Performance Testing
• Evaluates the run time performance of the
software, especially real time software.
• Resource utilization such as CPU load,
throughput, response time, memory usage
can be measured.
• For big systems involving many users
connecting to servers, performance testing
is very difficult.
• Beta testing is useful for performance
testing.
Testing Conventional
Applications
There are two general approaches for the software testing.
• White box testing (Glassbox testing) - White box
testing is a testing technique, that examines the
program structure and derives test data from the
program logic/code. The other names of glass box
testing are clear box testing, open box testing, logic
driven testing or path driven testing or structural
testing.
• Black box testing - Black-box testing is a method of
software testing that examines the functionality of an
application based on the specifications. It is also
known as Specifications based testing. Independent
Testing Team usually performs this type of testing
during the software testing life cycle.
White box testing
• White box testing is a software testing method in which
the internal structure/ design/ implementation of the
item being tested is known to the tester.
• It is like the work of a mechanic who examines the
engine to see why the car is not moving.
• Focus is on ensuring that even abnormal invocations are
handled gracefully.
• Using white-box testing methods, you can derive test
cases that
o Guarantee that all independent paths within a module
have been exercised at least once
o Exercise all logical decisions on their true and false sides
o Execute all loops at their boundaries
o Exercise internal data structures to ensure their validity
White box testing cont.
• Why is it called White box testing ? - Because here the
testers require knowledge of how the software is
implemented.
• It is applicable to the following levels of software testing
o Unit Testing: For testing paths within a unit
o Integration Testing: For testing paths between units
o System Testing: For testing paths between subsystems
• Goal - to ensure that all statements and conditions have
been executed at least once ...
Why and When White-Box Testing:
• White box testing is mainly used for detecting logical
errors in the program code.
• It is used for debugging a code, finding random
typographical errors, and uncovering incorrect
programming assumptions.
• White box testing is done at low level design and
implementable code.
• It can be applied at all levels of system development
especially Unit, system and integration testing.
• White box testing can be used for other development
artifacts like requirements analysis, designing and test
cases.
Advantages & Disadvantages
Advantages :
• Reveals errors in "hidden" code.
• Spots the Dead Code or other issues with respect to best
programming practices.
• Testing can be commenced at an earlier stage as one need not
wait for the GUI to be available.
• Testing is more thorough, with the possibility of covering most
paths.
Disadvantages :
• Expensive as one has to spend both time and money to perform
white box testing.
• Every possibility that few lines of code are missed accidentally.
• In-depth knowledge about the programming language is
necessary to perform white box testing.
• Since tests can be very complex, highly skilled resources are
required, with thorough knowledge of programming and
implementation.
Whitebox Testing Techniques:
• A major White box testing technique is Code Coverage
analysis.
• Code Coverage analysis, eliminates gaps in a test case suite.
• It identifies areas of a program that are not exercised by a set
of test cases.
• Once gaps are identified, you create test cases to verify
untested parts of code, thereby increase the quality of the
software product.
• There are automated tools available to perform Code
coverage analysis.
Following are Whitebox testing techniques:
o Statement coverage: This technique is aimed at
exercising all programming statements with minimal tests.
o Branch and decision coverage: This technique is
running a series of tests to ensure that all branches are
tested at least once. Tools: An example of a
tool that handles branch coverage testing for C, C++ and
Java applications is TCAT-PATH
1. Statement coverage:
• Statement coverage is a white box testing technique,
which involves the execution of all the statements at
least once in the source code.
• Through statement coverage we can identify the
statements executed and where the code is not
executed because of blockage.
• Using this technique we can check what the source
code is expected to do and what it should not & also
used to check the quality of the code & the flow of
different paths in the program.
• The statement coverage covers only the true
conditions. The main drawback of this technique is that
we cannot test the false condition in it.
• The statement coverage is count as per below formula:
(Statement coverage = No of statements
Executed/Total no of statements in the source code * 100)
1. Statement coverage:
Example:
Read A
Read B
if A>B
Print “A is greater than B”
else
Print "B is greater than A"
endif
• Set1 :If A =5, B =2
No of statements Executed: 5
Total no of statements in the source code: 7
Statement coverage =5/7*100 = 71.00%
• Set2 :If A =2, B =5 [False-Not supported by Statement
coverage]
No of statements Executed: 6
Total no of statements in the source code: 7
Statement coverage =6/7*100 = 85.20%
2. Branch/Decision coverage:
• Branch coverage is also known as Decision coverage or
all-edges coverage.
• It covers both the true and false conditions unlikely the
statement coverage.
• A branch is the outcome of a decision, so branch
coverage simply measures which decision outcomes
have been tested.
• This sounds great because it takes a more in-depth
view of the source code than simple statement
coverage.
• The formula to calculate decision coverage is:
Decision Coverage=(Number of decision outcomes
executed/Total number of decision outcomes)*100%
2. Branch/Decision coverage:
Example:
READ X
READ Y
IF (X > Y)
PRINT “X is greater that Y”
ENDIF
• To get 100% statement coverage only one test case is
sufficient for this pseudo-code.
• TEST CASE 1: X=10 Y=5
• However this test case won’t give you 100% decision
coverage as the FALSE condition of the IF statement is not
exercised.
• In order to achieve 100% decision coverage we need to
exercise the FALSE condition of the IF statement which will be
covered when X is less than Y.
• So the final TEST SET for 100% decision coverage will be:
TEST CASE 1: X=10, Y=5
TEST CASE 2: X=2, Y=10
3. Path coverage:
• The basis path method enables the test-case designer
to derive a logical.
• Complexity measure of a procedural design and use
this measure as a guide for defining a basis set of
execution paths.
• Test cases derived to exercise the basis set are
guaranteed to execute every statement in the program
at least one time during testing.
• All possible control paths taken, including
o All loop paths taken zero, once and multiple items in
technique
o The test case are prepared based on the logical
complexity measure of the procedure design
• Flow graph, Cyclomatic Complexity and Graph Metrices
are used to arrive at basis path.
3. Path coverage:
Disadvantages :
• This technique sometimes fails to test all the potential input values.
And so, the results are unsure.
• The dependencies with BVA are not tested between two inputs.
• This technique doesn’t fit well when it comes to Boolean Variables.
• It only works well with independent variables that depict quantity.
Comparison of Blackbox Testing & Whitebox
TestingBlack Box Testing White Box Testing
Black box testing is the Software White box testing is the software
testing method which is used to test testing method in which internal
the software without knowing the structure is being known to tester
internal structure of code or program. who is going to test the software.
This type of testing is carried out by Generally, this type of testing is
testers. carried out by software developers.
Implementation Knowledge is not Implementation Knowledge is
required to carry out Black Box required to
Testing. carry out White Box Testing.
Programming Knowledge is not Programming Knowledge is required
required to carry out Black Box to carry out White Box Testing.
Testing.
Testing is applicable on higher levels Testing is applicable on lower level of
of testing like System Testing, testing like Unit Testing, Integration
Acceptance testing. testing.
Black box testing means functional White box testing means structural
test or external testing. test or
interior testing.
Comparison of Blackbox Testing & Whitebox
Testing cont.
Black Box Testing White Box Testing
In Black Box testing is primarily In White Box testing is primarily
concentrate on the functionality of concentrate on the testing of program
the code of the system under test like
system under test. code structure, branches, conditions,
loops etc.
The main aim of this testing to check The main aim of White Box testing to
on what functionality is performing by check on how System is performing.
the system under test.
Black Box testing can be started White Box testing can be started
based on Requirement Specifications based on
documents. Detail Design documents.
The Functional testing, Behavior The Structural testing, Logic testing,
testing, Close box testing is carried Path testing, Loop testing, Code
out under Black Box testing, so there coverage testing, Open box
is no required of the programming testing is carried out under White
knowledge. Box testing, so there is
compulsory to know about
programming knowledge.
Test Case
• A TEST CASE is a set of actions executed to verify a
particular feature or functionality of your software
application.
• A Test Case contains test steps, test data, precondition,
postcondition developed for specific test scenario to
verify any requirement.
• The test case includes specific variables or conditions,
using which a testing engineer can compare expected
and actual results to determine whether a software
product is functioning as per the requirements of the
customer.
Test Suites design
• Test suite is a container that has a set of tests which
helps testers in executing and reporting the test
execution status. It can take any of the three states
namely Active, InProgress and completed.
• A Test case can be added to multiple test suites and
test plans. After creating a test plan, test suites are
created which in turn can have any number of tests.
• Test suites are created based on the cycle or based on
the scope. It can contain any type of tests, viz -
functional or Non-Functional.
Test Suite - Diagram:
Testing Object Oriented
Applications
• Objective – to uncover as much errors as possible with
manageable amount of efforts in realistic time span.
• The object oriented testing strategy is identical to
conventional testing strategy.
• The strategy is start testing in small & work outward to
testing in large.
• The basic unit of testing is class that contains attributes
& operations.
• These classes integrate to form object oriented
architecture & called collaborating classes.
Unit Testing in the OO Context
• The concept of the unit testing changes in object-
oriented software
• Encapsulation drives the definition of classes and
objects
o Means, each class and each instance of a class
(object) packages attributes (data) and the
operations (methods or services) that manipulate
these data
o Rather than testing an individual module, the
smallest testable unit is the encapsulated class
• Unlike unit testing of conventional software,
o which focuses on the algorithmic detail of a module
and the data that flows across the module interface,
o class testing for OO software is driven by the
operations encapsulated by the class and the state
behavior of the class
Integration Testing in the OO
Context
• Object-oriented software does not have a hierarchical control
structure,
• conventional top-down and bottom-up integration strategies
have little meaning
• There are two different strategies for integration testing of
OO systems.
o 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
• Regression testing is applied to ensure that no side effects occur
o Use-based testing
• 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
• Cluster testing is one step in the integration testing of OO software
• Here, a cluster of collaborating classes is exercised by designing
Integration Testing in the OO
Context
• Object-oriented software does not have a hierarchical control
structure,
• conventional top-down and bottom-up integration strategies
have little meaning
• There are two different strategies for integration testing of
OO systems.
o 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
• Regression testing is applied to ensure that no side effects occur
o Use-based testing
• 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
• Cluster testing is one step in the integration testing of OO software
• Here, a cluster of collaborating classes is exercised by designing
Validation Testing in an OO Context
• At the validation or system level, the details of class
connections disappear
• Like conventional validation, the validation of OO
software focuses on user-visible actions and user-
recognizable outputs from the system
• To assist in the derivation of validation tests, the tester
should draw upon use cases that are part of the
requirements model
• Conventional black-box testing methods can be used to
drive validation tests
Testing Web Applications
• WEB TESTING, or website testing is checking your web
application or website for potential bugs before its
made live and is accessible to general public.
• Web Testing checks for functionality, usability, security,
compatibility, performance of the web application or
website.
• To accomplish this, a testing strategy that encompasses
both reviews and executable testing is applied.
• During this stage issues such as that of web application
security, the functioning of the site, its access to
handicapped as well as regular users and its ability to
handle traffic is checked.
Content Testing
• Errors in WebApp content can be
o as trivial as minor typographical errors or
o as significant as incorrect information, improper
organization, or violation of intellectual property
laws
• Content testing attempts to uncover these and many
other problems before the user encounters them
• Content testing combines both reviews and the
generation of executable test cases
• Reviews are applied to uncover semantic errors in
content
• Executable testing is used to uncover content errors
that can be traced to dynamically derived content that
is driven by data acquired from one or more databases.
User Interface Testing
• Verification and validation of a WebApp user interface
occurs at three distinct points
• During requirements analysis
o the interface model is reviewed to ensure that it
conforms to stakeholder requirements
• During design
o the interface design model is reviewed to ensure
that generic quality criteria established for all user
interfaces have been achieved
• During testing
o the focus shifts to the execution of application-
specific aspects of user interaction as they are
manifested by interface syntax and semantics.
• In addition, testing provides a final assessment of
usability
Navigation Testing
• The job of navigation testing is to ensure that
o the mechanisms that allow the WebApp user to
travel through the WebApp are all functional and,
o to validate that each Navigation Semantic Unit
(NSU) can be achieved by the appropriate user
category
• Navigation mechanisms should be tested are
Navigation links,
Redirects,
Bookmarks,
Frames and framesets,
Site maps,
Internal search engines.
Component-Level Testing
• Component-level testing (function testing), focuses on
a set of tests that attempt to uncover errors in WebApp
functions.
• Each WebApp function is a software component
(implemented in one of a variety of programming
languages)
o WebApp function can be tested using black-box (and
in some cases, white-box) techniques.
• Component-level test cases are often driven by forms-
level input.
o Once forms data are defined, the user selects a
button or other control mechanism to initiate
execution.
Configuration Testing
• Configuration variability and instability are important
factors that make WebApp testing a challenge.
• Hardware, operating system(s), browsers, storage
capacity, network communication speeds, and a variety
of other client-side factors are difficult to predict for
each user.
• One user’s impression of the WebApp and the manner
in which he/she interacts with it can differ significantly.
• Configuration testing is to test a set of probable client-
side and server-side configurations
o to ensure that the user experience will be the same
on all of them and,
o to isolate errors that may be specific to a particular
configuration
Security Testing
• Security tests are designed to probe
o vulnerabilities of the client-side environment,
o the network communications that occur as data are
passed from client to server and back again, and
o the server-side environment.
• Each of these domains can be attacked, and it is the
job of the security tester to uncover weaknesses
o that can be exploited by those with the intent to do
so.
Performance Testing
• Performance testing is used to uncover
o performance problems that can result from lack of
server-side resources,
o inappropriate network bandwidth,
o inadequate database capabilities,
o faulty or weak operating system capabilities,
o poorly designed WebApp functionality, and
o other hardware or software issues that can lead to
degraded client-server performance
Testing Mobile Applications
• Mobile testing or mobile application testing is a process
by which application software developed for handheld
mobile devices is tested for its functionality, usability &
consistency.
• Testing mobile application is more complex & time
consuming as compared to traditional desktop & web
applications.
Challenges in Mobile testing
• There is a huge number of mobile devices available ranging
from handsets, to smart phones, to tabs, to ipads & wearable
tech
• There is diversity in mobile network operator such as CDMA,
GSM & so on.
• A mobile app can be a native app, a web app or a hybrid app
which has both contents.
• There are different OS for mobile such as Android, ios, windows
etc.
Testing Mobile Applications
cont. used for Mobile testing
Criteria
• To ensure that it is working as per the requirements.
• To work on different OS platforms, devices & networking
environment.
• Testing the mobile app during the interrupts such as
incoming calls, SMS, notifications, data cable insertion or
removal & so on.
• For installation, un-installation, updation on the devices.
• For security i.e. to check for attacks, authentication &
data security.
Testing tools
Win Runner – Is Mercury Interactive’s enterprise
automation tool.
Features -
• Automatic Recovery
• Silent Installation
• Support for various Environments
• Cost Effective
• Support Multiple data combination
• Multiple Verification
Testing tools cont.
Load Runner – HP Load runner is a software testing tool
from Hewlett-Packard.
It is used to test applications, measuring system
behaviour & performance under load.
HP Load runner can simulate thousands of users
concurrently using application software, recording & later
analyzing the performance of key components of the
application.
Features -
• Excellent monitoring & analysis interface
• Supports other languages
• No need to install it on server
• Support for most of the commonly used protocols
• GUI generated scripts
• Quickly point out the effect of the WAN