Basic strategies for test coverage of software testing

Reprinted at: http://www.51testing.com/html/09/n-3726309.html

 

Introduction to Software Test Coverage
  1. Definition: Coverage is a measure used to measure test integrity and a measure of the effectiveness of testing techniques.
  2. Calculation: Coverage = (number of items executed at least once)/total number of items
  3. Features
  1) Through coverage data, we can detect whether our test is sufficient
  2) Analyze the weaknesses of the test
  3) Guidance We design test cases that can increase the coverage rate and effectively improve the test quality, but the test case design cannot blindly pursue the coverage rate, because the test cost increases with the increase of the coverage rate.
  

Classification of software test coverage
  Coverage can be roughly divided into three categories according to test methods, namely white-box coverage, gray-box coverage and black-box coverage.
  

White-Box Coverage
  The most common one used in white-box coverage is Logical Coverage, also called Code Coverage or Structural Coverage. We commonly The logical coverage includes: statement coverage, decision coverage, condition coverage, decision condition coverage, condition combination coverage, and path coverage.
  

1. Statement Coverage
  1) Definition: During testing, after running the program under test, the ratio of executable statements executed in the program.
  2) Calculation formula: statement coverage = (number of statements executed at least once) / (total number of executable statements)
  3) 100% statement coverage meaning: when testing, first design several test cases, and then run the tested program so that each executable statement in the program is executed at least once.
  4) Features: Statement coverage can check each executable statement, but even if the statement coverage reaches 100%, there will be defects that cannot be found, so the coverage is only our measure.
  

2. Decision Coverage/Branch Coverage
  1) Definition: During testing, after running the program under test, the ratio of true and false branches of all judgment statements in the program are executed.
  2) Calculation formula: Judgment coverage rate = (number of times judgment results are evaluated) / (total number of judgment results)
  3) 100% conditional coverage rate Meaning: During testing, first design several test cases, and then run the test program, so that The true branch and false branch of each judgment in the program go through at least one time, that is, the true and false values ​​of the judgment have been satisfied.
  4) Features
  (1) If it is determined that the coverage reaches 100%, the statement coverage must be 100%.
  (2) Even if the judgment coverage reaches 100%, there will be defects that cannot be found.
  

3. Condition Coverage
  1) Definition: During the test, after running the program under test, the ratio of possible values ​​(true and false) of each condition in all judgment statements in the program occurred.
  2) Calculation formula: Condition coverage = (number of conditional operation values ​​evaluated at least once)/(total number of conditional operation values)
  3) 100% conditional coverage means: During testing, first design several test cases, and then run The program being tested must satisfy at least one possible value of each condition in each judgment.
  4) Features: Test cases that cover conditions do not necessarily cover judgments.
  

4. Decision Condition Coverage/Branch Condition Coverage
  1) Definition: During testing, after running the program under test, the possible values ​​of each condition in all judgment statements in the program (true value) and false values) and the ratio of occurrences of the judgment result (true or false) of each judgment itself.
  2) Calculation formula: Judgment-Condition Coverage = (Number of Conditional Operation Values ​​or Judgment Results that have been evaluated at least once)/(Total Number of Conditional Operation Values ​​+ Total Judgment Results)
  3) 100% Judgment-Condition Coverage Meaning: Design Sufficient test cases such that all possible values ​​of each condition in the judgment are executed at least once, and all possible results of each judgment itself are executed at least once. In other words, all possible value combinations of each judgment are required to be executed at least once.
  4) Features
  (1) Judgment-condition coverage is actually a combination of judgment coverage and condition coverage.
  (2) Using decision-condition coverage, errors in logical expressions may not necessarily be found.
  

5. Condition combination coverage (Condition combination coverage)
  1) Definition: During the test, after running the program under test, the ratio of all possible value result combinations of atomic conditions in all statements.
  2) Calculation formula: Condition combination coverage = (Condition combination that is executed at least once)/(Total possible number of condition combinations)
  3) 100% Condition combination coverage means: Design enough test cases to make the judgment of the condition All possible combinations have occurred at least once.
  4) Features: If the condition combination coverage rate is 100%, the statement coverage rate, judgment coverage rate, condition coverage rate, and judgment-condition coverage rate must be 100%.
  

6. Path Coverage
  1) Definition: During testing, after running the program under test, the ratio of all possible paths in the program being executed.
  2) Calculation formula: path coverage = (number of paths executed at least once)/(total number of paths)
  3) 100% path coverage means: Design enough test cases to cover all possible paths in the program.
  4) Features
  (1) Path coverage is stronger than judgment condition coverage, but cannot include judgment condition coverage.
  (2) If the path coverage rate is 100%, the statement coverage rate and the judgment coverage rate must be 100%.
  Summary: Logic coverage can be used as a measure of software testing, but even if 100% logic coverage is achieved, the correctness of the program cannot be guaranteed.
  

Gray-Box Coverage (Gray-Box Coverage)
Function coverage and interface coverage can be classified as gray-box testing.
1. Function coverage

  1) Definition: It indicates which functions have been tested in the test, how often they are tested, and how much these functions account for in all functions of the system.
  2) Calculation formula: function coverage = (number of functions executed at least once)/(total number of functions in the system)
  3) Features: It is tested for a system or subsystem.
  

2. Interface Coverage/Entry-Point Coverage
  1) Definition: It is required that each interface of the system be tested by designing certain use cases.
  2) Calculation formula: interface coverage = (number of interfaces executed at least once)/(total number of interfaces in the system)
  

Black-box coverage (Black-Box Coverage)
  In actual testing, the coverage related to the black box is relatively small, mainly the function coverage (Function Coverage), the most common of which is the requirement coverage.
  

Requirement coverage
  1) Definition: It indicates which functions have been tested in the test, how often they are tested, and how much these functions account for in all functions of the system. By designing certain test cases, each All requirements are tested.
  2) Calculation formula: requirement coverage = (number of verified requirements) / (total total requirements)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325274226&siteId=291194637