1. ## Testcases Design

Design test cases for the following function:
int max(int a, int b, int c){...}
this method will return the maximum value among three parameters:a,b,and c.

The following is my own design:

Case 1: 1, 1, 1
Case 2: 1, 2, 3
Case 3: 1, 2, 2
Case 4: 1.5, 1, 1
Case 5: 1, 1.5, 1
Case 6: 1, 1, 1.5

I used equivalence class partitioning technology. I don't think it is necessary to do boundary value analysis.

If I am not correct, please do not hesitate to point it out. Thanks a lot!

2. ## Re: Testcases Design

I think Case 5 and Case 6 are not required

3. ## Re: Testcases Design

[ QUOTE ]
Design test cases for the following function:

[/ QUOTE ]

Interview question?

4. ## Re: Testcases Design

[ QUOTE ]
I don't think it is necessary to do boundary value analysis.

[/ QUOTE ]

5. ## Re: Testcases Design

Is there a reason that you didn't include negative numbers, or cases in which the maximum value is an integer in parameter a or b?

6. ## Re: Testcases Design

Considering that a data type of int represents a whole number your cases 4, 5, and 6 won't compile or will throw an exception because you can't pass a non-int argument to a type int parameter. (Of course, ignoring non-strongly typed languages.)

As Burzmali suggests...you might also consider negative numbers, but basically this is essentially a permutation problem. So you need at least 3 tests in which the largest int is passed to each of the 3 input params. Another in which all are equal, and then permutations of 2 params that are identical and the 3rd param of lessor value.

I agree with your assertion to preclude boundary testing based on the stated function, but would be interested in hearing your rationale.

7. ## Re: Testcases Design

Just a small thing to add related to equivalent classes.

If you are looking for real life scenarios you should invest more in other invalid classes that tend to be problematic and many times not covered by developers.

Such as not-a-number and empty or blank spaces.

But if what you are looking is for an answer to an exam you should be covered by the above.

#### 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.