3.STQA - Unit 3 - Stat - Testing
3.STQA - Unit 3 - Stat - Testing
Static Testing
3. Static Testing
3.1. Static Techniques – Review
3.1.1. Review Process (Informal & Formal)
3.1.2. Desk Checking,
3.1.3. Technical or Peer Review
3.1.4. Walkthrough
3.1.5. Inspection
3.2. Static Techniques – Static Analysis
3.2.1. Data flow analysis
3.2.2. Control flow analysis,
3.2.3. Static Analysis by Tools (Automated Static Analysis)
Case Study on Preparation of Inspection Checklist
Static testing
• Static testing is a verification process used to test the application without
implementing the code of the application. And it is a cost-effective process.
• To avoid the errors, we will execute Static testing in the initial stage of
development because it is easier to identify the sources of errors, and it can
fix easily.
• In other words, we can say that Static testing can be done manually or with
the help of tools to improve the quality of the application by finding the error
at the early stage of development; that is also called the verification process.
• We can do some of the following important activities while performing static
testing:
• Business requirement review ,Design review ,Code walkthroughs,The test
documentation review
When we performed Static Testing?
Functional •The functional requirement validation activity is used to make sure that all necessary
Requirements elements identify correctly.
Validation •And it also took care of the software, interface listings, network requirements,
hardware, and database functionality.
Field Dictionary •In the field dictionary validation, we will test each field in the user interface specified
Validation to create field-level validation test cases.
•And we can check the fields for error messages, minimum or maximum length, list
values, etc.
Prototype/Screen •The prototype validation activity contains the authentication of requirements and uses
Mockup Validation cases.
Static Testing Techniques
Review
• In static testing, the review is a technique or a process implemented to find the
possible bugs in the application. We can easily identify and eliminate faults and
defects in the various supporting documents such as SRS [Software
Requirements Specifications] in the review process.
• In other words, we can say that a review in Static Testing is that where all the
team members will understand about the project's progress.
• In static testing, reviews can be divided into four different parts, which are as
follows:
1. Informal reviews
2. Walkthroughs
3. Technical/peer review
4. Inspections
• Informal reviews
• Control flow testing is a testing technique that comes under white box
testing. The aim of this technique is to determine the execution order
of statements or instructions of the program through a control
structure. The control structure of a program is used to develop a test
case for the program. In this technique, a particular part of a large
program is selected by the tester to set the testing path. It is mostly
used in unit testing. Test cases represented by the control graph of the
program.
• Control Flow Graph is formed from the node, edge, decision node,
junction node to specify all possible execution path.
Notations used for Control Flow Graph
1. Node
2. Edge
3. Decision Node
4. Junction node
Node
• Nodes in the control flow graph are used to create a path of procedures.
Basically, it represents the sequence of procedures which procedure is next
to come so, the tester can determine the sequence of occurrence of
procedures.
• We can see below in example the first node represent the start procedure
and the next procedure is to assign the value of n after assigning the value
there is decision node to decide next node of procedure as per the value of n
if it is 18 or more than 18 so Eligible procedure will execute otherwise if it
is less than 18 Not Eligible procedure executes. The next node is the
junction node, and the last node is stop node to stop the procedure.
• Edge
• Edge in control flow graph is used to link the direction of nodes.
• We can see below in example all arrows are used to link the nodes in an
appropriate direction.
• Decision node
• Decision node in the control flow graph is used to decide next node of
procedure as per the value.
• We can see below in example decision node decide next node of procedure as
per the value of n if it is 18 or more than 18 so Eligible procedure will
execute otherwise if it is less than 18, Not Eligible procedure executes.
• Junction node
• Junction node in control flow graph is the point where at least three links
meet.
Example
public class VoteEligiblityAge{
public static void main(String []args){
int n=45;
if(n>=18)
{
System.out.println("You are eligible for voting");
} else
{
System.out.println("You are not eligible for voting");
}
} }
Diagram - control flow graph
• The above example shows eligibility criteria of age for voting where if age
is 18 or more than 18 so print message "You are eligible for voting" if it is
less than 18 then print "You are not eligible for voting."
• Program for this scenario is written above, and the control flow graph is
designed for the testing purpose.
• In the control flow graph, start, age, eligible, not eligible and stop are the
nodes, n>=18 is a decision node to decide which part (if or else) will
execute as per the given value. Connectivity of the eligible node and not
eligible node is there on the stop node.
• Test cases are designed through the flow graph of the programs to
determine the execution path is correct or not. All nodes, junction, edges,
and decision are the essential parts to design test cases.
Cyclomatic complexity
• Cyclomatic complexity is a software metric used to measure the
complexity of a program.
• Thomas J. McCabe developed this metric in 1976.
• McCabe interprets a computer program as a set of a strongly
connected directed graph.
• Nodes represent parts of the source code having no branches and
arcs represent possible control flow transfers during program
execution.
• The notion of program graph has been used for this measure, and it
is used to measure and control the number of paths through a
program.
• The complexity of a computer program can be correlated with the
topological complexity of a graph.
What is Cyclomatic Complexity?
• Cyclomatic complexity is a source code complexity measurement that is being
correlated to a number of coding errors.
• It is calculated by developing a Control Flow Graph of the code that measures
the number of linearly-independent paths through a program module.
• McCabe proposed the cyclomatic number, V (G) of graph theory as an
indicator of software complexity. The cyclomatic number is equal to the
number of linearly independent paths through a program in its graphs
representation. For a program control graph G, cyclomatic number, V (G), is
given as:
• Cyclomatic complexity(G) = E - N + 2*P
E = number of edges in the flow graph.
N = number of nodes in the flow graph.
P = number of nodes that have exit points
Example
IF A = 10 THEN
IF B > C THEN
A=B
ELSE
A=C
ENDIF
ENDIF
Print A
Print B
Print C
Cyclomatic Complexity
= Total number of closed regions in the control
1. { int i, j, k; flow graph + 1
2. for (i=0 ; i<=N ; i++) =3+1
3. p[i] = 1; =4
• Associations
• In associations we list down all the definitions with all of its uses.
• (1, (2, f), x), (1, (2, t), x), (1, 3, x), (1, (4, t), x), (1, (4, f), x), (1, (5, t), x),
(1, (5, f), x), (1, 6, x), (1, 7, x), (6,(5, f)x), (6,(5,t)x), (6, 6, x), (3, 8, a), (7,
8, a).
How to make associations in data flow testing
<link>
• (1, (2, t), x), (1, (2, f), x)- This association is made with statement 1 (read x;) and
statement 2 (If(x>0)) where x is defined at line number 1, and it is used at line
number 2 so, x is the variable.
• Statement 2 is logical, and it can be true or false that's why the association is
defined in two ways; one is (1, (2, t), x) for true and another is (1, (2, f), x) for false.
• (1, 3, x)- This association is made with statement 1 (read x;) and statement 3 (a=
x+1) where x is defined in statement 1 and used in statement 3. It is a computation
use.
• (1, (4, t), x), (1, (4, f), x)- This association is made with statement 1 (read x;) and
statement 4 (If(x<=0)) where x is defined at line number 1 and it is used at line
number 4 so x is the variable. Statement 4 is logical, and it can be true or false that's
why the association is defined in two ways one is (1, (4, t), x) for true and another
is (1, (4, f), x) for false.
• (1, (5, t), x), (1, (5, f), x)- This association is made with statement 1 (read x;) and
statement 5 (if (x<1)) where x is defined at line number 1, and it is used at line
number 5, so x is the variable.
• Statement 5 is logical, and it can be true or false that's why the association is
defined in two ways; one is (1, (5, t), x) for true and another is (1, (5, f), x) for false.
• (1, 6, x)- This association is made with statement 1 (read x;) and statement 6 (x=x+1). x is
defined in statement 1 and used in statement 6. It is a computation use.
• (1, 7, x)- This association is made with statement 1 (read x) and statement 7 (a=x+1). x is
defined in statement 1 and used in statement 7 when statement 5 is false. It is a
computation use.
• (6, (5, f) x), (6, (5, t) x)- This association is made with statement 6 (x=x+1;) and statement
5 if (x<1) because x is defined in statement 6 and used in statement 5. Statement 5 is
logical, and it can be true or false that's why the association is defined in two ways one is
(6, (5, f) x) for true and another is (6, (5, t) x) for false. It is a predicted use.
• (6, 6, x)- This association is made with statement 6 which is using the value of variable x
and then defining the new value of x.
• x=x+1
• x= (-1+1)
• Statement 6 is using the value of variable x that is ?1 and then defining new value of x [x=
(-1+1) = 0] that is 0.
• (3, 8, a)- This association is made with statement 3(a= x+1) and statement 8 where variable
a is defined in statement 3 and used in statement 8.
• (7, 8, a)- This association is made with statement 7(a=x+1) and statement 8 where variable
a is defined in statement 7 and used in statement 8.
• Definition, c-use, p-use, c-use some p-use coverage, p-use some c-use coverage in data
flow testing <link>
• The next task is to group all the associations in Definition, c-use, p-use, c-use some p-use
coverage, p-use some c-use coverage categories.
• So, these are the all association which contain definition, Predicate use (p-use),
Computation use (c-use)
• (1, (2, f), x), (1, (2, t), x), (1, 3, x), (1, (4, t), x), (1, (4, f), x), (1, (5, t), x), (1, (5, f), x), (1,
6, x), (1, 7, x), (6,(5, f)x), (6,(5,t)x), (6, 6, x), (3, 8, a), (7, 8, a), (3, 8, a), (7, 8, a)
• Definition
• Definition of a variable is the occurrence of a variable when the value is
bound to the variable. In the above code, the value gets bound in the first
statement and then start to flow.
7
Inspection Process
Planning: Identifies work product to be inspected, determines the size and composition
of the inspection team, and sets the inspection schedule.
Overview: Optional phase where team members who are unfamiliar with the work product
to be inspected receive orientation.
Preparation: Team members inspect the work individually looking for defects in the work
product with the guidance of relevant checklist.
-The majority of defects found in inspection processes are found in this stage (about 75%);
-The reviewer should record any issues found, and determine their severity (i.e., major or minor):
• major for a defect that will cause an observable product failure or departure from requirements;
• minor for a defect that will not cause a failure in execution of the product.
-At this stage, it is strictly required that reviewers work individually and do not attempt to find 8
solutions to defects found as this is an improper use of their time.
Inspection Process (ctd.)
Inspection Meeting: Inspection team members meet to discuss possible defects in the work
product. The moderator should ensure that all the issues raised by individual reviewers are
appropriately logged.
Rework: The work product is revised to conform to requirements and specifications.
Follow up: The rework is verified, final inspection data is collected and summarized, and the
inspection is officially closed. At this stage also, the moderator may calculate certain metrics
to assess the effectiveness of the inspection and recommend improvement to the inspection
process. 9
-Example of Individual Reviewer Log form (used during preparation stage)
10
-Example of Log form (used during meeting phase)
Date: 14 March 2003
Team: D T 1
Part/Level: W C M S - H L D - 1 - 0 3 Cycle: 1
Moderator: M. Python Owner: M. Bean
Engineer Data
Defect Data
Totals: 8 9
Uni que Defects: 2 3
Inspection S u m m a r y Product Size: 15 Size Measure: pages
Total Defects for J.B: 8 Total Defects for R . M : 9 C o m m o n Defects:
6
Est. Total Defects: Total N u m b e r Found: N u m b e r Left:
15
5. Inspection Metrics
-The data collected during a software process are used to compute a set
of metrics that support evaluation and improvement of the process as
well as planning and tracking quality.
-The metrics computed during such process should be defined by the
requirements of your organization (typically in the quality manual).
The collection of data and calculation of metrics for no reason is a waste of time.
Where A and B are the number found by reviewer A and B respectively and C is
the number found by both A and B.
-Defect density is the ratio of the number of defects found to the size
of the artifact. It is given by
Where the size of the artifact is measured in number of pages, loc, or other size measure.
17
Example: compute inspection metrics from the following inspection log form
Team: D T 1
Date: 14 March 2003
Part/Level: W C M S - H L D - 1 - 0 3 Cycle: 1
Moderator: M. Python Owner: M. Bean
Engineer Data
Defect Data
Totals: 8 9
Uni que Defects: 2 3
Inspection S u m m a r y Product Size: 15 Size Measure: pages
Total Defects for J.B: 8 Total Defects for R . M : 9 C o m m o n Defects:
6
Est. Total Defects: Total N u m b e r Found: N u m b e r Left:
Note that in practice such assumptions are not always fulfilled, simply because some
defects are harder to find than others, and some reviewers are better than others.
20
Inspection Yield
-Inspection yield refers to the defect removal efficiency (DRE) of an
inspection process.
21
Inspection Rate and
Defect Detection Rate
-Requires computing the inspection time, which is the sum of each
reviewers review time plus the total person time spent in each meeting.
-The inspection rate is computed by:
Where:
size stands for the size of the artifact in number of pages, loc, or other size measure.
total inspection time measured in hours
22
Calculating Inspection Metrics with
more than two Reviewers
-If there are more than 2 reviewers, the same approach can be taken
to calculate inspection totals and yield by grouping reviewers into
two groups for calculation: group A and group B:
If there are 3 reviewers, it is often a good idea to choose the person who has the most
unique defects to be one group and the other two reviewers to be the other group. For
each group if any member of that group has found a defect, then count it for the group.
23
Example with 3 reviewers:
No. Defect Description Engineers (finding major defects)
R1 R2 R3 A (R2) B
1 1 1
1 1
1 1
1 1 1
1 1 1
1 1
1 1
1
1
1
1 1 1
Totals 7 9 7
Unique defects 1 2 0