程序代写代做代考 C 7CCSMASE

7CCSMASE
Tutorial 8 (Week 9) Solution
1.
• Target2, none, none / ii) Comes closest, since in this test a=b, which is closest to having
a>b (in other test vectors, a hit target 4
• It is impossible to have a test suite with 100% branch coverage, since the branch True
from “if (c==3)” is unreachable. The test suite T = {<43,42,0>, <1,2,2>,<1,2,3>} covers all branches.
2. Branch Coverage: In branch coverage you should test both branches, so a test that assigns FFF (false to a, b, and c) and a test that assigns TTT will together cover both branches.
Condition Coverage: In condition coverage, you should test both values for all three conditions, so a test that assigns FFT and a test that assigns TTF will together cover all conditions – but both lead to the if branch!
MC/DC coverage: In MC/DC coverage, you should come up with 4 tests that together have 100% MC/DC. It is not trivial at all. Here is the process for ((a &&b) || c). First of all, in order for a and b to make a difference in the value (a && b), one of the assignments should be TT. Then, changing either a or b to F separately will change the value of (a && b) from T to F. In order for this value to have an effect on the value of the overall compound condition, the value of c should be F (as otherwise, even if (a && b) is F, the value T of c will result in T as the final value of the compound condition). Hence, the first test is TTF. Now, it is clear that changing either a or b to F separately will change the value of the overall expression to F. Hence, the next two tests are FTF and TFF. The last test can be, for example, TFT, as it differs from TFF only in the value of c, and the value of the compound condition for TFT is true. Hence, the answer is {TFF, TFT, FTF, TTF}.
*MC/DC is modified condition/decision coverage. It requires that for each condition x in a compound condition (in the example, a, b, and c are conditions in the compound condition ((a&&b)||c) ) the following holds:
There exists a test where x is T and another test where x is F, and the rest of the conditions have exactly the same values in both tests;
The value of the compound condition is T for one of these tests and is F for another (that is, the condition x can affect the outcome).

For a compound condition of size N (that is, consisting of N simple conditions), there always exists a test suite of N+1 tests that has 100% MC/DC.
One example:
For (a || b || c), the set of tests with 100% MC/DC is FFF, TFF, FTF, FFT.
3.