A random data generation method, device, intelligent terminal and storage medium

By analyzing the data types of test parameters and generating corresponding types of random data, the problem of only numerical random data generation in the prior art is solved, and the random data generation of multiple types of data is realized, which improves the accuracy of automated verification tests.

CN113126955BActive Publication Date: 2025-04-11SHENZHEN HUASHENG SOFTWARE TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201911403360.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-30
Publication Date
2025-04-11
Estimated Expiration
2039-12-30

AI Technical Summary

Technical Problem

In the prior art, there are limitations when generating random data. Only numerical random data generation is supported, and the random data generation requirements of other types of data cannot be met.

Method used

By obtaining the test parameters of the preset interface, analyzing and determining the data type of the test parameters, and generating the corresponding type of random data based on the data type, for automatic verification testing of the application.

Benefits of technology

It realizes the generation of random data of different types of data (such as time, characters, java objects, rule data, etc.), improving the accuracy and comprehensiveness of the application's automated verification test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113126955B_ABST
    Figure CN113126955B_ABST
Patent Text Reader

Abstract

The present invention discloses a random data generation method, device, intelligent terminal and storage medium, the method comprising: obtaining a test parameter of a preset interface; determining a data type of the test parameter according to the test parameter, and generating random data corresponding to the data type according to the data type, the random data being used for an application to perform automated verification testing. The present invention analyzes the test parameter of the preset interface, determines the data type of the test parameter according to the test parameter, and then generates corresponding random data according to the data type, so that the generated random data can be used to perform automated verification testing when the application is tested.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of random data generation, and in particular to a random data generation method, device, intelligent terminal and storage medium. Background Art

[0002] During the application development process, random data can be provided to application testing as functional verification for automated testing operations.

[0003] In the prior art, there is an interface Math.random for generating random data in the Java language (used to randomly select a value greater than or equal to 0 and less than 1 through the system), but Math.random only supports the generation of digital random data. However, there is no effective random data generation method for other data such as time, characters, Java objects, and some regular data such as telephone numbers, emails, etc. The prior art has limitations when generating random data, and only supports the generation of numerical random data, and cannot meet the generation of random data of other types of data.

[0004] Therefore, the existing technology still needs to be improved and developed. Summary of the invention

[0005] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a random data generation method, device, intelligent terminal and storage medium are provided, aiming to solve the limitation of the prior art in generating random data, which only supports the generation of numerical random data and cannot meet the generation of random data of other types of data.

[0006] The technical solution adopted by the present invention to solve the problem is as follows:

[0007] In a first aspect, an embodiment of the present invention provides a method for generating random data, wherein the method comprises:

[0008] Get the test parameters of the preset interface;

[0009] The data type of the test parameter is determined according to the test parameter, and random data corresponding to the data type is generated according to the data type, and the random data is used for the application program to perform automated verification testing.

[0010] In one implementation, determining the data type of the test parameter according to the test parameter, and generating random data corresponding to the data type according to the data type includes:

[0011] Parsing the test parameter to obtain a data identifier in the test parameter, wherein the data identifier is used to determine a data type of the test parameter;

[0012] Matching the data identifier with a preset identifier library to obtain a matching result, wherein the identifier library is provided with a corresponding relationship between the data identifier and the data type;

[0013] The data type of the test parameter is determined according to the matching result, and random data corresponding to the data type is generated according to the data type.

[0014] In one implementation, determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes:

[0015] According to the matching result, determining whether the data identifier corresponds to a collection type;

[0016] If the data identifier corresponds to a set type, determining that the data type of the test parameter is a set type;

[0017] First metadata in the collection type is acquired, and random data corresponding to the collection type is generated according to the first metadata, where the first metadata is used to reflect attribute information of the collection type.

[0018] In one implementation, determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes:

[0019] If the data identifier does not correspond to the set type, judging whether the data identifier corresponds to the dictionary type according to the matching result;

[0020] If the data identifier corresponds to the dictionary type, determining that the data type of the test parameter is a dictionary type;

[0021] Second metadata in the dictionary type is acquired, and random data corresponding to the dictionary type is generated according to the second metadata, where the second metadata is used to reflect attribute information of the dictionary type.

[0022] In one implementation, determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes:

[0023] If the data identifier does not correspond to the dictionary type, judging whether the data identifier corresponds to the rule data type according to the matching result;

[0024] If the data identifier corresponds to the regular data type, determining that the data type of the test parameter is the regular data type;

[0025] A preset rule is searched from the rule data type and data matching is performed to generate random data corresponding to the rule data type.

[0026] In one implementation, determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes:

[0027] If the data identifier does not correspond to the regular data type, judging whether the data identifier corresponds to a simple data type according to the matching result;

[0028] If the data identifier corresponds to the simple data type, the data type of the test parameter is determined to be a simple data type:

[0029] The adaptation information in the simple data type is parsed, and corresponding random data is generated according to the adaptation information, wherein the adaptation information is used to reflect the data attribute information in the simple data type so that the corresponding random data is generated according to the data attribute information.

[0030] In one implementation, the generating corresponding random data according to the adaptation information includes:

[0031] If the adaptation information is basic type information, generating random data corresponding to the basic type information;

[0032] If the adaptation information is character string information, generating random data corresponding to the character string information;

[0033] If the adaptation information is time information, random data corresponding to the time information is generated.

[0034] In one embodiment, after generating random data corresponding to the data type according to the data type, the method further includes:

[0035] The random data is input into a verification process of a preset application program, and the random data is verified through the verification process to determine the running status of the preset application program.

[0036] In a second aspect, an embodiment of the present invention further provides a random data generating device, wherein the device comprises:

[0037] A parameter acquisition unit, used to acquire test parameters of a preset interface;

[0038] A data generation unit is used to determine the data type of the test parameter according to the test parameter, and generate random data corresponding to the data type according to the data type, wherein the random data is used for the application to perform automated verification testing.

[0039] In a third aspect, the present invention also provides an intelligent terminal comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include a method for executing random data generation as described in any one of the above.

[0040] In a fourth aspect, an embodiment of the present invention further provides a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute any of the random data generation methods described above.

[0041] Beneficial effects of the present invention: The present invention obtains the test parameters of the preset interface, analyzes the test parameters, and then determines the data type of the test parameters according to the test parameters, and then generates random data corresponding to the data type according to the data type. The random data is used for automated verification testing of the application program to determine the operating status of the application program. It can be seen that the present invention can generate random data according to the data type, so when the random data is used for verification testing, the test results will be more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0043] Figure 1 It is a flowchart of a random data generation method provided by an embodiment of the present invention.

[0044] Figure 2 The present invention provides a flow chart of random data generation in a random data generation method according to an embodiment of the present invention.

[0045] Figure 3 It is a flow chart of a specific application of the random data generation method provided by an embodiment of the present invention.

[0046] Figure 4 It is a principle block diagram of a Bluetooth audio data transmission device provided by an embodiment of the present invention.

[0047] Figure 5 It is a block diagram of the internal structure principle of the intelligent terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0049] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0050] In order to solve the problem in the prior art that random data cannot be generated for characters, time and some regular data information, the present embodiment provides a random data generation method, which mainly analyzes the test parameters of the preset interface and determines the data type of the test parameters according to the test parameters. Since the test parameters are the parameters that need to generate random data, the present embodiment further generates corresponding random data according to the data type, so that the generated random data can be used to perform automated verification testing in application testing.

[0051] Exemplary Methods

[0052] like Figure 1 As shown in , an embodiment of the present invention provides a random data generation method, which can be applied to a smart terminal. In an embodiment of the present invention, the method includes the following steps:

[0053] Step S100: Acquire test parameters of a preset interface.

[0054] The random data generation method in this embodiment is implemented based on the Java language. Java is an object-oriented programming language. The entire Java technology framework mainly includes two types of data descriptions: basic data types and objects. There are eight Java basic types, which can be divided into three categories: character type char, Boolean type (boolean) and numerical type byte (byte), short (short integer), int (integer), long (long integer), float (floating point type), double (double precision type). The random() method of the Math class in Java can generate a random floating point number between [0,1). If you want to generate a random integer of [0,n], you only need to multiply Math.random() by n+1 to generate a floating point number of [0,n+1), and then force the type conversion to int type (basic integer type), and only take its integer part to get an integer of [0,n]. The Java language forced conversion mechanism is divided into two types: basic data types and reference data types. The difference between the two is that there is no need to perform type judgment before basic data type conversion, which is implemented by Java's internal mechanism. For example, double type data can be forced to be converted to int type, that is, the integer part is assigned to the int type variable, and the data after the decimal point will be discarded. For reference data type conversion, type matching judgment is required before the operation, and the judgment is based on the fact that the conversion type and the converted type must be the same or have an inheritance relationship. In addition, the conversion between string objects (String) and other objects (Object) is also implemented by internal mechanisms.

[0055] In this embodiment, when a verification test is performed on an application, the input test parameters need to be processed to generate random data that can be recognized by the verification process of the application, so the preset interface will be called to obtain the test parameters. In this embodiment, the test parameters are parameters entered by the user or tester in a specific preset interface so that the test parameters can be received by the preset interface. The test parameters represent a certain data type. In this embodiment, the test parameters in the preset interface include data type identification, metadata, length data, etc. In this embodiment, the data type identification refers to the identification corresponding to the data type for which a random number needs to be generated; metadata refers to the sub-unit data type contained in a group of data sets such as collection (Collection, Array) type, dictionary (Map) type, array type, etc.; length refers to the data size used to generate random data, such as numbers represent the number of digits, characters and array types represent length (length), and collection and array types represent size (size).

[0056] In this embodiment, when the test parameters are obtained from the preset interface, it is necessary to analyze the test parameters and determine the data type of the test parameters so as to generate random data corresponding to the data type according to the data type.

[0057] Step S200: determining a data type of the test parameter according to the test parameter, and generating random data corresponding to the data type according to the data type, wherein the random data is used for performing automated verification testing of the application.

[0058] Since the present embodiment needs to generate different random data according to different data types, so as to solve the problem in the prior art that random data cannot be generated for time, characters, Java objects, and some regular data such as telephone numbers, emails, etc. Therefore, the present embodiment first needs to analyze the test parameters to determine the data types corresponding to the test parameters.

[0059] Specifically, Figure 2 As shown, the step S200 specifically includes:

[0060] Step S201: Parse the test parameter to obtain a data identifier in the test parameter, where the data identifier is used to determine a data type of the test parameter;

[0061] Step S202: Match the data identifier with a preset identifier library to obtain a matching result, wherein the identifier library is provided with a corresponding relationship between the data identifier and the data type;

[0062] Step S203: determine the data type of the test parameter according to the matching result, and generate random data corresponding to the data type according to the data type.

[0063] Since different data types have different data identifiers, the data type can be determined based on the data identifier. Therefore, in this embodiment, by analyzing the test parameters, the data identifier can be obtained from the test parameters to determine which data type the test parameters are. Specifically, in this embodiment, it can be said that the data identifier is first obtained from the test parameters, and then the data identifier is matched with the preset identifier library to obtain a matching result, and the corresponding relationship between the data identifier and the data type is set in the identifier library. For example, data identifier A corresponds to the set type; data identifier B corresponds to the dictionary type; data identifier C corresponds to the simple data type; data identifier D corresponds to the rule data type, etc. Therefore, according to the data identifier obtained from the test parameters, the data type corresponding to the data identifier can be found, and then the data type of the test parameters can be determined, so as to generate random data corresponding to the data type according to the determined data type.

[0064] Specifically, after the data identifier of the test parameter is obtained and matched with the identifier library, a matching result is obtained. According to the matching result, it is determined whether the data identifier corresponds to the set type. If it corresponds to the set type, the data type of the test parameter is determined to be the set type. Therefore, the first metadata in the set type is further obtained and the first metadata is parsed. The first metadata is used to reflect the attribute information of the set type. Therefore, random data corresponding to the set type is generated according to the length of the first metadata. Since the first metadata reflects the attribute information, it reflects what content is specifically included in the set type. Since the set type includes multiple data, such as a series of codes or characters, the length of the first metadata can indicate how much content is in the set type. Therefore, the corresponding random data is generated according to the length of the first metadata, which can ensure that the generated random data matches the content in the set type. Therefore, when the data type of the test parameter is a set type, random data corresponding to the set type can be generated, so that the random data can be used to perform automated verification testing on the application.

[0065] Further, when the data identifier does not correspond to the set type, it is further determined whether the data identifier corresponds to the dictionary type according to the matching result. If the data identifier corresponds to the dictionary type, the data type of the test parameter is determined to be a dictionary type. When the data type of the test parameter is determined to be a dictionary type, the second metadata in the set type is obtained and the second metadata is parsed. In this embodiment, the attribute name of the second metadata is used as an index to generate random data corresponding to the dictionary type. The second metadata in this embodiment is used to reflect the attribute information of the dictionary type, that is, to reflect the specific content included in the dictionary type. Specifically, since the dictionary type is a form of searching for another data based on one data, this embodiment can parse the second metadata to read the attribute definition of the second metadata. The attribute definition in this embodiment includes an attribute name as a data index Key and a data Value value corresponding to each data index key. After parsing the second metadata, the data index key is obtained, and then the data Value value corresponding to the data index key is obtained, and then the corresponding random data is generated according to the data Value value. It can be seen that when the data type of the test parameter is a dictionary type, random data corresponding to the dictionary type can be generated.

[0066] Further, if the data identifier does not correspond to the dictionary type identifier, it is determined whether the data identifier corresponds to the rule data type according to the matching result. If the data identifier corresponds to the rule data type, the data type of the test parameter is determined to be the rule data type; the preset rules are searched from the rule data type and data matching is performed to generate random data corresponding to the rule data type. The preset rules in this embodiment are pre-set. Since the data composition of the rule data type itself has certain rules, such as telephone numbers, emails, postal codes, etc., all have certain rules. Therefore, in this embodiment, the corresponding rules can be pre-set for these data, such as telephone numbers corresponding to one rule, and emails corresponding to another rule. In this way, when it is determined that the data type is the rule data type, random data corresponding to the rule data type can be generated according to the preset rules. It can be seen that when the data type of the test parameter is the rule data type, random data corresponding to the rule type can be generated. The rule data type in this embodiment refers to a data type with certain rules in the data format, such as telephone numbers, emails, postal codes, names, etc. For example, if the test parameter input by the user is a telephone number, random data corresponding to the telephone number is generated according to the telephone number.

[0067] Furthermore, if the data identifier does not correspond to the regular data type, then it is further determined whether the data identifier corresponds to a simple data type based on the matching result; if the data identifier corresponds to the simple data type, then the data type of the test parameter is determined to be a simple data type: the adaptation information in the simple data type is parsed, and the adaptation information is used to reflect the data attribute information in the simple data type, so that the corresponding random data is generated according to the data attribute information, and thus the corresponding random data is generated according to the adaptation information. In this embodiment, if the adaptation information is basic type information, random data corresponding to the basic type information is generated; if the adaptation information is string information, random data corresponding to the string information is generated; if the adaptation information is time information, random data corresponding to the time information is generated. In other words, different adaptation information ultimately generates different types of random numbers.

[0068] Specifically, in this embodiment, when the adaptation information is basic type information, the method for generating random data is: based on the data returned by the Math.random interface, forced conversion or multiplication by a multiple of the data length size generates the random data. When the adaptation information is Boolean type (boolean) information, the method for generating random data is: taking the data returned by the Math.random interface and comparing it with 0.5, or randomly reading the index from the Boolean enumeration class to generate it. When the adaptation information is string information, the method for generating random data is: first converting the predefined string constant to an array, and then looping (preset interface test parameters) data length to randomly read the array character value of the subscript and append the current value to generate random data (i.e., a random string). When the adaptation information is time information, the method for generating random data is: first read the current system time, add or subtract a random time length (month, day, minute, etc.) to the current time to obtain random time. Another method is to use the calendar class Calendar, and randomly generate corresponding values ​​of each calendar attribute (year / month / day / hour / minute / second) and call the Calendar interface to assign the values, where the year value is a 4-digit integer greater than 1970, the month requires an integer from 0 to 11, the day is an integer from 1 to 31 and needs to determine whether it is a big or small month or a leap year, and the hour, minute, and second are required to be positive integers not exceeding their period (i.e., not exceeding 12, and minutes and seconds not exceeding 60). Of course, when the adaptation information is other information, the method for generating random data also includes: enumerating the indexes of various data types, and then customizing the character information according to each index, and generating corresponding random data according to the customized character information. Therefore, the random data generated at this time is character-type random data.

[0069] Further, after the random data is generated, the random data is input into the verification process of the preset application, and the random data is verified through the verification process to determine the running state of the preset application. It can be seen that the present invention can generate random data according to the data type, so when the random data is used for verification testing, the test result will be more accurate. For example, when the WeChat application needs to be tested, the generated random data is input into the test process of the WeChat application for test verification to determine whether the WeChat application is running normally.

[0070] Furthermore, if Figure 3 As shown in , this embodiment provides a flowchart for the specific application of the random data generation method. It includes the following steps:

[0071] Step 301, start.

[0072] Step 302: The random data generation module obtains the transfer parameters (ie, the above-mentioned test parameters).

[0073] Step 303 , determine whether the transmitted parameter is a collection type; if so, execute step 304 ; if not, execute step 306 .

[0074] Step 304: Parse the metadata type, which is included in the transfer parameter.

[0075] Step 305: cyclically execute metadata type random data generation, that is, generate random data corresponding to the collection type.

[0076] Step 306 , determine whether the transmitted parameter is a dictionary type; if so, execute step 307 ; if not, execute step 310 .

[0077] Step 307: parse the metadata type.

[0078] Step 308: Get the metadata attribute name in the metadata type and use it as the data index Key.

[0079] Step 309: cyclically execute dictionary type random data generation, that is, generate random data corresponding to the dictionary type.

[0080] Step 310, determine whether the transferred parameter is a simple data type; if so, execute step 313; if not, execute step 311.

[0081] Step 311: Parse the POJO (Plain Ordinary Java Object) type and read the attributes. The definition of the POJO type only contains some attributes.

[0082] Step 312: loop through the attributes and randomly generate random data.

[0083] Step 313, determine whether the transmitted parameter is a regular data type; if so, execute step 314; if not, execute step 316.

[0084] Step 314: Search for rules and match to generate data.

[0085] Step 315: Generate data according to predefined rules.

[0086] Step 316: Simple data type analysis.

[0087] Step 317: basic type is randomly generated, that is, corresponding to the above embodiment, if the adaptation information is basic type information, random data corresponding to the basic type information is generated.

[0088] Step 318: randomly generate a character string, that is, corresponding to the above embodiment, if the adaptation information is character string information, then generate random data corresponding to the character string information.

[0089] Step 319, random generation of time, that is, corresponding to the above embodiment, if the adaptation information is time information, random data corresponding to the time information is generated.

[0090] Step 320, other data is randomly generated, that is, corresponding to the above embodiment, when the adaptation information is other information, the indexes of various data types are enumerated, and then the character information is customized according to each index, and the corresponding random data is generated according to the customized character information.

[0091] Step 321, simple data type data is randomly generated, that is, the generation of random data is completed.

[0092] Step 322, end.

[0093] The present invention analyzes the test parameters of the preset interface, determines the data type of the test parameters according to the test parameters, and then generates corresponding random data according to the data type, so as to perform automated verification testing in application program testing using the generated random data.

[0094] In specific application, the following is an example of this embodiment:

[0095] Application scenarios: Functional development and unit testing of smart preschool education system (referenced by API), functional development and unit testing of smart conference system, development and unit testing of cloud office OA system, development and unit testing of 4G police dispatch system, development and unit testing of police data analysis system, development and unit testing of eshow information release system, development and unit testing of welfare lottery system, development and unit testing of cloud platform permission system, development and unit testing of cloud platform terminal management system, development and unit testing of cloud platform network disk system. Functional automation testing of smart preschool education system, functional automation testing of smart conference system, automation testing of cloud office OA system, automation testing of 4G police dispatch system, automation testing of police data analysis system, automation testing of eshow information release system, automation testing of welfare lottery system, automation testing of cloud platform permission system, automation testing of cloud platform terminal management system, automation testing of cloud platform network disk system. Stress testing of cloud platform login function. Among them, the smart preschool education system, smart conference system, cloud office OA system, cloud platform network disk system, cloud platform terminal management system, cloud platform permission system, and cloud platform login are used in the form of API; the 4G police dispatch system and the police data analysis system are used in the form of services; the eshow information release system and the welfare lottery system are used in the form of webservice interface service system. Interaction (usage) mode: independent control references are called in the form of API, service references are accessed in the form of HTTP, and cloud server references are called in the form of webservice.

[0096] Specifically, when developing and unit testing, the automated test calls the method: first reference the jar package control and compile the application; then the application is started or the automated test of the application is started; when the R&D personnel debug the application function, the user operates the application function or starts the application function according to the automated test instructions, the random data generation method is called, and the test parameters are required to include the data type, metadata type, and data length; finally, if the processing is successful, the corresponding random data is returned, and if it fails, empty is returned.

[0097] Service form calling method: Application starts, the current application function sends an http (post or get) request to read the random number, the request path is http: / / ip:port number / component / randomdata.json, where the ip address (or domain name) and port number are based on the server running the random number module. The request parameters are required to include data type, metadata type, and data length. If the processing is successful, the corresponding random data is returned, otherwise an empty data prompt is returned.

[0098] Cloud service webservice call method: application starts, the current application functions as a client to request the server-side webservice interface service, the request path is http: / / ip:port number / ws / randomdata, where the ip address and port number are based on the server running the random number module. The request parameters include data type, metadata type, and data length. If the processing is successful, the corresponding random data is returned, otherwise it fails and returns an empty data prompt. When entering the test parameters, the requirements are: data type is required, and when the data type is a collection type (map, list, collection), the metadata type and data length are required. When the data type is a basic data type, the metadata type can be empty and the data length is required. When the data type is other types, the metadata type and length can be empty.

[0099] In summary, the present invention obtains the test parameters of the preset interface, analyzes the test parameters, and then determines the data type of the test parameters according to the test parameters, and then generates random data corresponding to the data type according to the data type. The random data is used for automatic verification testing of the application program to determine the running status of the application program. It can be seen that the present invention can generate random data according to the data type, so when the random data is used for verification testing, the test result will be more accurate.

[0100] Exemplary Devices

[0101] like Figure 4As shown in , an embodiment of the present invention provides a random data generation device, which includes: a parameter acquisition unit 410 and a data generation unit 420. Specifically, the parameter acquisition unit 410 is used to obtain the test parameters of the preset interface. The data generation unit 420 is used to determine the data type of the test parameter according to the test parameter, and generate random data corresponding to the data type according to the data type, and the random data is used for the application to perform automated verification testing.

[0102] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 5 As shown. The intelligent terminal includes a processor, a memory, a network interface, a display screen, and a temperature sensor connected through a system bus. Among them, the processor of the intelligent terminal is used to provide computing and control capabilities. The memory of the intelligent terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the intelligent terminal is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a random data generation method is implemented. The display screen of the intelligent terminal can be a liquid crystal display screen or an electronic ink display screen, and the temperature sensor of the intelligent terminal is pre-set inside the intelligent terminal to detect the operating temperature of the internal device.

[0103] Those skilled in the art will understand that Figure 5 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the smart terminal to which the scheme of the present invention is applied. The specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0104] In one embodiment, a smart terminal is provided, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations:

[0105] Get the test parameters of the preset interface;

[0106] The data type of the test parameter is determined according to the test parameter, and random data corresponding to the data type is generated according to the data type, and the random data is used for the application program to perform automated verification testing.

[0107] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0108] In summary, the present invention discloses a random data generation method, the method comprising: obtaining a test parameter of a preset interface; determining a data type of the test parameter according to the test parameter, and generating random data corresponding to the data type according to the data type, the random data being used for an application to perform automated verification testing. The present invention analyzes the test parameter of the preset interface, determines the data type of the test parameter according to the test parameter, and then generates corresponding random data according to the data type, so that the generated random data can be used to perform automated verification testing in application testing.

[0109] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A random data generation method, characterized in that: The method comprises: Get the test parameters of the preset interface; Determine the data type of the test parameter according to the test parameter, and generate random data corresponding to the data type according to the data type, wherein the random data is used for the application to perform automated verification testing; The test parameters include data type identification, metadata and length data; The data type identifier refers to the identifier corresponding to the data type for which random data needs to be generated; The metadata refers to the sub-unit data type contained in the data type of the collection type, dictionary type, and array type; The length refers to the data size used to generate random data.

2. The random data generation method according to claim 1, characterized in that: The determining the data type of the test parameter according to the test parameter, and generating random data corresponding to the data type according to the data type, includes: Parsing the test parameter to obtain a data identifier in the test parameter, wherein the data identifier is used to determine a data type of the test parameter; Matching the data identifier with a preset identifier library to obtain a matching result, wherein the identifier library is provided with a corresponding relationship between the data identifier and the data type; The data type of the test parameter is determined according to the matching result, and random data corresponding to the data type is generated according to the data type.

3. The random data generation method according to claim 2, characterized in that: The step of determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes: According to the matching result, determining whether the data identifier corresponds to a collection type; If the data identifier corresponds to a set type, determining that the data type of the test parameter is a set type; First metadata in the collection type is acquired, and random data corresponding to the collection type is generated according to the first metadata, where the first metadata is used to reflect attribute information of the collection type.

4. The random data generation method according to claim 3, characterized in that: The step of determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes: If the data identifier does not correspond to the set type, judging whether the data identifier corresponds to the dictionary type according to the matching result; If the data identifier corresponds to the dictionary type, determining that the data type of the test parameter is a dictionary type; Second metadata in the dictionary type is acquired, and random data corresponding to the dictionary type is generated according to the second metadata, where the second metadata is used to reflect attribute information of the dictionary type.

5. The random data generation method according to claim 4, characterized in that: The step of determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes: If the data identifier does not correspond to the dictionary type, judging whether the data identifier corresponds to the rule data type according to the matching result; If the data identifier corresponds to the regular data type, determining that the data type of the test parameter is the regular data type; A preset rule is searched from the rule data type and data matching is performed to generate random data corresponding to the rule data type.

6. The random data generation method according to claim 5, characterized in that: The step of determining the data type of the test parameter according to the matching result, and generating random data corresponding to the data type according to the data type, includes: If the data identifier does not correspond to the regular data type, judging whether the data identifier corresponds to a simple data type according to the matching result; If the data identifier corresponds to the simple data type, the data type of the test parameter is determined to be a simple data type: The adaptation information in the simple data type is obtained, and corresponding random data is generated according to the adaptation information, wherein the adaptation information is used to reflect the data attribute information in the simple data type so that the corresponding random data is generated according to the data attribute information.

7. The random data generation method according to claim 6, characterized in that: The generating corresponding random data according to the adaptation information includes: If the adaptation information is basic type information, generating random data corresponding to the basic type information; If the adaptation information is character string information, generating random data corresponding to the character string information; If the adaptation information is time information, random data corresponding to the time information is generated.

8. The random data generation method according to claim 1, characterized in that: After generating random data corresponding to the data type according to the data type, the method further includes: The random data is input into a verification process of a preset application program, and the random data is verified through the verification process to determine the running status of the preset application program.

9. A random data generating device, characterized in that: The device comprises: A parameter acquisition unit, used to acquire test parameters of a preset interface; A data generating unit, configured to determine a data type of the test parameter according to the test parameter, and to generate random data corresponding to the data type according to the data type, wherein the random data is used for the application to perform automated verification testing; The test parameters include data type identification, metadata and length data; The data type identifier refers to the identifier corresponding to the data type for which random data needs to be generated; The metadata refers to the sub-unit data type contained in the data type of the collection type, dictionary type, and array type; The length refers to the data size used to generate random data.

10. An intelligent terminal, characterized in that: The device comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include being used to execute the method according to any one of claims 1 to 8.

11. A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data verification method and device and computer storage medium

    CN109165017A