Friday 24 August 2012

Decision Coverage and Branch Coverage (Asked in ISTQB)


Q.  How many test cases are necessary to cover all the possible sequences of statements (paths) for the following program fragment? Assume that the two conditions are independent of each other:

if (Condition 1)
then statement 1
else statement 2
fi
if (Condition 2)
then statement 3
fi

A. 2 Test Cases
B. 3 Test Cases
C. 4 Test Cases
D. Not achievable

Answer:-A

Q: Given the following:

Switch PC on
Start "outlook"
IF outlook appears THEN
Send an email
Close outlook

A. 1 test for statement coverage, 1 for branch coverage
B. 1 test for statement coverage, 2 for branch coverage
C. 1 test for statement coverage. 3 for branch coverage
D. 2 tests for statement coverage, 2 for branch coverage
E. 2 tests for statement coverage, 3 for branch coverage

Answer:-B


Q. IF A > B THEN
C = A – B
ELSE
C = A + B
ENDIF
Read D

IF C = D Then
Print "Error"
ENDIF

A. 1 test for statement coverage, 3 for branch coverage
B. 2 tests for statement coverage, 2 for branch coverage
C. 2 tests for statement coverage. 3 for branch coverage
D. 3 tests for statement coverage, 3 for branch coverage
E. 3 tests for statement coverage, 2 for branch coverage

Answer:-B

Q: Consider the following:

Pick up and read the newspaper
Look at what is on television
If there is a program that you are interested in watching then switch the the television on and watch the program
Otherwise
Continue reading the newspaper
If there is a crossword in the newspaper then try and complete the crossword

A. SC = 1 and DC = 1
B. SC = 1 and DC = 2
C. SC = 1 and DC = 3
D. SC = 2 and DC = 2
E. SC = 2 and DC = 3

Answer:-E

Q: Given the following code, which is true about the minimum number of test cases required for full statement and branch coverage:

Read P
Read Q
IF P+Q > 100 THEN
Print "Large"
ENDIF

If P > 50 THEN
Print "P Large"
ENDIF

A. 1 test for statement coverage, 3 for branch coverage
B. 1 test for statement coverage, 2 for branch coverage
C. 1 test for statement coverage, 1 for branch coverage
D. 2 tests for statement coverage, 3 for branch coverage
E. 2 tests for statement coverage, 2 for branch coverage

Answer:-B



Q:Disc = 0
Order-qty = 0
Read Order-qty
If Order-qty >=20 then
Disc = 0.05
If Order-qty >=100 then
Disc =0.1
End if
End if

A. Statement coverage is 4
B. Statement coverage is 1
C. Statement coverage is 3
D. Statement Coverage is 2


Answer:-B



Q. What is the smallest number of test cases required to Provide 100% branch coverage?

If(x>y) x=x+1;
else y=y+1;
while(x>y)
{
y=x*y; x=x+1;
}

A. 1
B. 2
C. 3
D. 4

Answer:-B


Q: If the pseudo code below were a programming language ,how many tests are required to achieve 100% statement coverage?

1. If x=3 then
2. Display_messageX;
3. If y=2 then
4. Display_messageY;
5. Else
6. Display_messageZ;
7. Else
8. Display_messageZ;

A. 1
B. 2
C. 3
D. 4


Answer:-C



Q:Using the same code example as question 17,how many tests are required to achieve 100% branch/decision coverage?

A. 1
B. 2
C. 3
D. 4


Answer:-C

Q: This part of a program is given:

WHILE (condition A) Do B
END WHILE
How many decisions should be tested in this code in order to achieve 100% decision coverage?

A. 2
B. Indefinite
C. 1
D. 4

Answer:-A



Q.: Analyze the following highly simplified procedure:

Ask: "What type of ticket do you require, single or return?"
IF the customer wants ‘return’
Ask: "What rate, Standard or Cheap-day?"
IF the customer replies ‘Cheap-day’
Say: "That will be £11:20"
ELSE
Say: "That will be £19:50"
ENDIF
ELSE
Say: "That will be £9:75"
ENDIF

Now decide the minimum number of tests that are needed to ensure that all the questions have been asked, all combinations have occurred and all replies given.

A. 3
B. 4
C. 5
D. 6
Answer:-A

Q: For the following piece of code, how many test cases are needed to get 100% statement coverage?

Procedure X
Read (Color) // Input color from user
IF (Color == “Red”) THEN
Call Roses(Color)
ELSEIF (Color == “Blue”) THEN
Call Violets(Color)
ELSE
PRINT “User is no Shakespeare”
SaveToDatabase(Color)
End Procedure X

 A. 5
B. 3
C. 1
D. 2

Answer:-B




51 comments:

  1. Hi can anyone explain how these answers are right for better understanding.
    thanks

    ReplyDelete
    Replies
    1. on which question you need help?

      Delete
    2. Q: If the pseudo code below were a programming language ,how many tests are required to achieve 100% statement coverage?

      1. If x=3 then
      2. Display_messageX;
      3. If y=2 then
      4. Display_messageY;
      5. Else
      6. Display_messageZ;
      7. Else
      8. Display_messageZ;

      A. 1
      B. 2
      C. 3
      D. 4

      plz explain it ...


      Answer:-C

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Can anyone please explain for 1st question ans is A
    I think the ans is C

    Q. How many test cases are necessary to cover all the possible sequences of statements (paths) for the following program fragment? Assume that the two conditions are independent of each other:

    if (Condition 1)
    then statement 1
    else statement 2
    fi
    if (Condition 2)
    then statement 3
    fi

    A. 2 Test Cases
    B. 3 Test Cases
    C. 4 Test Cases
    D. Not achievable

    Answer:-A

    ReplyDelete
    Replies
    1. Yes, that's right. The answer should be C i.e. 4 test cases:

      TC1: condition1=T, condition2=T
      TC2: condition1=F, condition2=T
      TC3: condition1=T, condition2=F
      TC4: condition1=F, condition2=F

      Delete
    2. Assume the program like this –
      If the age is greater than 60 years
      Then provide 25% senior citizen discount (Statement 1)
      Else no discount (Statement 2)

      If the age is less than 5 years
      Then provide special seat (Statement 3)

      These are two independent code snippets. How many test cases do you require to cover the above statements? If you carefully choose to minimize the number of test cases, then 2 test cases would be enough. However, if it were an actual test scenario we will have more tests.

      What are those 2 test cases?
      1. Input age more than 60 (say 65 years). Covers statement 1.
      2. Input age less than 5 (say 4 years). Covers statement 2 and statement 3.

      Delete
  4. Learn to draw flow diagrams, then solving will be easy! Happy learning! :)

    ReplyDelete
    Replies
    1. please tell me how to calculate statement and decision coverage. provide any files which will help.

      Delete
  5. could you please explain

    Q: This part of a program is given:

    WHILE (condition A) Do B
    END WHILE
    How many decisions should be tested in this code in order to achieve 100% decision coverage?

    thank you

    ReplyDelete
    Replies
    1. I also have same doubt..plz help

      Delete
    2. Correct answer is 2 because there are two possible value "True"&"False" for Condition A:
      1) condition A == True
      2) condition A == False

      Delete
  6. Hi,
    When I was studying for ISTQB...
    There was no site in which consist of only number of examples with branch and statement coverage...
    so, I gathered all the examples and put them together. So, that anyone who is preparing for ISTQB...can get it!

    Thanks
    Vrushali...

    ReplyDelete
    Replies
    1. could you pls send the gathered docs to mailid ; kcholetti@gmail.com

      Delete
    2. Hi , Can you plz send the gathered docs to me as well (Poonam ) ; dulletpoonam@gamil.com

      Delete
    3. sorry ,it is...dulletpoonam@gmail.com.

      Delete
    4. Hi, can u please send me the questions ;
      osbihat@hotmail.com

      Delete
  7. Hi Vrushali
    I appreciate you and your blog for a very good initiative.

    could you please help me in answering this question :
    Given the following code, which is true:
    IF A > B THEN
    C = A ? B
    ELSE
    C = A B
    ENDIF

    Read D
    IF C = D Then
    Print ?Error?
    ENDIF
    1 test for statement coverage, 3 for branch coverage
    2 tests for statement coverage, 2 for branch coverage
    2 tests for statement coverage, 3 for branch coverage
    3 tests for statement coverage, 3 for branch coverage

    ReplyDelete
  8. How do you define a testing policy?
    oracle training in chennai
    The following are the important steps used to oracle dba training in chennai define a testing policy in general. But it can change according to your organization. hadoop training in chennai Let's discuss in detail the steps of implementing a testing policy in an organization.

    ReplyDelete
  9. An electronic program guide service downloads TV listing data once setup data has been downloaded either with the digital tuner, or the analog tuner (if present), or an external receiver (if defined): The following tests have been executed for the control flow diagram above:

    Test1: No setup data could be found, first with the digital tuner, then with the analog tuner, and finally with an external receiver.

    Test2: Setup and TV listing data has been downloaded with the digital tuner.

    Test3: Setup and TV listing data has been downloaded with the analog tuner.

    What is the decision coverage of these three tests?

    a. 100%
    b. 51%
    c. 70%
    d. 0%

    ReplyDelete
  10. pls ans on above que.

    I guess the ans is 'a' but not sure

    ReplyDelete
  11. Please ans below ques
    Q. 2 Which of the following is an objective of a pilot project for the introduction of a testing tool?
    A. Evaluate testers’ competence to use the tool.
    B. Complete the testing of a key project.
    C. Assess whether the benefits will be achieved at reasonable cost.
    D. Discover what the requirements for the tool are.

    Q. 3 Which of the following is a TYPICAL objective of a pilot project for introducing a testing tool into an organization?
    A. To assess whether the benefits will be achieved at a reasonable cost
    B. To identify the initial requirements of the tool
    C. To select the most suitable tool for the intended purpose
    D. To document test design and test execution processes

    Q. 4 Which of the following is NOT a goal of a Pilot Project for tool evaluation?
    A. To evaluate how the tool fits with existing processes and practices.
    B. To determine use, management, storage, and maintenance of the tool and test assets.
    C. To assess whether the benefits will be achieved at reasonable cost.
    D. To reduce the defect rate in the Pilot Project.

    ReplyDelete
  12. Pick up and read the newspaper
    Look at what is on television
    If there is a program that you are interested in watching then switch the the television on and watch the program
    Otherwise
    Continue reading the newspaper
    If there is a crossword in the newspaper then try and complete the crossword

    E. SC = 2 and DC = 3
    please give me explanation.

    ReplyDelete
  13. • Thanku for shariong..
    Informatica training, in the recent times has acquired a wide scope of popularity amongst the youngsters at the forefront of their career.
    sas training in chennai

    ReplyDelete
  14. • Nice Blog It's such a useful information to all
    qtp training in chennai

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Can anyone explain?
    Q: If the pseudo code below were a programming language ,how many tests are required to achieve 100% statement coverage?

    1. If x=3 then
    2. Display_messageX;
    3. If y=2 then
    4. Display_messageY;
    5. Else
    6. Display_messageZ;
    7. Else
    8. Display_messageZ;

    A. 1
    B. 2
    C. 3
    D. 4
    and test cacses required for banch coverage too for the same question?

    ReplyDelete
    Replies
    1. 3 tests are required for 100 % statement coverage.
      1)if x=3 ,display x
      2)if y=3 ,display y
      3)if x not equal to 2 or y not equal to 3, display z

      Delete
  17. Procedure X
    Read (Color) // Input color from user
    IF (Color == “Red”) THEN
    Call Roses(Color)
    ELSEIF (Color == “Blue”) THEN
    Call Violets(Color)
    ELSE
    PRINT “User is no Shakespeare”
    SaveToDatabase(Color)
    End Procedure X

    Answer is 2 test cases for 100% statement coverage, but how is it 3

    ReplyDelete
  18. 1. If x=3 then
    2. Display_messageX;
    3. If y=2 then
    4. Display_messageY;
    5. Else
    6. Display_messageZ;
    7. Else
    8. Display_messageZ;

    Can any one explain plzz...

    ReplyDelete
  19. I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guys I’ve added you guys to my blog roll.
    Best digital marketing training Institute in chennai

    ReplyDelete
  20. I am really happy with your blog because your article is very unique and powerful for new reader.
    Click here:
    Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune | Selenium online Training

    ReplyDelete
  21. I’ve bookmarked your site, and I’m adding your RSS feeds to my Google account.
    nebosh igc courses in chennai

    ReplyDelete
  22. I am commenting to let you know what a terrific experience my daughter enjoyed reading through your web page. She noticed a wide variety of pieces, with the inclusion of what it is like to have an awesome helping style to have the rest without hassle grasp some grueling matters.
    Best training in Blockchain in kk nagar chennai |Check Best Training @ Chennai in KK nagar, vadapalani in chennai |Blockchain institute in Chennai | Blockchain
    Check Best Software Testing Training institute in KK nagar, Chennai | Software Courses| Real time Projects
    Web designing training
    DevOps Training

    ReplyDelete
  23. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    Data Science Training in ChennaiKK Nagar | Data Science Course in Chennai
    Python Course in Chennai KK Nagar | Python Training Course Institutes in Chennai
    RPA Training in Chennai KK Nagar | RPA Training in Chennai

    ReplyDelete
  24. I ‘d mention that most of us visitors are endowed to exist in a fabulous place with very many wonderful individuals with very helpful things.

    Best PHP Training Institute in Chennai|PHP Course in chennai
    Best .Net Training Institute in Chennai
    Dotnet Training in Chennai
    Dotnet Training in Chennai

    ReplyDelete
  25. Such a great information for blogger i am a professional blogger thanks…

    Start your journey with Best SAP Course and get hands-on Experience with 100% Placement assistance from experts Trainers @Softgen Infotech Located in BTM Layout Bangalore. Expert Trainers with 8+ Years of experience, Free Demo Classes Conducted.

    ReplyDelete
  26. I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking automated software testing training the time to discuss this, I feel happy about it and I love learning more about this topic.

    ReplyDelete
  27. Really Good tips and advises you have just shared. Thank you so much for taking the time to share such a piece of nice information. Looking forward for more views and ideas, Keep up the good work! Visit here for Product Engineering Services | Product Engineering Solutions

    ReplyDelete
  28. Thanks for posting the best information and the blog is very helpful.I also want to share some information about Signova

    ReplyDelete