Download TestStudio: An environment for automatic test generation based on

Transcript
TestStudio – Diploma project
new value, with the name of the selected class filled in in the text field for the return
type.
•
The check box for random generation (through which the user can choose whether
he wants to generate random values for types for which he has already defined values)
is selected and disabled. The reason is that currently we cannot disable random
generation of values for types other than the basic ones in the context generator.
Function save_info of class TSG_VALUES_VERTICAL_BOX saves the values that the
user entered (in an instance of TS_TEST_DATA). As described above, the user must enter the
values for basic types in text fields. By getting the texts from these fields, we obtain strings
which have to be parsed in ordered to get the integers, reals, etc. they contain. For this, we
created a utility class called TSU_STRING_PARSER, which contains functions get_ints,
get_reals, get_doubles, get_booleans, get_chars, and get_strings (all
receiving a STRING as argument) for parsing a string to get different kinds of values from it.
All these functions return arrays of objects of the corresponding basic type. Then we save
these arrays in an instance of TS_TEST_DATA.
The functions of class TSU_STRING_PARSER use instances of special parser classes
(contained in cluster scanner): TSG_INTEGER_SCANNER, TSG_REAL_SCANNER,
TSG_DOUBLE_SCANNER, TSG_CHARACTER_SCANNER and TSG_STRING_SCANNER. (For
booleans it’s not necessary to have a special scanner class, because we can just test if the
string contains a “true” substring and a “false” substring, as these are the only legal values for
type BOOLEAN.) We generated these classes using Gobo Eiffel Lex (gelex [Bezault04]). Gelex
takes as input a lex-type file which contains three sections:
•
Declarations – start conditions, options, name definitions and Eiffel code which gelex
will copy at the beginning of the generated scanner class;
•
Rules – a series of rules of the form “pattern action”;
•
User code – Eiffel code which gelex will copy at the end of the generated scanner
class.
For all the above-mentioned classes, the user code section contains a function called
scan_text, which reads tokens one at a time and performs different actions depending on
the type of the token that it finds. We declare the token types as constants at the end of the
class.
Having intervals is allowed for characters and strings (an interval inside a string is
interpreted as the string containing all characters whose codes are between the code of the
character starting the interval and the code of the character ending the interval). So the parsers
for characters and strings need to take this into account, and when they encounter the “…”
token, actually add all elements of the interval to the array they return.
We save the values that the user enters for non-basic types, as they are, in an instance of
TS_TEST_DATA. When we generate the test code, we assemble them into feature definitions
and we copy their code as it is in the context generator class.
Class TSG_STRESS_LEVEL_VERTICAL_BOX contains the functionality for setting the
stress levels associated with tested items, either globally, or on a per-cluster, per-class, or perfeature basis. It initially displays only the radio buttons for setting the global stress level and a
button which, when it is pressed, triggers the display of the widgets used for setting the stress
level for clusters, classes and features. The elements included in the test are shown in a treelike structure, and for each element the user can set the stress level. The user can also change
the values of the parameters which map to stress levels (number of method calls and whether
30