 Testcover.com Tutorial - Functional Dependence - Temperature Conversion 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

Direct Product Block notation is a general way to specify constraints. A partition containing blocks of factor values defines all the possible test cases by allowing all the blocks' combinations of values. Earlier examples show how to set up blocks in a partition to generate test cases for browser-operating system configuration constraints, for calendar rule constraints and for business rule constraints. When the constraints are complex, or when there are many test factors, it may take several blocks to define the allowed test cases. However, the specification of the constraints can be simplified when a factor's values are determined by the values of other factors. That is, the factor's values are functionally dependent on other factors. Expressing values in functionally dependent form can clarify the constraint analysis in a test design by making these relations among factor values explicit. The temperature conversion example on this page illustrates the simplification when the dependence is on one other factor.

Functionally Dependent Form
The temperature conversion program changes a temperature on the Celsius, Fahrenheit or Kelvin scale to the corresponding temperature on any of these three scales. The three test factors are:
 • inScale, the temperature scale for the input temperature • inTemp, an integral number of degrees on the input scale • outScale, the scale for the converted temperature
Temperatures below absolute zero are invalid.

The tester plans to try several inTemp values in the valid temperature partition. These will include the minimum valid temperature, 20 and 68 degrees on the input scale, and the freezing and boiling points for water.

The three test factors have values as follows.

Test FactorNumber of ValuesTest Factor Values
1. inScale3 Celsius Fahrenheit Kelvin
2. inTemp5 minimum(inScale) 20 68 freezing(inScale) boiling(inScale)
3. outScale3 Celsius Fahrenheit Kelvin

Three of the inTemp values are expressed as functions of the inScale values. The values of inScale (the determinant factor) determine the values of the functions for inTemp (the functionally dependent factor). Thus, when inScale is Celsius, the minimum temperature, minimum(Celsius), is -273. The outScale factor is not part of these relations, so it is a nondeterminant factor.

The test case generator request can be expressed in terms of these functions (in functionally dependent form) or in terms of their fixed values determined by the inScale factor (in fixed values form). Using functionally dependent values in this example reduces the number of blocks as well as the number of test cases. The inTemp functions are placeholder values, to be evaluated and substituted according to the inScale values in the generated test cases. When an inScale value appears with an inTemp function, the function's value is determined for the test case.

The test case generator request in functionally dependent form is given below.
 ```Temperature Conversion Example - functionally dependent form inScale inTemp outScale # all valid temperatures +inTemp depends on inScale Celsius Fahrenheit Kelvin minimum(inScale) 20 68 freezing(inScale) boiling(inScale) Fahrenheit Kelvin Celsius```

The results table follows. The input temperatures after substitution are shown in the column on the right.

#1. all valid temperatures
TestCase ID inScale inTemp outScale ComboCountdown Input Temperatureafter Substitution 3 Values 5 Values 3 Values 39 1 Celsius minimum(inScale) Fahrenheit 36 -273 oC 2 Fahrenheit 20 Celsius 33 20 oF 3 Kelvin 68 Kelvin 30 68 oK 4 Fahrenheit freezing(inScale) Kelvin 27 32 oF 5 Kelvin boiling(inScale) Celsius 24 373 oK 6 Celsius 20 Kelvin 21 20 oC 7 Kelvin 20 Fahrenheit 18 20 oK 8 Celsius 68 Celsius 15 68 oC 9 Fahrenheit 68 Fahrenheit 12 68 oF 10 Fahrenheit minimum(inScale) Kelvin 10 -459 oF 11 Kelvin minimum(inScale) Celsius 8 0 oK 12 Celsius freezing(inScale) Fahrenheit 6 0 oC 13 Kelvin freezing(inScale) Celsius 4 273 oK 14 Celsius boiling(inScale) Fahrenheit 2 100 oC 15 Fahrenheit boiling(inScale) Kelvin 0 212 oF

Because the request is in functionally dependent form, the test case generator treats each of the inTemp functions as a single value. The implications for coverage are as follows.
 • All allowed values of the dependent factor are covered. Even though each inTemp function is treated as one value, when it is paired with the determinant function values it is interpreted correctly, by the definition of the function. • All allowed pairs of determinant and dependent factor values are covered. Each determinant factor value is paired with the corresponding value of each of the dependent factor's functions. • All allowed pairs of determinant and nondeterminant factor values are covered. • Each nondeterminant factor value is paired with at least one value of each function and with all the fixed values of the dependent factor.
These coverage characteristics may be sufficient for test goals. When they are not (when each nondeterminant factor value is to be paired with all the values of each function), the request can be converted to fixed values form. This approach is illustrated next. Alternatively the request can be repartitioned to cover all pairs. 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 one factor, all allowed pairs are covered.

Fixed Values Form
Converting the functionally dependent request above to fixed values form requires specific values for the inTemp functions based on the inScale values. Now the three test factors have values as follows.

Test FactorNumber of ValuesTest Factor Values
1. inScale3 Celsius Fahrenheit Kelvin
2. inTemp11 minimum(Celsius) minimum(Fahrenheit) minimum(Kelvin) 20 68
freezing(Celsius) freezing(Fahrenheit) freezing(Kelvin)
boiling(Celsius) boiling(Fahrenheit) boiling(Kelvin)
3. outScale3 Celsius Fahrenheit Kelvin
The request is converted to fixed values form by replacing its block with three blocks containing the individual determinant factor values and their corresponding functionally dependent factor values.
 ```Temperature Conversion Example - fixed values form inScale inTemp outScale # all valid temperatures +Celsius inScale Celsius minimum(Celsius) 20 68 freezing(Celsius) boiling(Celsius) Fahrenheit Kelvin Celsius +Fahrenheit inScale Fahrenheit minimum(Fahrenheit) 20 68 freezing(Fahrenheit) boiling(Fahrenheit) Fahrenheit Kelvin Celsius +Kelvin inScale Kelvin minimum(Kelvin) 20 68 freezing(Kelvin) boiling(Kelvin) Fahrenheit Kelvin Celsius```

The results table follows. The input temperatures after substitution are shown in the column on the right.

#1. all valid temperatures
TestCase ID inScale inTemp outScale ComboCountdown Input Temperatureafter Substitution 3 Values 11 Values 3 Values 75 1 Celsius freezing(Celsius) Fahrenheit 72 0 oC 2 Celsius minimum(Celsius) Kelvin 69 -273 oC 3 Celsius 20 Celsius 66 20 oC 4 Fahrenheit freezing(Fahrenheit) Fahrenheit 63 32 oF 5 Fahrenheit minimum(Fahrenheit) Kelvin 60 -459 oF 6 Fahrenheit 68 Celsius 57 68 oF 7 Kelvin freezing(Kelvin) Fahrenheit 54 273 oK 8 Kelvin minimum(Kelvin) Kelvin 51 0 oK 9 Kelvin boiling(Kelvin) Celsius 48 373 oK 10 Celsius boiling(Celsius) Kelvin 46 100 oC 11 Celsius 68 Kelvin 44 68 oC 12 Fahrenheit boiling(Fahrenheit) Kelvin 42 212 oF 13 Fahrenheit 20 Fahrenheit 40 20 oF 14 Kelvin 20 Kelvin 38 20 oK 15 Kelvin 68 Fahrenheit 36 68 oK 16 Celsius minimum(Celsius) Fahrenheit 35 -273 oC 17 Celsius freezing(Celsius) Celsius 34 0 oC 18 Celsius boiling(Celsius) Fahrenheit 33 100 oC 19 Celsius minimum(Celsius) Celsius 32 -273 oC 20 Celsius freezing(Celsius) Kelvin 31 0 oC 21 Celsius boiling(Celsius) Celsius 30 100 oC 22 Fahrenheit minimum(Fahrenheit) Fahrenheit 29 -459 oF 23 Fahrenheit freezing(Fahrenheit) Celsius 28 32 oF 24 Fahrenheit boiling(Fahrenheit) Fahrenheit 27 212 oF 25 Fahrenheit minimum(Fahrenheit) Celsius 26 -459 oF 26 Fahrenheit freezing(Fahrenheit) Kelvin 25 32 oF 27 Fahrenheit boiling(Fahrenheit) Celsius 24 212 oF 28 Kelvin boiling(Kelvin) Kelvin 23 373 oK 29 Kelvin minimum(Kelvin) Fahrenheit 22 0 oK 30 Kelvin freezing(Kelvin) Celsius 21 273 oK 31 Kelvin boiling(Kelvin) Fahrenheit 20 373 oK 32 Kelvin minimum(Kelvin) Celsius 19 0 oK 33 Kelvin freezing(Kelvin) Kelvin 18 273 oK

Because the request is in fixed values form, all allowed pairs are covered among all factors. The fixed values are expressed here in terms of the function's domain, e.g. minimum(Celsius). In fixed values form they can be expressed in terms of the function's range instead, -273 for minimum(Celsius), etc.

One Function of One Factor
The second approach to cover all pairs of all factors is to split the original functionally dependent partition into separate partitions for each inTemp function. There are three partitions for minimum(inScale), freezing(inScale) and boiling(inScale), and one more for the fixed values 20 and 68. This illustration focuses on the partition for minimum(inScale); the partitions for freezing(inScale) and boiling(inScale) are constructed similarly.

When the minimum(inScale) function specifies all the inTemp values, the three test factors have values as follows.

Test FactorNumber of ValuesTest Factor Values
1. inScale3 Celsius Fahrenheit Kelvin
2. inTemp1 minimum(inScale)
3. outScale3 Celsius Fahrenheit Kelvin

The test case generator request is given below.
 ```Temperature Conversion Example - one function of one factor inScale inTemp outScale # all valid temperatures +inTemp depends on inScale Celsius Fahrenheit Kelvin minimum(inScale) Fahrenheit Kelvin Celsius```

The results table follows. The input temperatures after substitution are shown in the column on the right.

#1. all valid temperatures
TestCase ID inScale inTemp outScale ComboCountdown Input Temperatureafter Substitution 3 Values 1 Value 3 Values 15 1 Kelvin minimum(inScale) Celsius 12 0 oK 2 Celsius minimum(inScale) Kelvin 9 -273 oC 3 Fahrenheit minimum(inScale) Fahrenheit 6 -459 oF 4 Kelvin minimum(inScale) Fahrenheit 5 0 oK 5 Fahrenheit minimum(inScale) Celsius 4 -459 oF 6 Celsius minimum(inScale) Celsius 3 -273 oC 7 Kelvin minimum(inScale) Kelvin 2 0 oK 8 Fahrenheit minimum(inScale) Kelvin 1 -459 oF 9 Celsius minimum(inScale) Fahrenheit 0 -273 oC

As before, the test case generator treats the inTemp function as a single value. The implications for coverage are as follows.
 • All allowed values of the dependent factor are covered. Even though each inTemp function is treated as one value, when it is paired with the determinant function values it is interpreted correctly, by the definition of the function. • All allowed pairs of determinant and dependent factor values are covered. Each determinant factor value is paired with the corresponding value of the dependent factor's function. • All allowed pairs of determinant and nondeterminant factor values are covered. • Each nondeterminant factor value is paired with all the values of the dependent factor. This is because when each nondeterminant factor value is paired with a determinant factor value, it must be paired with the corresponding dependent value as well. There is no other choice.
Thus, all allowed pairs among all factors are covered. In this case (one function of one factor) the functionally dependent form is equivalent to the fixed values form: Both forms yield test cases covering the same values and pairs.

A general procedure for converting requests from functionally dependent form to fixed values form includes the two approaches introduced here. Example a in the procedure illustrates this one function of one factor case.

The calendar example is revisited on the next page to show how constraints for a factor determined by two other factors can be simplified.