Thread: Decision coverage testing - Question

1. Decision coverage testing - Question

Hi all,

I am new to testing. I am reading the Art of Software testing book to understand concepts. I am having a little confusion.

DO K=0 TO 50 WHILE (J+K&lt;QUEST)

is one of the example, the books suggests while talking about decision coverage.

Question: As per the definition of Decision coverage, atleast one test case must be written to execute the true branch and false branch and point of entry must be invoked atleast once.

Therefore in the above example there should be test cases for J+K&lt;QUEST leading to true condition and J+K&lt;QUEST leading to false condition to satisfy decision coverage from my understanding.

While the book talks about Condition coverage, it reverts to the above example and following lines are mentioned -
If you are using decision testing,the criterion can be satisfied by letting the loop run from K=0 to 50, without ever exploring the circumstance where the WHILE clause becomes false.

Why? This contradicts my understanding of Decision coverage definition. Please clarify. Any help is highly appreciated.

Regards,
Balaji S

2. Re: Decision coverage testing - Question

The information to the above reference from the book is also available in the link
http://testdesigners.com/testingstyles/ControlFlowTesting.html for any one to refer to.

3. Re: Decision coverage testing - Question

Hi Balaji,

Although I like Myers' book, the example used is a bit obscure.

An easier way to think about decision vs. condition testing is how we design our tests to analyze a predicate statement in code. For example,

if (a &gt; b) {
...// do something
}

is a simple Boolean expression and the type of test is a simple decision coverage test in which the conditional expression (predicate statement) should be evaluated to true and to false.

But, lets look at another example.

if (a &gt; b &amp;&amp; b &gt; c) {
... // do something
}

In this case we need 2 tests for decision coverage (true and false branch). The first test is a &lt;= b which will cause both conditional expressions to short circuit and the Boolean expression will be false. The second test is a &gt; b and b &gt; c which will cause both conditional expressions to resolve as true.

For condition coverage we need 3 tests.
a &gt; b and b &gt; c
a &lt;= b
a &gt; b and b &lt;= c

Condition coverage evaluates the true and false outcome for each conditional expression in a predicate statement. Decision coverage only evaluates the true and false outcome of a predicate statement regardless of the number of conditional expressions in the predicate statement.

A good ref. is http://shemesh.larc.nasa.gov/fm/pape...10876-MCDC.pdf

Hope that helps
Bj

4. Re: Decision coverage testing - Question

Thanks Bj. I think for your second example, in condition coverage the focus in covering all possibilities of conditions.

There are two conditions. (a&gt;b, b&gt;c) Therefore the possibilities are,

1. a&gt;b
2. a&lt;=b
3. b&gt;c
4. b&lt;=c

Test cases
a=3, b=4, c=5 covers 1, 3.
a=3, b=3, c=3 covers 2, 4.

Don't you agree?

5. Re: Decision coverage testing - Question

Hi Balaji,

Your second test does not cover the false outcome of b &gt; c because in most cases when the first conditional expression as false in a compound predicate statement control flow will will short-circuit around that predicate statements block.

Of course, there are cases where short circuiting is not used. But, there also used to be a time when people drilled holes in other people's heads to relieve headaches.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:57 PM.