Thanks:  0
Likes:  0
Dislikes:  0

# Thread: Calculate a number of test cases:

1. ## Calculate a number of test cases:

Suppose here a code:
int n1, n2, n3, n4;
If(n1&gt;n2)
{
Print "n1"
}
else
Print "n2"
If(n3&gt;n4)
Print "n3"
Else
Print "n4".
Print "Welcome" ;

So Calculate how many test cases is there, and give the reason .

2. ## Re: Calculate a number of test cases:

Is this an interview question, or an exam question?

3. ## Re: Calculate a number of test cases:

Ah - 19,476

How many are relevant? THAT is a different question...

Like Joe, I am curious as to the purpose and source of the question.

4. ## Re: Calculate a number of test cases:

[ QUOTE ]
Ah - 19,476

[/ QUOTE ]
[img]/images/graemlins/grin.gif[/img]

5. ## Re: Calculate a number of test cases:

Dear Joe ;
I am not testing your quality and just i put my question and as simple as possible can you give me the proper answer and reason.
Thanks and Regards.
Sun.

6. ## Re: Calculate a number of test cases:

Dear Sun,

Ok.

The proper answer is that there are an infinite number of test cases one could perform on the code snippet you have presented.

The reason is that there are always more test cases that could be created.

Hope that helps.

(BTW, learning the answer to my question might have helped place your post in the most appropriate forum to get a helpful response. It's a shame that you chose not to answer.)

7. ## Re: Calculate a number of test cases:

OK, I'll approach this from a different angle....

Can you explain the reason why you are asking about test cases for a particular snippet of code?

Unless I have been tasked with unit testing some section or module of code, I typically don't worry too much about it. Then again, the shops I have worked in, the programmers (ok, developers) are tasked with doing their unit tests, not testers.

Instead, we build tests, hence test cases, around the intent of the function or process. We look to exercise the software to find true behavior and present our findings to management (project, team, whatever) and stakeholders. The programmers/developers can argue that "the code is right" all they want. If the function/need is not being fulfilled, then it is not "right" - based on the model of the business users/customers/project stakeholders.

So, can you explain what prompted your question? Then, perhaps, we can talk about what it is that you are trying to find.

8. ## Re: Calculate a number of test cases:

dear Walen;
i want to know just how many test cases are required for 100% decision coverage? for the given code below.and please give reason behind your answer. just i want to learn from you.
Thanks and regards.
Sun.

if width &gt; length
then
biggest_dimension = width
if height &gt; width
then
biggest_dimension = height
end_if
else
biggest_dimension = length
if height &gt; length
then
biggest_dimension = height
end_if
end_if

9. ## Re: Calculate a number of test cases:

So you are only interested in Decision Coverage test cases? That, I fear, is a small subset of the total cases - which is what I thought you were asking in the initial question.

So, is evaluating code to determine the number of test cases really the question? Or are you in need of the number of test cases to determine wich of the variables has the greatest/highest value.

Perhaps, another question is, does the code do what it is intended to do?

The reason I ask is, quite simply, the code snippet and the psuedo code do different things. (The initial snippet had 4 variables, the psuedo/plain-language code has 3.) Was that intentional?

Frankly, this looks like an academic exercise, or maybe a discussion in theory. The reason I say this is it appears from your wording (granted I suspect that English is not your primary language and there are often translation things that happen) that you are looking for the "correct" (or as you say "proper" answer. I can give you an answer. Joe can give you an answer - they may not agree, we could both be wrong, or right.

Is your intent to learn about Decision coverage or Line and Branch coverage? If that is the case, I would be happy to discuss this with you. Sorry to say, I do not believe me giving you a number, and saying "here's why" does you or anyone else reading this much good.

I would be happy to explain the steps I go through in these types of situations, then helping you find the answer to your own question. I've done this at workshops with people several times - most recently at STPCon this past October.

10. ## Re: Calculate a number of test cases:

3

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.