Introduction
An example
Let's take a look at an example to learn the characteristics of unit testing for "rules." We have a performance tuning tool, WPA, that evaluates the values of performance-related parameters and recommends optimal values. Its evaluation and recommended optimal value algorithms are based on "rules".
The initial heap size of the Java virtual machine (JVM initial heap size) is a key parameter that affects the performance of the JVM. Performance Tuning Tool WPA has a set of rules for evaluating the value of JVM initial heap size (see Listing 1). The results of the assessment are 5 levels. The level "1" is well set to improve performance, and the level "5" indicates a poor setting, which can degrade performance.
Listing 1. JVM initial heap Size rating algorithm
Rating3upperbounds = 1024
Rating3lowerbounds = 48
Rating5upperbounds = 1536
Rating5lowerbounds = 32
Rating3multiplier = 4
Rating5multiplier = 3
Absolutemaximumvalue= math.min (currentmemorypoolsize, overallmemoryonpartition)
/Rating3multiplier
if (Initialheapsize > Absolutemaximumvalue) {
return 4;
}
if ((Initialheapsize < rating5lowerbounds) | |
(Initialheapsize > Rating5upperbounds)) {
Rating = Severe problem (5)
}
else if (Initialheapsize < rating3lowerbounds) | |
(Initialheapsize > Rating3upperbounds)) {
Rating = probable problem (3)
}
......
}
if (initialheapsize * rating5multiplier > Currentmemorypoolsize)
{
Return severe problem (5)
}
else if (Initialheapsize*rating3multiplier > Currentmemorypoolsize)
{
Return Max (rating, 3)
}
else if (Initialheapsize*rating2multiplier > Currentmemorypoolsize)
else {
Return Max (rating, 1)
}
In this set of rules, there are three input parameters: "Initialheapsize" (the value of the JVM initial heap size), "Currentmemorypoolsize" (the value of the memory pool), and the Overallmemoryonpartition "(Value of physical memory). To get these values, we need to use the APIs provided by the application Server and OS. When using these APIs, we must construct the runtime environment required by the API.
In this set of rules, there are many different conditions (see "if-else" statements). At the time of testing (unit and functional testing), we need at least 24 sets of test data to cover all thresholds (threshold value) and equivalence classes (equivalent Class). See table 1.