Testcover.com Testcover.com
Tutorial - Functional Dependence -
Calendar Example

Home
Existing User Login
Brochure
Sign up for Risk-Free Trial
About Testcover.com
Frequently Asked Questions
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
Test
Case ID
Month Day Year Combo
Countdown
Date after
Substitution
12 Values3 Values3 Values81
1jan1201578jan 1 2015
2jan10201675jan 10 2016
3janlast_day(month,year)201772jan 31 2017
4feb1201669feb 1 2016
5feb10201766feb 10 2017
6feblast_day(month,year)201563feb 28 2015
7mar1201760mar 1 2017
8mar10201557mar 10 2015
9marlast_day(month,year)201654mar 31 2016
10apr1201552apr 1 2015
11apr10201650apr 10 2016
12aprlast_day(month,year)201748apr 30 2017
13may1201646may 1 2016
14may10201744may 10 2017
15maylast_day(month,year)201542may 31 2015
16jun1201740jun 1 2017
17jun10201538jun 10 2015
18junlast_day(month,year)201636jun 30 2016
19jul1201534jul 1 2015
20jul10201632jul 10 2016
21jullast_day(month,year)201730jul 31 2017
22aug1201628aug 1 2016
23aug10201726aug 10 2017
24auglast_day(month,year)201524aug 31 2015
25sep1201722sep 1 2017
26sep10201520sep 10 2015
27seplast_day(month,year)201618sep 30 2016
28oct1201516oct 1 2015
29oct10201614oct 10 2016
30octlast_day(month,year)201712oct 31 2017
31nov1201610nov 1 2016
32nov1020178nov 10 2017
33novlast_day(month,year)20156nov 30 2015
34dec120174dec 1 2017
35dec1020152dec 10 2015
36declast_day(month,year)20160dec 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
Test
Case ID
Month Day Year Combo
Countdown
12 Values6 Values3 Values126
1jan12015123
2jan102016120
3jan312017117
4mar12016114
5mar102017111
6mar312015108
7may12017105
8may102015102
9may31201699
10sep30201796
11jun30201593
12apr30201690
13feb28201587
14feb29201684
15jul31201782
16jul1201580
17jul10201678
18aug1201676
19aug10201774
20oct1201772
21oct10201570
22aug31201568
23oct31201666
24dec1201664
25dec10201762
26dec31201560
27apr1201558
28jun10201656
29apr10201754
30sep1201652
31jun1201750
32sep10201548
33nov1201646
34nov10201744
35nov30201542
36feb10201740
37feb1201539
38feb28201738

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
Test
Case ID
Month Day Year Combo
Countdown
Date after
Substitution
12 Values1 Value3 Values51
1janlast_day(month,year)201548jan 31 2015
2feblast_day(month,year)201645feb 29 2016
3marlast_day(month,year)201742mar 31 2017
4aprlast_day(month,year)201540apr 30 2015
5maylast_day(month,year)201538may 31 2015
6junlast_day(month,year)201536jun 30 2015
7jullast_day(month,year)201534jul 31 2015
8auglast_day(month,year)201532aug 31 2015
9seplast_day(month,year)201530sep 30 2015
10octlast_day(month,year)201528oct 31 2015
11novlast_day(month,year)201526nov 30 2015
12declast_day(month,year)201524dec 31 2015
13janlast_day(month,year)201623jan 31 2016
14janlast_day(month,year)201722jan 31 2017
15feblast_day(month,year)201521feb 28 2015
16feblast_day(month,year)201720feb 28 2017
17marlast_day(month,year)201519mar 31 2015
18marlast_day(month,year)201618mar 31 2016
19aprlast_day(month,year)201617apr 30 2016
20aprlast_day(month,year)201716apr 30 2017
21maylast_day(month,year)201615may 31 2016
22maylast_day(month,year)201714may 31 2017
23junlast_day(month,year)201613jun 30 2016
24junlast_day(month,year)201712jun 30 2017
25jullast_day(month,year)201611jul 31 2016
26jullast_day(month,year)201710jul 31 2017
27auglast_day(month,year)20169aug 31 2016
28auglast_day(month,year)20178aug 31 2017
29seplast_day(month,year)20167sep 30 2016
30seplast_day(month,year)20176sep 30 2017
31octlast_day(month,year)20165oct 31 2016
32octlast_day(month,year)20174oct 31 2017
33novlast_day(month,year)20163nov 30 2016
34novlast_day(month,year)20172nov 30 2017
35declast_day(month,year)20161dec 31 2016
36declast_day(month,year)20170dec 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.

<Temperature Conversion Example Fixed Values Procedure>

Copyright © 2003-2017 Testcover.com, LLC. All rights reserved.