White box understood that the example and Jacoco

Understanding and white-box testing examples (written in very good)

There are two types of commonly used software testing method: Static test method and dynamic testing methods. Wherein the static test software does not require the measuring program, mainly with some artificial simulation analysis and testing of the software actually runs on a computer; example data dynamic test software by entering a set of predetermined according to certain test criteria configuration to dynamically run the program, to achieve the discovery process-error process. Dynamic analysis techniques , the most important tests are white box and the black box. 
Wherein the test structures, also known as white box, transparent box testing, the test logic or code-based driver test. The box refers to the software being tested, the box refers to the white box is visible, you know how things inside the box and inside works. White box test to consider the extent of coverage of the internal program, the best white box is able to cover every path, but due to the great number of paths, each path to be performed is not possible. But we can do is to make coverage becomes a little higher, to introduce the following six kinds of coverage testing methods to see the extent of their coverage.

Six kinds of white-box testing :( from low to high)

Statement coverage.

Decision coverage.

Coverage.

Determination / condition coverage.

Coverage condition combination.

First, the statement coverage (Statement coverage)

( 1) Definition:

  • "Statement coverage" is a relatively weak standard test, its meaning is: in the test, several test cases designed first, and then run the program under test, so that the program executed at least once each executable statement. Then the so-called "number" is naturally better.

( 2) Design Example:

 

FIG 1 is a program to be tested, its source is: 
PROCEDURE M (on VAR A, B, X-: REAL); 
the BEGIN 
the IF (A> 1) the AND (B = 0) THENX: = X-/ A; 
the IF ( 2 = A) OR (X->. 1) THENX: = X-+. 1; 
the END.

For each statement in the program at least once, simply by designing a path ace examples can be, for example, selecting input data: 
A = 2, B = 0, X-=. 3 
so that the block of four statements They have been implemented, which was done by statement coverage. 

However, if the selected test cases are: 
A = 0 B = X-2 = -3 abe program executed by path, failed to meet the statement coverage. 

As can be seen from this example, statement coverage is actually weak, each statement in the program have been executed this point of view, the method of statement coverage seems to more fully examine each sentence. But it is by no means perfect. If the logical operation of the two blocks is determined to have a problem, if the first conditional statement AND erroneously written to OR, the above test is not find this error; if the third conditional statement X > 1 mistakenly written as X> 0, this test can not be exposed to it. in addition, along the path abd implementation, the value of X should remain unchanged, for each statement have experienced, it seems to be at ease. In fact, this test is not very reliable. In the statement coverage test test program, remove have a role in checking non-executable statement, but did not rule out the test program includes the risk of errors.

  • In short, generally considered "statement coverage" is very full of a standard.
  • You can visually obtained from the test source code, and no expression is determined for each segment.
  • Because this test method is only for an explicit statement in the program logic exists (to execute the statement), but hidden conditions and the implicit logic of the branch may arrive, it can not be tested.
  • Than "statement coverage" slightly stronger coverage criteria is "decision coverage" (known as branch coverage or branch coverage) standard. Determination means for testing coverage criteria, several test design, the program run by the side, such that each program is determined to take the true branch taken and branch experienced at least one prosthesis, i.e. the truth value are determined been satisfied. Decision coverage, also known as branch coverage.
  • FIG procedure 1, if the design of two examples, and that they can ace path ABD, ABE, or path through and acd, can achieve "decision coverage" standard, may be selected for the input data is: 
    ① A =. 3, B = 0, X = 1 (performed along path acd); ②A = 2, B = 1, X = 3 ( performed along path abe) 
  • Program statement contained in the determination comprises IF-THEN-ELSE, DO- WHILE, REPEAT-UNTIL the like, in addition to the binary decision statement, there are multi-value determination statements, the CASE statement as PASCAL, FORTRAN with the three and other branches of the IF statement. Therefore, the "Decision coverage" is a more general sense: that each determination result is obtained every possible.
  • "Coverage determination" than "statement coverage" strict, because if each branch are executed, and then each statement will execute before.
  • However, the "decision coverage" is still very inadequate, such as the above two test cases failed to check along the path abd execution, if the value of X remains unchanged. It can meet the requirements of coverage condition, but can not determine the conditions to be checked.
  • Decision coverage to more than the statement coverage almost double the testing path, of course, also stronger than the statement coverage testing capabilities. The same decision coverage and statement coverage also has the same simplicity, no subdivision each decision can get test cases.
  • Most often the decision statement is made of a combination of a plurality of logical conditions (e.g., decision statement contains AND, OR, CASE), if only the final result is determined throughout, while ignoring the value of the case of each condition will inevitably omissions some of the test path.

( 3) Advantages:

( 4) disadvantages:

Second, decision coverage (Decision coverage)

( 1) Definition:

( 2) Design Example:

( 3) Advantages:

( 4) disadvantages:

White box: statement coverage, condition coverage, decision coverage, conditions - decision coverage, covering composition, path coverage

6

1 Statement Coverage

All of the statements can execute a judgment of the case conditions, such as when the judge sentences combined sentence of thing, and with or connected to, a case can only meet

 

2 Decision coverage (branch coverage)

 For judgment statement, in the case of setting the time, to be set two kinds of cases True and False; and statements cover different is the addition of False case

 

3 condition coverage

The value for the judgment statement which cases should go once, regardless of the condition of values

 

4 determines / condition coverage

Cross each condition decision coverage covers, in the conditions for determining the value of 

 

Combination covering 5

Judgment - the conditions covered by the enhanced version 

 

 

6 Path Coverage

 

 

 

 

reference:

https://www.baidu.com/link?url=EQQ6Qc-zy1Xup2cLtHvs_3z1df9eirKEI6gmSqYaIEUGMgFus_mdGWspGYRUWncYTlUI4Q5vdJ7lMrCqBTvwxvjnrzd1MyRdPFr29yeWjQ_&wd=&eqid=dea7fa6600000e5a0000000456418b0c

http://www.cnblogs.com/jerry19880126/articles/2623433.html

http://blog.sina.com.cn/s/blog_69fe22cb0100nag2.html

 

 

Guess you like

Origin www.cnblogs.com/ITniu/p/11111729.html
Recommended