Generate boundary Value analysis, robust and worst-case test case for the program to find the median of three numbers. Its input is a triple of positive integers (say x, y, and z) and the minimum value can be 100 and maximum can be 500.

**Median** of three numbers is the middle number when all three numbers are sorted.

**Example –**

10, 40, 20

In this case, the median is 20 (10, 20, 40).

**1. Boundary Value Test Cases** are –

for x, y, z : min value = 100 close to min = 101 nominal = 300 close to max = 499 max = 500

Test cases are,

4*3 + 1 = 13

X | Y | Z | Median |
---|---|---|---|

100 | 300 | 300 | 300 |

101 | 300 | 300 | 300 |

300 | 300 | 300 | 300 |

499 | 300 | 300 | 300 |

500 | 300 | 300 | 300 |

300 | 100 | 300 | 300 |

300 | 101 | 300 | 300 |

300 | 499 | 300 | 300 |

300 | 500 | 300 | 300 |

300 | 300 | 100 | 300 |

300 | 300 | 101 | 300 |

300 | 300 | 499 | 300 |

300 | 300 | 500 | 300 |

**2. Robust Test Cases –**

Here, we go outside the legitimate boundary, it is an extension of boundary value analysis.

for x, y, z : min value : 100 close to min : 101 nominal : 300 close to max : 499 max : 500 lesser than min value : 99 larger than max value : 501

Total test cases,

= 6*n+1 = 6*3+1 = 19

So there will be extra 6 cases apart from the above 13 cases –

X | Y | Z |
---|---|---|

99 | 300 | 300 |

501 | 300 | 300 |

300 | 99 | 300 |

300 | 501 | 300 |

300 | 300 | 99 |

300 | 300 | 501 |

**3. Worst Test Cases –**

If we reject “single” fault assumption theory of reliability, and consider cases where more than 1 variable has extreme values, then it is known as worst case analysis.

Total no. of test cases,

5^n = 5^3 = 125 cases

X | Y | Z | Median |
---|---|---|---|

100 | 100 | 100 | 100 |

101 | 100 | 100 | 100 |

300 | 100 | 100 | 100 |

499 | 100 | 100 | 100 |

500 | 100 | 100 | 100 |

100 | 101 | 100 | 100 |

101 | 101 | 100 | 101 |

300 | 101 | 100 | 101 |

499 | 101 | 100 | 101 |

… | … | … | … |

Mathematically, the test cases will be a cross product of 3 sets –

{100, 101, 300, 499, 500} x {100, 101, 300, 499, 500} x {100, 101, 300, 499, 500}

Let set A,

= {100, 101, 300, 499, 500}

So, the set of worst cases will be represented by,

= A x A x A

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Difference between Use Case and Test Case
- Boundary Value Analysis - Triangle Problem
- Boundary Value Analysis : Nature of Roots of a Quadratic equation
- Difference between Test Case and Test Script
- Test Case Prioritization in Software Testing
- Software Testing | Use Case Testing
- Difference between Test Plan and Test Strategy
- Test Driven Development (TDD)
- Software Development Engineer in Test (SDET)
- Test Coverage vs Code Coverage
- Test Configuration Generation in Combinatorial Testing
- Software Engineering | Differences between Sanity Testing and Smoke Testing
- Difference between Frontend Testing and Backend Testing
- Software Engineering | Differences between Manual and Automation Testing
- Software Engineering | Comparison between Regression Testing and Re-Testing
- Difference between Alpha and Beta Testing
- Differences between Interface and Integration Testing
- Differences between Functional and Non-functional Testing
- Differences between Testing and Debugging
- Difference between Black Box Testing and Gray Box Testing

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.