Testcover.com Tutorial - Functional Dependence - Calendar Example

Home
Brochure
Tutorial with Examples
->Equivalence Partitioning
--->HTML Form Example
--->Functional Dependence
----->Temperature Example
----->Calendar Example
----->Fixed Values Procedure
--->Shopping Cart Example
----->Seq. Unit Replay Design
->UML State Machines
--->Shopping Cart Example
--->Thermostat Example
->Definitions of Terms
Performance
WSDL Interface
Background
Partners
Registrations
Contact Information

The earlier calendar example shows how to set up blocks in a partition to generate test cases conforming to calendar rule constraints. The calendar example on this page illustrates functional dependence when there are two determinant factors: Given any month and year, the number of days in the month is determined. So the last day of any month can be expressed as a function of the month and year. The function last_day(month,year) is defined so that last_day(dec,2015) = 31, last_day(feb,2016) = 29, etc.

Functionally Dependent Form
The tester will use the first day, tenth day and last day of the month in the valid dates partition. The three test factors have values as follows.

Test FactorNumber of ValuesTest Factor Values
1. Month12 jan feb mar apr may jun jul aug sep oct nov dec
2. Day3 1 10 last_day(month,year)
3. Year32015 2016 2017

One of the Day values is expressed as a function of the Month and Year values. The values of Month and Year (the determinant factors) determine the value of the last day function for Day (the functionally dependent factor). There are no nondeterminant factors in this example.

The test case generator request can be expressed in terms of the function (in functionally dependent form) or in terms of its fixed values determined by the Month and Year factors (in fixed values form). The last day function is a placeholder value, to be evaluated and substituted according to the Month and Year values in the generated test cases. When Month and Year values appear with the last day function, the function's value is determined for the test case.

The test case generator request in functionally dependent form is given below.
 Calendar Example - functionally dependent form Month Day Year # valid dates partition, days 1 10 & last day + all months; first, tenth and last days; all years jan feb mar apr may jun jul aug sep oct nov dec 1 10 last_day(month,year) 2015 2016 2017

The results table follows. The date after substitution is shown in the column on the right.

#1. valid dates partition, days 1 10 & last day
TestCase ID Month Day Year ComboCountdown Date afterSubstitution 12 Values 3 Values 3 Values 81 1 jan 1 2015 78 jan 1 2015 2 jan 10 2016 75 jan 10 2016 3 jan last_day(month,year) 2017 72 jan 31 2017 4 feb 1 2016 69 feb 1 2016 5 feb 10 2017 66 feb 10 2017 6 feb last_day(month,year) 2015 63 feb 28 2015 7 mar 1 2017 60 mar 1 2017 8 mar 10 2015 57 mar 10 2015 9 mar last_day(month,year) 2016 54 mar 31 2016 10 apr 1 2015 52 apr 1 2015 11 apr 10 2016 50 apr 10 2016 12 apr last_day(month,year) 2017 48 apr 30 2017 13 may 1 2016 46 may 1 2016 14 may 10 2017 44 may 10 2017 15 may last_day(month,year) 2015 42 may 31 2015 16 jun 1 2017 40 jun 1 2017 17 jun 10 2015 38 jun 10 2015 18 jun last_day(month,year) 2016 36 jun 30 2016 19 jul 1 2015 34 jul 1 2015 20 jul 10 2016 32 jul 10 2016 21 jul last_day(month,year) 2017 30 jul 31 2017 22 aug 1 2016 28 aug 1 2016 23 aug 10 2017 26 aug 10 2017 24 aug last_day(month,year) 2015 24 aug 31 2015 25 sep 1 2017 22 sep 1 2017 26 sep 10 2015 20 sep 10 2015 27 sep last_day(month,year) 2016 18 sep 30 2016 28 oct 1 2015 16 oct 1 2015 29 oct 10 2016 14 oct 10 2016 30 oct last_day(month,year) 2017 12 oct 31 2017 31 nov 1 2016 10 nov 1 2016 32 nov 10 2017 8 nov 10 2017 33 nov last_day(month,year) 2015 6 nov 30 2015 34 dec 1 2017 4 dec 1 2017 35 dec 10 2015 2 dec 10 2015 36 dec last_day(month,year) 2016 0 dec 31 2016

Because the request is in functionally dependent form, the test case generator treats the last day function as a single value. The implications for coverage are as follows.
 • The dependent factor values give the correct function values, but all allowed values might not be covered. The last day value of 29 is missing in this example. All pairs of the determinant factors (Month and Year) are covered. But test case 4, which has feb paired with the leap year, has the fixed value 1 instead of the last day function. • If there were nondeterminant factors in this example, all allowed pairs of determinant and nondeterminant factor values would be covered. • Each nondeterminant factor value would be paired with at least one value of the function and with all the fixed values of the dependent factor.
Generally the request can be converted to fixed values form to cover all values and pairs. This approach is illustrated next. Alternatively the request can be repartitioned. This second approach is illustrated below on this page. It makes use of the fact that when all the values of the dependent factor are given by one function of two factors, all allowed values are covered.

Fixed Values Form
Converting the functionally dependent request above to fixed values form requires specific values for the last day function based on the Month and Year factor values. The fixed values can be expressed here in terms of the function's domain or in terms of the function's range, e.g. last_day(dec,2015) or 31. There are 36 allowed domain values for the last_day(month,year) function, 12 months • 3 years. However they map to only four range values (28, 29, 30 and 31). Using range values is preferable because they will require fewer blocks. Now the three test factors have values as follows.

Test FactorNumber of ValuesTest Factor Values
1. Month12 jan feb mar apr may jun jul aug sep oct nov dec
2. Day6 1 10 28 29 30 31
3. Year32015 2016 2017
The request is converted to fixed values form by replacing its block with four blocks containing the individual determinant factor values and their corresponding functionally dependent factor values.
 Calendar Example - fixed values form Month Day Year # valid dates partition, days 1 10 & last day + 31 day months; first, tenth and last days; all years jan mar may jul aug oct dec 1 10 31 2015 2016 2017 + 30 day months; first, tenth and last day; all years apr jun sep nov 1 10 30 2015 2016 2017 + 28 day month; first, tenth and last day; common years feb 1 10 28 2015 2017 + 29 day month; first, tenth and last day; leap year feb 1 10 29 2016
#1. valid dates partition, days 1 10 & last day
TestCase ID Month Day Year ComboCountdown 12 Values 6 Values 3 Values 126 1 jan 1 2015 123 2 jan 10 2016 120 3 jan 31 2017 117 4 mar 1 2016 114 5 mar 10 2017 111 6 mar 31 2015 108 7 may 1 2017 105 8 may 10 2015 102 9 may 31 2016 99 10 sep 30 2017 96 11 jun 30 2015 93 12 apr 30 2016 90 13 feb 28 2015 87 14 feb 29 2016 84 15 jul 31 2017 82 16 jul 1 2015 80 17 jul 10 2016 78 18 aug 1 2016 76 19 aug 10 2017 74 20 oct 1 2017 72 21 oct 10 2015 70 22 aug 31 2015 68 23 oct 31 2016 66 24 dec 1 2016 64 25 dec 10 2017 62 26 dec 31 2015 60 27 apr 1 2015 58 28 jun 10 2016 56 29 apr 10 2017 54 30 sep 1 2016 52 31 jun 1 2017 50 32 sep 10 2015 48 33 nov 1 2016 46 34 nov 10 2017 44 35 nov 30 2015 42 36 feb 10 2017 40 37 feb 1 2015 39 38 feb 28 2017 38

Because the request is in fixed values form, all allowed pairs are covered among all factors.

A general procedure for converting requests from functionally dependent form to fixed values form includes the approach introduced here. Example c in the procedure illustrates the case of a function of two factors when there is a nondeterminant factor.

One Function of Two Factors
The second approach to cover all pairs of all factors is to repartition the original functionally dependent request into separate partitions for the Day factor's last day function and for its fixed values. This illustration focuses on the partition for last_day(month,day).

When the last_day(month,day) function specifies all the Day values, the three test factors have values as follows.

Test FactorNumber of ValuesTest Factor Values
1. Month12 jan feb mar apr may jun jul aug sep oct nov dec
2. Day1 last_day(month,year)
3. Year32015 2016 2017

The request for this example is given below.
 Calendar Example using functionally dependent last day, without days 1 & 10 Month Day Year # valid dates partition, last day only + all months; only last day; all years jan feb mar apr may jun jul aug sep oct nov dec last_day(month,year) 2015 2016 2017

The results table follows, with the date after substitution shown in the column on the right.

#1. valid dates partition, last day only
TestCase ID Month Day Year ComboCountdown Date afterSubstitution 12 Values 1 Value 3 Values 51 1 jan last_day(month,year) 2015 48 jan 31 2015 2 feb last_day(month,year) 2016 45 feb 29 2016 3 mar last_day(month,year) 2017 42 mar 31 2017 4 apr last_day(month,year) 2015 40 apr 30 2015 5 may last_day(month,year) 2015 38 may 31 2015 6 jun last_day(month,year) 2015 36 jun 30 2015 7 jul last_day(month,year) 2015 34 jul 31 2015 8 aug last_day(month,year) 2015 32 aug 31 2015 9 sep last_day(month,year) 2015 30 sep 30 2015 10 oct last_day(month,year) 2015 28 oct 31 2015 11 nov last_day(month,year) 2015 26 nov 30 2015 12 dec last_day(month,year) 2015 24 dec 31 2015 13 jan last_day(month,year) 2016 23 jan 31 2016 14 jan last_day(month,year) 2017 22 jan 31 2017 15 feb last_day(month,year) 2015 21 feb 28 2015 16 feb last_day(month,year) 2017 20 feb 28 2017 17 mar last_day(month,year) 2015 19 mar 31 2015 18 mar last_day(month,year) 2016 18 mar 31 2016 19 apr last_day(month,year) 2016 17 apr 30 2016 20 apr last_day(month,year) 2017 16 apr 30 2017 21 may last_day(month,year) 2016 15 may 31 2016 22 may last_day(month,year) 2017 14 may 31 2017 23 jun last_day(month,year) 2016 13 jun 30 2016 24 jun last_day(month,year) 2017 12 jun 30 2017 25 jul last_day(month,year) 2016 11 jul 31 2016 26 jul last_day(month,year) 2017 10 jul 31 2017 27 aug last_day(month,year) 2016 9 aug 31 2016 28 aug last_day(month,year) 2017 8 aug 31 2017 29 sep last_day(month,year) 2016 7 sep 30 2016 30 sep last_day(month,year) 2017 6 sep 30 2017 31 oct last_day(month,year) 2016 5 oct 31 2016 32 oct last_day(month,year) 2017 4 oct 31 2017 33 nov last_day(month,year) 2016 3 nov 30 2016 34 nov last_day(month,year) 2017 2 nov 30 2017 35 dec last_day(month,year) 2016 1 dec 31 2016 36 dec last_day(month,year) 2017 0 dec 31 2017

As before, the test case generator treats the last day function as a single value. The implications for coverage are as follows.
 • All allowed values of the dependent factor are covered. All pairs of the determinant factors (Month and Year) are covered, and each pair is associated with the functionally dependent factor value as well. There is no other choice. • All allowed pairs of determinant and dependent factors are covered. The allowed values of each determinant factor are covered, and they are paired with the allowed functionally dependent factor values as well. There is no other choice. • If there were nondeterminant factors in this example, all allowed pairs of determinant and nondeterminant factor values would be covered. • Each nondeterminant factor value would be paired with at least one value of the last day function.
In this example, all allowed pairs among all factors are covered because there are no nondeterminant factors. Generally, when a dependent factor has one function of two factors, allowed pairs will be covered except for pairs of dependent and nondeterminant factor values.

In this case (one function of two factors) the functionally dependent form is not equivalent to the fixed values form. Typically all values of the dependent factor are covered, but conversion to fixed values form is required to cover all pairs.