Everyone thinks the writing is okay, you can like, bookmark, and pay attention to it!
You can also visit my personal blog , it is estimated that it will be updated in recent years! Be friends with me! https://motongxue.cn
Article directory
Chapter 3 White Box Testing
-
White-box testing: A test of how the program unit under test works internally , characterized by the source code of the program under test rather than the software's requirements specification.
-
in principle
- Ensure that all independent paths in a module are tested at least once.
- All logical values are tested for both true and false values.
- Check the internal data structure of the program to ensure the validity of its structure.
- Run all loops within upper and lower bounds and within operable range.
-
Test Methods
-
review
-
Four elements of a formal review
-
determine the problem
-
obey the rules
-
Prepare
-
write report
-
-
Purpose
- find bugs in software
-
-
walk through
-
test
-
-
Static white-box testing (structured analysis): does not execute the software
-
Flow diagrams are also called program diagrams: nodes, control flow lines
-
basic structure
- sequential structure
- branch structure
- loop structure
-
Cyclomatic complexity
- A software metric that provides a quantitative measure of program logic complexity
- Commonly used in basic path testing method
- The number of linearly independent directed cycles in a strongly connected flow graph is the cyclomatic complexity of the program.
- calculation method
- V(G)=m-n+p
- Add a dashed arc from the exit point to the entry point . At this time, the flow graph becomes a strongly connected graph.
- m represents the number of directed edges in the directed graph G;
- n represents the number of nodes in the directed graph;
- p represents the number of independent connected regions that can be separated in the directed graph G, which is a constant of 1.
- V(G) = the number of areas enclosed by the strongly connected flow graph on the plane
- V(G) = number of decision nodes + 1
- V(G)=m-n+p
-
Dynamic White Box Testing
- Generate test cases according to certain steps and methods, and drive related modules to execute the program and find errors and defects in the software.
- The logic coverage method and the basic path method are often used to design white-box test cases.
-
Logical coverage method (increasing order by ability to find errors)
- Override method:
- Statement coverage: every statement is executed at least once
- Decision coverage: each branch of each decision (the entire final result, the difference from conditional coverage) is executed at least once
- Condition coverage: Each small condition in each judgment is executed at least once according to "true" and "false".
- Decision/Condition Coverage: Satisfy the requirements of both decision coverage and condition coverage
- Condition combination coverage: Find all possible combination values of all conditions in the judgment, and execute each possible condition combination at least once
- Improved decision/condition coverage (MC/DC coverage)
- Path coverage: all possible paths are executed at least once
- Linear Code Sequence and Jump Coverage (LCSAJ): It consists of an ordered sequence of code that ends with a jump to the beginning of another code sequence
- Coverage = (number of tested items that are executed at least once) / total number of tested items
- Override method:
-
Basic path method (independent path testing)
- Refers to any path in a program that introduces at least one new statement or a new condition
- The basic steps of basic path testing are:
- Export the control flow graph of the program flow chart according to the program design results;
- Calculate the cyclomatic complexity of the program;
- Export the basic path set to determine the independent path of the program;
- According to the independent path, design the corresponding test cases.
-
cycle test
- Principle: Execute the loop body at the loop boundary and run limit.
- loop structure
- simple loop
- Concatenated loops (parallel loops): independent loops? Simple Loops: Nested Loops
- nested loop
-
data flow test
-
basic concept
- c-use: A variable is used in an expression of an assignment statement, in an output statement, or passed as a parameter to a calling function, or used in a subscript expression
- p-use: a variable is used in the conditional expression of the branch statement
- We only care about the definition and use of global variables, and the local definition and use are meaningless when studying data flow-based testing .
-
Data flow graph (DFG/def-use graph)
- The basic process of constructing a data flow graph:
- Compute def, c-use, and p-use for each basic block in the program.
- Associate each node in the node set with its corresponding def, c-use, and p-use.
- For each node that has a non-empty p-use set and ends at condition C, if condition C is true, edge 1 is executed, and when C is false, edge 2 is executed, and edge 1, edge 2 and C ,! C is connected.
- The basic process of constructing a data flow graph:
-
def-clear path
- Suppose variable x is defined in node i and used in node j. For the path
p={i,n1,n2,…,nk,j}
,k≥0
, and nodes i and j have not appeared in subpaths n1, n2, ..., nk, variable x has not been used in subpaths Redefine , say p is the def-clear path of variable x.
- Suppose variable x is defined in node i and used in node j. For the path
-
def-use pairs
-
Any variable x, from its definition to its use constitutes a specific def-use pair of this variable.
-
Classification
-
dcu
-
dpu
-
variable (v) The node where the definition is located (n) dcu(v,n) dpu(v,n) x 1 {2} {(1,2),(1,3), (3,5),(3,4)} y 1 {4} {(1,2),(1,3)} z 1 {2,4,5} {(3,5),(3,4)} z 2 {2,4,5} {(3,5),(3,4)} z 4 {2,4,5} {(3,5),(3,4)}
-
-
-
def-use chain
- The concept of a def-use pair can be extended to an alternate definition and use sequence of variables , which is also called a def-use chain or k-dr interaction. The nodes in the def-use chain vary . k indicates the length of the chain, the letter d means "definition", and the letter r means "reference".
-
Optimization: The data flow graph can reduce the number of def-use pairs to be covered.
-
-
-
White box testing application example - triangle problem
-
practise
-
What is white box testing? What are the methods of static white box testing? And briefly describe it?
-
What are the basic principles of loop testing? What kinds of situations are often considered in the test cycle?
-
How many types of white box testing processes are there? What are the types of common white box testing problems?
-
Updated on December 20, 2020
Everyone thinks the writing is okay, you can like, bookmark, and pay attention to it!
You can also visit my personal blog , it is estimated that it will be updated in recent years! Be friends with me! https://motongxue.cn