# Statement test and coverage ###### tags: `White Box Testing Tech` `ISTQB` `Software Testing` `SQA` ## Statement testing and coverage Statement testing is testing aimed at exercising programming statements. Remember: **we are only interested in executable statements**, so we do not count non-executable statements at all **when we are measuring statement coverage** Having explored flow charts and flow graphs a little, you will see that flow charts are very good at showing you where the executable statements are; **they are all represented by diamonds or rectangles and where there is no rectangle there is no executable code.** ![](https://i.imgur.com/R3IrrbY.png) ![](https://i.imgur.com/qxWBs5y.png) By setting A = 2 and X = 2 at point a, every statement will be executed once. ==However, what if the first decision should be an OR rather than an AND? The test would not have detected the error, since the condition will be true in both cases.== :question: ==Similarly, if the second decision should have stated X > 2 this error would have gone undetected because the value of A guarantees that the condition is true. Also, there is a path through the program in which X goes unchanged (the path abeh). If this were an error it would also go undetected.== :question: :::success 只用都執行過的方式,就會檢查不出一些狀況,就如上面兩個情況,這就是他要表達的意思。 ::: ![](https://i.imgur.com/oflDeE0.png) How many test cases would be needed for 100 per cent statement coverage? A: 4 test case 80,60,40,38 >Exercise 4.8 Now using the program Grading in Exercise 4.7 again, try to calculate whether 100 per cent statement coverage is achieved with a given set of data (this would be a K4 level question in the exam). Suppose we ran two test cases, as follows: Test Case 1 StudentScore = 50 Test Case 2 StudentScore = 30 :::info 1. Would 100 per cent statement coverage be achieved? ::: :::success A: No ::: :::info 2. If not, which lines of pseudo code will not be exercised? ::: :::success A:11,14 will not exercise. :::