SUBSCRIBE TO MY CHANNEL

Five Test Automation Mistakes to Avoid - Must watch for testers!

How to be successful QA leader? - Future leaders, QA Leads and Managers

LATEST THINKING

Monday, August 8, 2016

ISTQB: Easiest way to solve statement and branch coverage problems.

12:17:00 AM Posted by Prashant Hegde 59 comments
Several ISTQB aspirants face issues in answering the statement and branch coverage questions. These questions are really important to clear ISTQB certification.I got emails from several aspirants where they have asked me doubts on statements and branch coverage. So I decided to write this post.

Before learning how to solve these problem one needs to know the basics of  drawing flow chart.
Flowcharts use special shapes to represent different types of actions or steps in a process. Lines and arrows show the sequence of the steps, and the relationships among them. These are known as flowchart symbols.



STATEMENT COVERAGE

You can say you have achieved 100% statement coverage if your test cases executes every statement in the code at-least once.

Let's solve a problem on statement coverage so that you know how to solve such question when asked in exam.

How many test case are required to achieve 100% statement coverage?

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




Tip: To achieve 100% statement coverage you need to execute all the statements (represented with rectangular boxes).You need to find out the shortest number of paths following which all the nodes will be covered. 

As you seen in diagram below in one path we can cover all statements. So 1 test case is enough to achieve 100% statement coverage.

If you are flying with an economy ticket, there is a possibility that you may get upgraded to business class, especially if you hold a gold card in the airline's frequent flier program. If you don't hold a gold card, there is a possibility that you will get 'bumped' off the flight if it is full and you check in late. This is shown in Figure 4.5.
Note that each box (i.e. statement) has been numbered. Three tests have been run:

Test 1: Gold card holder who gets upgraded to business class
Test 2: Non-gold card holder who stays in economy
Test 3: A person who is bumped from the flight

What is the statement coverage of these three tests?
a. 60%
b. 70%
c. 80%
d. 90%


The answer is 80%. There are 10 statements(boxes) and 8 have been covered by the tests run.



BRANCH/DECISION COVERAGE:

Branch coverage is also known as Decision coverage. It covers both the true and false conditions unlike statement coverage. We can say we have achieved 100% decision coverage if all the edges in the flow charts are covered by your test case.

How many test case are required to achieve 100% decision coverage?

Switch PC on
Start "outlook"
IF outlook appears THEN
Send an email
Close outlook
We need 2 test cases to achieve 100% decision coverage. 2 paths will ensure covering of all the edges as shown is figure below:

How many test cases are required for 100% decision coverage?

Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF



With 2 paths we can cover all the edges. So 2 test cases are required for 100% decision coverage.
Tips
  • Cover all nodes for 100% statement coverage. 
  • Cover all edges for 100% decision coverage.

You are often asked minimum number of test cases required to cover 100%statement and branch coverage in ISTQB exams.
PATH COVERAGE:
To achieve 100% path Coverage you need to cover all the paths from start to end. As far as I know you wont get questions to calculate path coverage in ISTQB certification exam.

How many test cases are required for 100% path coverage?

Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF



As shown in the illustration above, 4 test cases are required for 100% path coverage.

1A-2B-E-4F
1A-2B-E-4G-5H
1A-2C-3D-E-4G-5H
1A-2C-3D-E-4F

Remember
  1. Branch coverage and Decision coverages are one and the same
  2. 100% LCSAJ(Linear Code Sequence and Jump.) coverage implies 100% Branch/Decision coverage
  3. 100% Path coverage implies 100% Statement coverage
  4. 100% Branch/Decision coverage implies 100% Statement coverage
  5. 100% Path coverage implies 100% Branch/Decision coverage
I have tried to explain the statement and decision coverage with simple techniques. I hope it helps!


RECOMMENDED BOOK FOR ISTQB NEW SYLLABUS
                                                                    




59 comments:

Naveen Kumar S said...

Thanks for your effort :-)

poonampreet said...
This comment has been removed by the author.
poonampreet said...

Thanks,great explanation.

Sari said...

Very detailed Explanation.Thank You

Unknown said...

Hi Prashant, Could you please solve this as well for both branch and statement coverage? Thanks!
IF A > B THEN

C = A – B

ELSE

C = A + B

ENDIF

Read D

IF C = D Then

Print “Error”

ENDIF

Sherlin Jones said...
This comment has been removed by a blog administrator.
Unknown said...

It helps alot ...easily understable with examples

Unknown said...

What are nodes and edges? can you elaborate?

Suba said...

Testing mould our application without any bugs. As you said Testing field is peak in software industry. I like your way of writing. I am the one who is interested to learn testing blogs, eagerly waiting for the next article from you.
Regards:
Software training institutes in chennai
Software testing training institutes in chennai

UNKNOWN said...

Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

Best Selenium Training in Chennai



Anonymous said...

Such easy explaination.

David Miller said...

I visit the website more times to know more information. This post about to solving statement and branch coverage problems very easy way. I am waiting for your next post about Personal Statement Review information.

Unknown said...

Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area. Digital Marketing Training in Chennai

Andreas said...

Thank you very much!

NAINA said...

you are the real hero. I read your article. IU think you always follow google Update. I see you are used info graphic Video for information article website. I love the skill. thans.

Steven G. Kingsley said...

Glad to know this information.

Steven G. Kingsley said...

This is wonderful article about solution of statement and branch coverage problem. Here you have provided great explanation with some diagram. This statement solution system should helpful for students. Also you can visit our site to take personal statement writing help. Thanks for sharing useful post.

Unknown said...

Excellent explanation

Anonymous said...

Your explanation is the best one for me, after countless blogwalking. Thank you very much. Please continue blogging!

sheran said...

wooow Thanks well explained.

Edward said...

Really nice topics you had discussed above. I am much impressed. Thank you for providing this nice information here

Software Testing Company

Mobile Game Testing

Gameplay Testing

Switch Game Testing

Anonymous said...

Very good explanation!Thanks a lot!!

Nisuga Jayawardana said...

what if there is a while loop like this??
Is there Any easy method to get the minimum number of required test cases?

intf1(int x, int y){
while (x != y){
if (x>y)
x=x-y;
else y=y-x;
}
return x; }

Chris Hemsworth said...

The article is so informative. This is more helpful. Thanks for sharing.
Learn best software testing online certification course class in chennai with placement
Best selenium testing online course training in chennai
Best online software testing training course institute in chennai with placement

divi said...

Really nice blog, I enjoyed your information. Thank you and I will expect more in the future.
web design company in velachery

Anonymous said...

Good effort. Specially the animated example. Some of the examples and content seems to be have been referred from ISTQB Guru

source said...

Looks easy enough (sarcasm). Thanks for the content though.

Anonymous said...

This was really helpful

thank you very much!!!

kloudportal said...

Thank you for sharing this post
Very nice post here thanks for it I always like and search such topics and everything connected to them.
Online Exam Software

Anonymous said...

Very useful article while preparing for ISTQB exam! Thanks :)

Y Hasnat said...
This comment has been removed by the author.
Aipmca said...

Web Designer in Noida
Best Website Development service In Noida
Website Designing service In Noida
Best digital marketing service In Noida
Best digital marketing Company in Noida
Indian Bookmarking list
Indian Bookmarking list
India Classified Submission List
Indian Classified List

yadav said...


Nice Blog. Keep update more information about this..
IELTS Coaching in Chennai
IELTS coaching in bangalore
IELTS coaching centre in coimbatore
IELTS coaching in madurai
IELTS Coaching in Hyderabad
Best ielts coaching in bangalore
ielts training in bangalore
ielts coaching centre in bangalore
ielts classes in bangalore
ethical hacking course in bangalore

Allen Marry said...

The information which you have provided is very good. It is very useful who is looking for Game testing services

merlin said...

As you said Testing field is peak in software industry. I like your way of writing. I am the one who is interested to learn testing blogs, eagerly waiting for the next article from you.
Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery




Edward said...

Thank you so much for this nice information. Hope so many people will get aware of this and useful as well. And please keep update like this.

Game QA Solutions

PC Game Testing Services

WOW said...

thank u

WOW said...

Description:-
The West Bengal Police is one of the two police forces of the Indian state of West Bengal. The West Bengal Police was reorganized under provisions of the Police Act 1861 during the British Raj.

Here you can find West Bengal Police full mock test in Bengali. You will get a free mock test for West Bengal Police.

sathya said...

There are many things I agree with in this post. Enjoyed the simplicity. Thanks for the post. If you want to learn

Selenium Training in Chennai | Certification | Online Courses

selenium training in chennai

selenium training in chennai

selenium online training in chennai

selenium training in bangalore

selenium training in hyderabad

selenium training in coimbatore

selenium online training

sara mohamed said...

شركة تنظيف بخميس مشيط
شركة تنظيف منازل بخميس مشيط
تنظيف سجاد بخميس مشيط
شركة تنظيف مجالس بخميس مشيط
شركة تنظيف سجاد بابها
شركة رش مبيدات بابها
شركة تنظيف فلل بابها
شركة تنظيف سجاد بابها
شركة تنظيف كنب بابها
شركة تنظيف سجاد ومجالس بابها
شركة تنظيف خزانات بابها
شركة تنظيف منازل بابها

COCOTECH said...

Amazing to peruse this sorts of blog, continue giving the new updates. Continue sharing Thanks... Regards Activated carbon manufacturing companies in India

branding companies in chennai said...

The article unambiguously top branding companies in chennai indicated every one of the positive and negative sides of the issue I'm exceptionally bewildered with the nature of the substance which you have written down. This is a marvelous article! Your article has all the essential data on the individual theme branding companies in chennai

borav said...

Hi! I simply need to offer you a major approval for your incredible data you have here on this post. I'll be returning to your site for all the more soon.
live

sam said...

After reading your article I was amazed. I know that you explain it very well.

IELTS Institute in Ambala
Best IELTS Coaching in Ambala

Ramesh Sampangi said...

Really an awesome blog. Informative and knowledgeable content. I enjoyed while reading your article. Keep sharing more stuff like this. Thank you.
Data Science Course Training in Hyderabad with Placements

anish said...

Useful post with valuable information .thanks for sharing updates.
Ielts Coaching In Bangalore


ISWARYASEO said...

Companies can provide personalized support to their employees and resolve issues in a matter of seconds. AI is used in these platforms to provide streamlined support to employees with a single platform that handles all employee queries.

Click here: AI service desk

bharti said...

Really great article, Glad to read the article. It is very informative for us. Thanks for posting. And also visit for good quality Zirconia Crown In India

نقل اثاث دبي said...


شركة ليلى نقل اثاث دبي هي شركة تقدم خدمات المنزلية و أثاث المكاتب
و الفنادق داخل الإمارات المتحدة في أي وقت و في كل مكان.
نقل اثاث الشارقة
نقل اثاث دبي
نقل اثاث عجمان
نقل اثاث ابوظبي
نقل اثاث العين

rita said...

Target 9 Band Institute provides the best IELTS Classes in Ambala and Best PTE coaching in Ambala. We have won the faith of thousands of students who have studied from us. Enrolling for IELTS/PTE/TOEFL/Spoken English course with us will give you multiple benefits.

Fleek IT Solutions said...

Great share! Thanks for the information. Keep going!

shazam said...

Great share. thanks for the information keep going..
Main KW: Abogados de bancarrota cerca de mí
Secondary KWs: Abogados de bancarrota capítulo 7 cerca de mí

Anonymous said...

Qman is an IT Training and Development company. We provide Best Software testing services in india .
Thank you for sharing this website.

Wiztech automation solutions pvt.ltd said...

Thanks for sharing!!
embedded training center in Chennai
best embedded training institute in Chennai
plc training center in Chennai
plc scada vfd dcs hmi training institute in Chennai
best final year Project center in Chennai

Digital Arnav said...

At our Automation Testing Training Institute in Noida, we understand the growing demand for skilled automation testers in the software development sector. Our curriculum is carefully designed to cover all aspects of automation testing, including test automation frameworks, scripting languages, industry-standard tools, and best practices. What sets us apart from other training institutes is our focus on hands-on learning. We believe in the principle of "learning by doing," and our training modules are designed to provide ample opportunities for students to apply their knowledge in real-world scenarios. Through practical assignments and projects, students gain valuable experience and develop the confidence to tackle real-world automation testing challenges.

Blogger said...

Nice article. Thank you so much for sharing. Know about Bitwissend, website design company kottayam.

Mohit Kumar said...

Looking for reliable Functional Testing services in Noida? Our expert team in Noida offers comprehensive functional testing solutions to ensure your software operates flawlessly. With rigorous testing methodologies, we identify and rectify glitches, enhancing user experience. Trust us for top-notch functional testing in Noida, delivering seamless and robust software.

VISWA Technologies said...

Hi Thanks for such a wonderful article, this informative article is a lifesaver for those who want to rank their website in the top search results. Keep sharing! thanks
Saviynt Training
Mevn Stack Training

Mohit Kumar said...

We've compiled a list of the Functional Testing services in Noida in this blog comment. You can learn more about them and select the one that best suits your business needs.

Popular Posts

Total Pageviews