Implementation of a Test Data Generator based on DSL Files

In software testing process, test data generation represents an important step for high quality software, even for mobile devices. As proposed in previous works, a potential source for random data generation is represented by the UI layout files that are used for almost all mobile platforms (Android, iOS, Windows Phone/Mobile). This paper continues the previous work and presents a test data generation system based on Android layout files. The test data generator uses DSL files as input and generates test data that conform to several testing principles. The generated test data could be stored in XML files or any format required by the testing frameworks.


Introduction
Software testing represents an important step in software development [1], [2] and the testing process is thoroughly presented in books like [3] and [4].Like other applications, mobile applications require testing in order to achieve a required level of quality.This can be done using similar tools and frameworks and also specific and dedicated tools, depending on the platform.Some of the mobile application testing types are shortly described in [5].During the testing process, test data generation has its own role for testing success.Test data generation is made using different tools and techniques.The paper continues the research presented in [6], [7] and [17] and focuses on template generation for test data based on Android layout files.Test data templates are XML-based files written using DSL (Data Specification Language).The generated test data can be used by own testing tools or frameworks or can be used as inputs for existing testing frameworks and tools.The paper is structured as follows.The section Android testing frameworks and tools presents the most important aspects related to Android applications testing.It also make a short presentation of the Android testing instruments.Data Specification Language (DSL) section describes the proposed system for test data generator based on Android layout files and details the XML-based language used for test data specification.The proposed parser for Android layout files is presented in the last section, Android layout files parser.The section Random test data generator based on pragmatic testing (RIGHT-BICEP) presents a test data generator, based on DSL files, that allows to generate data that conform to selected principles.The paper ends with conclusion and future work.

Android Testing Frameworks and Tools
Android applications being developed using Java programming language, JUnit testing framework is suitable for the automated testing of functional issues.JUnit is a testing framework for regressive unit testing of Java programs [8].The main Java classes used by the framework are associated to test cases and suites.The Android platform includes several tools and frameworks.Also, third party developers have built such tools and framework for Android applications testing.In [9] are presented the fundamentals of Android applications testing.and IntelliJ; it is a continuous test runner.In order to automate the testing process, some of these tools can run using generated data by dedicated tools.Specific Android testing approaches are presented in [11], [12] and [13].

Data Specification Language (DSL)
In order to generate test data, test data generators (TDG) can be based on random functions or can use inputs related to application under test (specifications, source files, data constraints, list of values, layout files etc.).The test data will be used either for white-box testing (as in [14]) or for functional testing.White-box testing requires a deeper knowledge of source code and a previous analysis of it is required before [15].Our proposed solution take as input an XMLbased file that includes a description of each field for which will be generated test data.Figure 1 depicts the architecture of the test data generator system.Android layout files are used as inputs for the parser.The parser generates a DSL file that is used as input for the test data generator.Finally, the test data generator will provide the test data.DOI: 10.12948/issn14531305/20.2.2016.03

Fig. 1. Test data generator system
The DSL file provides required information to test data generator and allows to generate test data for the analyzed software under test (SUT).The generated test data could be stored in memory or in files (XML, binary or any other specific format).In [6] and [7] was proposed an XML-based language used for test data generation.The current version include more nodes for a better control of data generation.The root node any DSL file is dataset.Each field for which data will be generated is represented by field node.The field node include tow attributes:  id, associated to the identification attribute of the current field;  type, representing the control type (EditText, Spinner etc.).Each field includes the nodes:  type, representing data type like string, number, Boolean etc.;  generation, showing how data will be generated (random or a list of values);  maxLength, with attribute fixed, used for the required length.The fields that require values from a list of values will include the lov node with values used for selection.The XSD schema of DSL files is presented in Listing 1.If the control identifier is not present, the system will generate one.Data length will be deduced from the Android UI layout files, such as android:maxLength attribute.Data type could be determined based on android:inputType and initial fields values.For input that include numbers and a specific format (like phone numbers, date etc.), it should be included the format also.Also, for numeric fields, it could be added the nodes minValue and maxValue and their corresponding values obtained from the layout file or specifications or could be added later.

Android Layout Files Parser
The Android layout parser uses XML-based files available in res/layout folder of the Android project.Several sources, such as [16], present the content and structure of Android layout files.In order to exemplify the DSL template generation, the XML layout from Listing 2 was used.

Fig. 2. Test data generator system
The generated test data could be used by existing tools and frameworks to fill the controls and to activate the submission button.Based on the layout from Listing 2, the generated DSL file is presented in Listing 3.This DSL file represents an input for the test data generator.In this stage, the DSL file does not fully automate test data generators.It could require a manual intervention or other additional parsers or editors that need to narrow data boundaries or add other constraints or will provide the list of values for list-based controls.For example, the for the Spinner control, the list of values has to be filled before data generation.

Random Test Data Generator Based On Pragmatic Testing (RIGHT-BICEP)
The DSL files will be used for generate the data set for testing.In order to generate these datasets it is necessary to know what will be tested with these datasets.The test data generator we propose will use, for unit testing, the Right-BICEP principle, Figure 3. DOI: 10.12948/issn14531305/20.2.2016.03

Fig. 3. Right-BICEP principle
According to this principle, for each control must be tested and verified if the input provided by the user comply [8]:  RIGHTif the provided control input is correctly; it should be verified if the input of the control is correct and is not changed;  Boundaryall limits should be checked and if the input is correctly obtained for these limits; it should be verified if the control provide the correct input with minimum length or with maximum accepted length;  Inverseinverse relationship must be verified for each control; it should be verified by an inverse relationship if the control provide the correct input;  Cross-checkit must be verified by a cross-check accuracy, using calculation methods similar tested and validated by a large community of programmers and compare results;  Errorcheck control behavior when obtaining certain errors or introduce erroneous values by the user; the control should be forced to provide errors and to be analyzed the reaction of the control in these situations;  Performanceverifying the optimal functioning of that control, otherwise it is strongly recommended another type of control.Besides this principle exist another one named CORRECT, which should be considered in the process of testing and in the process of elaboration of dataset for testing.Following the principles of testing and using the DSL file layouts obtained for Android was developed Random Test Data Generator (RTDG) application.The application generates an XML file with test data fields described in the file DSL.For each test data file with the desired DSL file uploaded it is specified the number of tests required for each field and what type of tests to generate.The RTDG will generate test data for three of the six categories of Right-BICEP principle: Right, Boundary and Error.Figure 4 depicts the interface of the RTDG application.Within the XML file, test data is organized by controls.For each control, test data are generated in order to comply with each principle selected in the application.Each set contains the test tag, the control id for and the type of test that is generated.If the test is Right or Boundary, the tag input contains the attribute ERROR with the false value and the value represents the input data set to achieve for that test.If the selected test type is Boundary or Right, expectedResult tag exists and represent the expected result from the test.For the Error tests, the value of the attribute ERROR is true and the tag expectedResult doesn't exists, because the expected result is the error.The proposed Random Test Data Generator application can be improved so as to generate other files with test data and not only XML.Also, the structure of the resulting file can be customized depending on the application framework used to automate the testing process based on test data provided by RTDG application.

Conclusions and Future Work
The proposed system can be integrated with many testing frameworks and tools available for Android platform.The presented format of DSL files is a preview and it will be improved during the future development.The proposed application for random test data generation demonstrates the functionality of the proposed system.The next steps include the further development of the test data generator that generate test data based on DSL files: data output format, more testing criteria.

Table 1
summarizes the most used Android testing tools and frameworks.Many of these are based on JUnit.

editTitlu" type="Error"> <input
C E P Random Test Data Generator ApplicationBased on each identified field of DSL file it is determined the control type and what types of test data should be generated.For example, if the identified control type is EditText, then:  the data type could be either String or numeric,  the id attribute is taken from the control related attribute (android:id) or it is generated;  the maximum length of characters accepted is determined, if it is specified.If the maxLenght tag is not specified it is considered a length of 20 characters.This length is used to build test data for Boundary principle.After all the fields were identified, random test data will be generated.If the field is of type String it may also contain characters and numbers but also special signs.If that field is numeric, it contains only numbers.Based on DSL file from Listing 3 it is generated the XML file from Listing 4. The file contains one set of test data for each EditText control, for each category (Right, Boundary, and Error).