Software Testing - White Box Testing: Symbolic Testing and Path Analysis

sign test

  • Overview: Ordinary tests perform arithmetic operations, while symbolic tests perform algebraic operations, which can represent a class of tests.
    Symbolic values ​​can be elementary symbolic values ​​or expressions. Elementary symbols are strings of any variable value, and expressions are combinations of numbers, arithmetic operators, and symbolic values.
  • Symbolic execution tree
    In a conditional statement, the judgment condition is a predicate, which may be a symbolic expression, which can be true or false. Continuously constructed, a binary tree is formed, which is called a symbolic execution tree. The predicate conditions of each branch point are accumulated together and connected together with the logical multiplication symbol, and the logical expression obtained is called the path condition.
    Find the greatest common factor program flow chart
    The Symbolic Execution Tree of the Program for Finding the Greatest Common Divisor
    It should be noted that in the symbolic execution tree, the symbol value corresponding to the node corresponds to the value before the label in the flowchart. For example: the symbol value at the No. 6 node of the symbol execution tree is the value of each symbol when Q=QR has not been executed.
  • The current challenges are
    branch problems, ambiguity problems, and large program problems.

path analysis

The path in the analysis program refers to: the inspection program starts from the entrance, each statement experienced in the execution process, and ends at the exit. The test focusing on path analysis can be called path test , and the ideal situation to complete path test is to achieve path coverage .

  • Program Path Expression

    Arc Sequence Representation and Node Sequence Representation of Path
    Arc Sequence Representation and Node Sequence Representation of Path
  • The path expression
    operand refers to the arc in the control flow graph, and introduces two operations: multiplication and addition.
    ab represents the road section experienced along arc a and then along arc b.
    a + b means the relationship between two arcs is OR. (Parallel road section)
    path expression
    (a). e(a+b)(c+d)f
    (b). ab(1+cb+(cb)²+…)d
    multiplication indicates order, and does not have commutative law
  • Calculation of the number of paths in the program Calculation
    Example of Program Complexity Calculation
    formula: V=E-N+2. The complexity value V is exactly the number of rhombus judgments in its control flow diagram plus 1. At the same time, this value is also equal to the number of fields in the control flow graph that the control flow line divides the plane of the entire graph.
  • Number of independent paths The
    independent path of a certain program refers to multiple executions from program entry to exit, each time at least one statement (including operation, assignment, input and output or judgment) is new and has not been repeated. (at least one arc that has never been traveled)
    Program flow chart and control flow graph
    There are 4 independent paths in the above diagram.
  • Tree representation of program path and path encoding
    Path "and/or" trees and control flow graphs
    a. For any node N in the path tree, let u be the number of entry terminals and v the number of branches at the outflow end. We use N(u, v) to represent the node.
    b. There is one and only one root node in the path tree.
    c. Each leaf node in the path tree corresponds to an arc in its program control flow graph.
    d. For any non-root node N(u, v) in the path tree, the number u of its entry terminals must be 1.
    In the figure, or means parallel connection, and means series connection. Intermediate nodes represent arc relationships, and leaf nodes represent arcs.
  • Simplify the path tree
    a. If there is still an AND node in the child node of an AND node in the path tree, the grandchild node will be mentioned to the position of the child node, and the AND child node will be removed.
    b. If there is still an OR node in the child node of an OR node in the path tree, the grandchild node is also mentioned to the position of the child node, and the OR child node is removed.
    c. If the AND node of the path tree has a child node that is a leaf node, we can merge the leaf node into its left and right neighbor nodes, thereby eliminating the branch formed by the AND node and the leaf node.
    Simplification of the path tree
    Path simplification
    After the simplification of the above rules, any path tree will have new features, that is, any branch of each OR node is no longer an OR node, and any branch of each AND node is no longer an AND node, and it is likely to be an OR node.
    Simplified path tree
  • Path encoding
    L = [ L og 2 ( v − 1 ) + 1 ] L = [Log_2(v − 1) + 1]L=[Log2(v1)+1 ] , where v is the number of outgoing branches of the OR node, and the square brackets are rounding operations.
    The encoding of the output of the OR node
    The encoding of any path is the sequence of the output encodings of all OR nodes experienced by starting from the root node and traversing the leaf nodes of the path and then returning to the root node. Note: Edges are not double counted.
    path encoding
    Path Encoding for Simplified Trees
  • Test path enumeration
    a. Z path coverage:
    path coverage in the sense of simplified cycle is called Z path coverage. Limiting the number of loops to 0 or one is equivalent to structuring the loop into a selection structure.
    Loop structure simplified to selection structure
    b. Path enumeration:
    traverse according to the path tree to realize path enumeration.
  • Path Test System
    Loop structure simplified to selection structure

Guess you like

Origin blog.csdn.net/Bat_Reality/article/details/123949184