Tutorial-3: To Generate BVA Test Cases-For the Next Date Function
Before we generate the test cases for the Next Date Function problem, firstly we need to define the problem domain as described below.
Problem Domain: “Next Date” is a function consisting of three variables like: month, date and year. It returns the date of next day as output. It reads current date as input date.
The conditions are
C1: 1 ≤ month ≤ 12
C2: 1 ≤ day ≤ 31
C3: 1900 ≤ year ≤ 2025.
If any one condition out of C1, C2 or C3 fails, then this function produces an output “value of month not in the range 1…12”.
Since many combinations of dates can exist, hence we can simply displays one message for this function : “Invalid Input Date”.
Complexities in Next Date
FunctionA very common and popular problem occurs if the year is a leap year. We have taken into consideration that there are 31 days in a month. But what happens if a month has 30 days or even 29 or 28 days ?
A year is called as a leap year if it is divisible by 4, unless it is a century year. Century years are leap years only if they are multiples of 400. So, 1992, 1996 and 2000 are leap years while 1900 is not a leap year.
Furthermore, in this Next Date problem we find examples of Zipf’s law also, which states that “80% of the activity occurs in 20% of the space”. Thus in this case also, much of the source-code of Next Date function is devoted to the leap year considerations.
Objective of this Tutorial: How to Generate BVA Test Cases for this problem?
The Next Date program takes date as input and checks it for validity. If it is valid, it returns the next date as its output.
Here we have three inputs for the program, hence n = 3.
Since BVA yields (4n + 1) test cases according to single fault assumption theory, hence we can say that the total number of test cases will be (4*3+1)=12+1=13.
The boundary value test cases are
Test Case ID | Month (mm) | Day (dd) | Year (yyyy) | Expected Output |
1 | 6 | 15 | 1900 | 16 June, 1900 |
2 | 6 | 15 | 1901 | 16 June, 1901 |
3 | 6 | 15 | 1962 | 16 June, 1962 |
4 | 6 | 15 | 2024 | 16 June, 2024 |
5 | 6 | 15 | 2025 | 16 June, 2025 |
6 | 6 | 1 | 1962 | 2 June, 1962 |
7 | 6 | 2 | 1962 | 1 June, 1962 |
8 | 6 | 30 | 1962 | 1 July 1962 |
9 | 6 | 31 | 1962 | Invalid Date as June has 30 Days |
10 | 1 | 15 | 1962 | 16 January, 1962 |
11 | 2 | 15 | 1962 | 16 February, 1962 |
12 | 11 | 15 | 1962 | 16 November, 1962 |
13 | 12 | 15 | 1962 | 16 December, 1962 |
This is how we can apply BVA technique to create test cases for our Next Date Problem.
Many More Articles & Tutorials on Black Box Testing
An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.