CN115934523A - Target test data generation method and device, storage medium and electronic device - Google Patents

Target test data generation method and device, storage medium and electronic device Download PDF

Info

Publication number
CN115934523A
CN115934523A CN202211510685.5A CN202211510685A CN115934523A CN 115934523 A CN115934523 A CN 115934523A CN 202211510685 A CN202211510685 A CN 202211510685A CN 115934523 A CN115934523 A CN 115934523A
Authority
CN
China
Prior art keywords
interface
test
tested
name
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211510685.5A
Other languages
Chinese (zh)
Inventor
王党军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd, Haier Uplus Intelligent Technology Beijing Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202211510685.5A priority Critical patent/CN115934523A/en
Publication of CN115934523A publication Critical patent/CN115934523A/en
Pending legal-status Critical Current

Links

Images

Abstract

The application discloses a method and a device for generating target test data, a storage medium and an electronic device, which relate to the technical field of smart families, wherein the method for generating the target test data comprises the following steps: acquiring interface parameters for testing an interface to be tested; obtaining the interface name of the interface to be tested from the interface parameter, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested; and determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function.

Description

Target test data generation method and device, storage medium and electronic device
Technical Field
The application relates to the technical field of smart homes, in particular to a method and device for generating target test data, a storage medium and an electronic device.
Background
At present, with the higher and higher automation level of the home appliance, the requirement of the user for the automatic test of the home appliance is also continuously increased. In the related art, the process of device testing is generally implemented by testing an interface of a device. However, for the interface test mode, a background technician needs to write a corresponding test case in advance on the tested interface and also needs to fill test data in the test case, and the mode has high manpower dependence and low efficiency. Therefore, in the related art, there is a problem how to generate test data to improve test efficiency.
In the related art, no effective solution is provided for the problem of how to generate test data to improve the test efficiency.
Disclosure of Invention
The embodiment of the application provides a method and a device for generating target test data, a storage medium and an electronic device, so as to at least solve the problem of how to generate the test data to improve the test efficiency in the related art.
According to an embodiment of the present application, a method for generating target test data is provided, including: acquiring interface parameters for testing an interface to be tested; obtaining the interface name of the interface to be tested from the interface parameter, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested; and determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function.
In one exemplary embodiment, obtaining interface parameters for testing an interface to be tested comprises: acquiring preset interface parameters corresponding to the interface to be tested, wherein the preset interface parameters at least comprise one of the following parameters: the interface name, the user name of the interface to be tested, the password of the interface to be tested and the expected test result of the interface to be tested; and responding to the selection operation of the target object, and determining the interface parameters from the preset interface parameters.
In an exemplary embodiment, determining a test type of the test data according to the interface name includes: searching the interface name in a preset interface name record; the preset interface name record comprises the corresponding relation between the interface name and the test type; and under the condition of successful searching, determining the test type corresponding to the interface name according to the corresponding relation.
In an exemplary embodiment, in the case that the search is successful, determining a test type corresponding to the interface name according to the correspondence includes: determining that the test type is a correct use case test under the condition that the interface name is a correct interface name, wherein the correct interface name comprises at least one of the following: correct user name, correct password; determining the test type to be a wrong use case test under the condition that the interface name is a wrong interface name, wherein the wrong interface name comprises at least one of the following: wrong user, wrong password; determining the test type to be null case test under the condition that the interface name is null interface name, wherein the null interface name comprises at least one of the following: the username does not exist and the password does not exist.
In an exemplary embodiment, determining an objective function from a plurality of functions corresponding to the test type includes: under the condition that the test type is determined to be the correct use case test, acquiring a first function corresponding to the correct use case test, wherein the first function is used for generating a correct user name and/or a correct password; under the condition that the first function is used for generating a correct user name, acquiring a plurality of first user names generated in a plurality of first functions; acquiring a first user name corresponding to the interface number of the interface to be tested in the plurality of first user names; determining a first function that generates the first username as the objective function.
In an exemplary embodiment, after obtaining the corresponding first function of the correct use case test, the method further includes: under the condition that the first function is used for generating a correct password, acquiring a first user name corresponding to the interface number of the interface to be tested from a plurality of first user names generated in a plurality of first functions; generating the correct password using a first function that generates the first username; determining the first function as the target function if the password format of the correct password is determined to be verified.
In an exemplary embodiment, after determining an objective function from a plurality of functions corresponding to the test type to generate objective test data for testing the interface to be tested using the objective function, the method further includes: testing the interface to be tested by using the target test data to obtain a target test result; under the condition that the target test result is determined to be consistent with the expected test result of the interface to be tested, storing the target test data to a server; and sending prompt information to the target object under the condition that the target test result is determined to be inconsistent with the expected test result, wherein the prompt information is used for prompting that the test result of the target test data is wrong.
According to another embodiment of the present application, there is also provided a device for generating target test data, including: the acquisition module is used for acquiring interface parameters for testing the interface to be tested; the obtaining module is used for obtaining the interface name of the interface to be tested from the interface parameter and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested; and the determining module is used for determining a target function from a plurality of functions corresponding to the test types and generating target test data for testing the interface to be tested according to the target function.
According to another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the method for generating target test data when running.
According to another aspect of the embodiments of the present application, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for generating target test data through the computer program.
In the embodiment of the application, interface parameters for testing the interface to be tested are obtained; obtaining the interface name of the interface to be tested from the interface parameter, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested; determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function; by adopting the technical scheme, the problem of how to generate the test data so as to improve the test efficiency is solved, and the test efficiency is further improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
FIG. 1 is a schematic diagram of a hardware environment of a method for generating target test data according to an embodiment of the present application;
FIG. 2 is a flow chart of a method of generating target test data according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a test flow according to an embodiment of the present application;
FIG. 4 is a block diagram (I) of a target test data generation apparatus according to an embodiment of the present application;
fig. 5 is a block diagram (ii) of a structure of a target test data generation apparatus according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the accompanying drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an aspect of an embodiment of the present application, a method for generating target test data is provided. The target test data generation method is widely applied to full-House intelligent digital control application scenes such as intelligent homes (Smart Home), intelligent homes, intelligent Home equipment ecology, intelligent House (Intelligent House) ecology and the like. Alternatively, in this embodiment, the method for generating the target test data may be applied to a hardware environment formed by the terminal device 102 and the server 104 as shown in fig. 1. As shown in fig. 1, the server 104 is connected to the terminal device 102 through a network, and may be configured to provide a service (e.g., an application service) for the terminal or a client installed on the terminal, set a database on the server or independent of the server, and provide a data storage service for the server 104, and configure a cloud computing and/or edge computing service on the server or independent of the server, and provide a data operation service for the server 104.
The network may include, but is not limited to, at least one of: wired networks, wireless networks. The wired network may include, but is not limited to, at least one of: wide area networks, metropolitan area networks, local area networks, which may include, but are not limited to, at least one of the following: WIFI (Wireless Fidelity), bluetooth. Terminal equipment 102 can be but not limited to be PC, the cell-phone, the panel computer, intelligent air conditioner, intelligent cigarette machine, intelligent refrigerator, intelligent oven, intelligent kitchen range, intelligent washing machine, intelligent water heater, intelligent washing equipment, intelligent dish washer, intelligent projection equipment, intelligent TV, intelligent clothes hanger, intelligent (window) curtain, intelligence audio-visual, smart jack, intelligent stereo set, intelligent audio amplifier, intelligent new trend equipment, intelligent kitchen guarding equipment, intelligent bathroom equipment, intelligence robot of sweeping the floor, intelligence robot of wiping the window, intelligence robot of mopping the ground, intelligent air purification equipment, intelligent steam ager, intelligent microwave oven, intelligent kitchen is precious, intelligent clarifier, intelligent water dispenser, intelligent lock etc..
In this embodiment, a method for generating target test data is provided, and is applied to the above-mentioned computer terminal, and fig. 2 is a flowchart of a method for generating target test data according to an embodiment of the present application, where the flowchart includes the following steps:
step S202, acquiring interface parameters for testing an interface to be tested;
step S204, obtaining the interface name of the interface to be tested from the interface parameters, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested;
step S206, determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function.
Acquiring interface parameters for testing the interface to be tested through the steps; obtaining the interface name of the interface to be tested from the interface parameters, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested; and determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function, so that the problem of how to generate the test data to improve the test efficiency in the related art is solved, and the test efficiency is improved.
In an exemplary embodiment, for the process of acquiring the interface parameters for testing the interface to be tested in step S202, the following steps may be combined, and specifically include: acquiring preset interface parameters corresponding to the interface to be tested, wherein the preset interface parameters at least comprise one of the following parameters: the interface name, the user name of the interface to be tested, the password of the interface to be tested and the expected test result of the interface to be tested; and responding to the selection operation of the target object, and determining the interface parameters from the preset interface parameters.
It should be noted that the expected test result has a corresponding relationship with the test purpose of the interface to be tested, for example, in the case that the interface to be tested is a "login interface", the expected test result may be set as successful login, failed login, abnormal login, etc.; in the case that the interface to be tested is a "network interface", the expected test result may be set as a success of networking, a failure of networking, or the like.
In an exemplary embodiment, in order to better understand a technical solution of how to determine the test type of the test data according to the interface name in step S204, the following implementation steps are provided, which specifically include: searching the interface name in a preset interface name record; the preset interface name record comprises the corresponding relation between the interface name and the test type; and under the condition of successful searching, determining the test type corresponding to the interface name according to the corresponding relation.
Optionally, in an embodiment, in the case of a failure in the search, a prompt message may be sent to the user to prompt that the interface name does not exist, and prompt the user to re-determine the test type.
In an exemplary embodiment, a technical solution for determining a test type corresponding to the interface name according to the correspondence when the search is successful is further provided, and the specific steps include: determining that the test type is a correct use case test under the condition that the interface name is a correct interface name, wherein the correct interface name comprises at least one of the following: correct user name, correct password; determining the test type to be a wrong use case test under the condition that the interface name is a wrong interface name, wherein the wrong interface name comprises at least one of the following: wrong user, wrong password; determining that the test type is null case test under the condition that the interface name is null interface name, wherein the null interface name comprises at least one of the following: the username is not present and the password is not present.
In an exemplary embodiment, a technical solution for determining an objective function from a plurality of functions corresponding to the test type is further provided, and the specific steps include: under the condition that the test type is determined to be a correct use case test, acquiring a first function corresponding to the correct use case test, wherein the first function is used for generating a correct user name and/or a correct password; under the condition that the first function is used for generating a correct user name, acquiring a plurality of first user names generated in a plurality of first functions; acquiring a first user name corresponding to the interface number of the interface to be tested in the plurality of first user names; determining a first function that generates the first username as the objective function.
Optionally, under the condition that the test type is determined to be a wrong use case test, obtaining a second function corresponding to the wrong use case test, where the second function is used to generate a wrong user name and/or a correct password; under the condition that the second function is used for generating a wrong user name, acquiring a plurality of second user names generated in a plurality of second functions; acquiring a second user name corresponding to the interface number of the interface to be tested in the plurality of second user names; determining a second function that generates the second username as the objective function, wherein the second username is different from the first username.
Optionally, after obtaining the corresponding first function of the correct case test, a technical scheme is further provided, which specifically includes: after the first function is used for generating a correct password, acquiring a second user name corresponding to the interface number of the interface to be tested from a plurality of second user names generated in a plurality of second functions; generating the error password using a second function that generates the second username; determining the second function as the objective function.
It should be noted that the case where the test type is null case test is similar to the case where the test type is correct case test, and details are not described herein again.
In an exemplary embodiment, after obtaining the corresponding first function of the correct use case test, a technical solution is further provided, which specifically includes: under the condition that the first function is used for generating a correct password, acquiring a first user name corresponding to the interface number of the interface to be tested from a plurality of first user names generated in a plurality of first functions; generating the correct password using a first function that generates the first username; determining the first function as the target function if the password format of the correct password is determined to be verified.
It should be noted that the above-mentioned password format represents a character string format formed by multiple types of data, and these data types may include letters, numbers, special symbols, and the like.
In an exemplary embodiment, after determining an objective function from a plurality of functions corresponding to the test type to generate objective test data for testing the interface to be tested by using the objective function, the objective test data may be used to test the interface to be tested to obtain an objective test result; under the condition that the target test result is determined to be consistent with the expected test result of the interface to be tested, storing the target test data to a server; and sending prompt information to the target object under the condition that the target test result is determined to be inconsistent with the expected test result, wherein the prompt information is used for prompting that the test result of the target test data is wrong.
In the process of determining an objective function from a plurality of functions corresponding to the test type, the objective function may be used to generate the objective test data in the following manner: generating the target test data according to a plurality of data structures and a random number algorithm; generating the target test data using a random number generation tool.
Optionally, in the above embodiment, the process of generating the password or the user name using the target function may be understood as a process of generating data using various data structures such as int, long int, char, tree, heap, hash manpu, linked list, and a random number algorithm. Or random variable data may be generated directly using a random number generation tool.
In order to better understand the process of the method for generating the target test data, the following describes a flow of a method for generating the target test data with reference to an optional embodiment, but the flow is not limited to the technical solution of the embodiment of the present application.
In this embodiment, a method for generating target test data is provided with reference to fig. 3, where fig. 3 is a schematic diagram of a test procedure according to an embodiment of the present application, and as shown in fig. 3, the following steps are specifically provided:
step S301: constructing an interface automation test;
step S302: acquiring the generated test data;
in one embodiment, for example, 5 test cases may be designed, and each test case is parameterized, that is, parameters such as an interface name, a user name, a password, an expected result (corresponding to the preset interface parameters) and the like are set as actual parameters corresponding to test data. The tests are shown in table 1 below, for example:
TABLE 1
Figure BDA0003970844950000091
Step S303: performing a test operation using the test data;
step S304, determining whether the interface test result is consistent with an expected result; if yes, go to step S307; if not, go to step S305.
Step S305: finding out the defects of the product;
step S306: submitting the defect to a defect system;
step S307: the test is passed.
In one embodiment, the test may be performed according to the test case provided in table 1, and whether the returned result of the interface is consistent with the expected result is determined. If the test cases are consistent, the corresponding test cases are judged to be accurate, and if the test cases are not consistent, the product defects can be found.
Next, a process of generating the target test data will be described with reference to table 2. In this embodiment, different data may be dynamically generated according to the objective function. As shown in table 2, taking case 1 as an example, for a variable user Name, the value "admin" corresponding to the Name of the interface case 1 is calculated according to the first function corresponding to the correct case test when the interface Name is the correct user Name and password (i.e., the correct interface Name). The first function may be, for example, "fx = RANDBETWEEN (0, 99999999)", or "fx = CHAR (INT (RAND () + 24) + 97) & CHAR (INT (RAND ()) + 97) & CHAR (INT (RAND () + 24) + 97) & CHAR (INT (RAND () + 97) & CHAR (RANDBETWEEN (1, 2)),", CHAR (INT (RAND () + 24) + 97) & CHAR (randetween (1, 2)), ", CHAR (RAND () + 97) & CHAR (RAND () + 24) & text (RAND (1) (99)", "00").
TABLE 2
Figure BDA0003970844950000101
Similarly, as shown in table 2, for the variable Password, when the Name value of the interface use case 1 is determined to be "admin" (which corresponds to a case where the first function is used to generate a correct Password), the first function generating "admin" is used to generate a value "12345678" corresponding to Password.
Optionally, in other embodiments, each pair of interfaces to be tested is tested once, and a new set of target test data of the interfaces to be tested is regenerated, so that different test data are provided, and forward verification and reverse verification of the interfaces to be tested can be realized, thereby improving accuracy of a test result.
Through the embodiment, the testing efficiency can be improved, and the correctness and the robustness of the testing result can be improved. Aiming at the scene of generating a large amount of test data, the efficiency of compiling the test script is improved, the coverage of automatic test and the quality of software test are improved, and the correctness and the stability of the test result of the interface to be tested are also improved.
Optionally, in an embodiment, the flow of the interface test may be briefly summarized as follows:
step 1: writing test cases, for example, in csv files;
step 2: reading a test case, and performing parameter configuration on the interface to be tested;
and step 3: generating target test data for testing the interface to be tested;
and 4, step 4: obtaining a test result of testing the interface to be tested by using the target test data;
and 5: and when the test result is consistent with the expected result, determining that the interface to be tested passes the test.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method of the embodiments of the present application.
Fig. 4 is a block diagram (a) of a target test data generation apparatus according to an embodiment of the present application, and as shown in fig. 4, the target test data generation apparatus includes:
an obtaining module 62, configured to obtain interface parameters for testing an interface to be tested;
an obtaining module 64, configured to obtain an interface name of the interface to be tested from the interface parameter, and determine a test type of test data according to the interface name, where the test data is used to test the interface to be tested;
the determining module 66 is configured to determine an objective function from a plurality of functions corresponding to the test type, and generate target test data for testing the interface to be tested according to the objective function.
Acquiring interface parameters for testing an interface to be tested through the device; obtaining the interface name of the interface to be tested from the interface parameter, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested; and determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function, so that the problem of how to generate the test data to improve the test efficiency in the related art is solved, and the test efficiency is improved.
In an exemplary embodiment, the obtaining module 62 is further configured to: acquiring preset interface parameters corresponding to the interface to be tested, wherein the preset interface parameters at least comprise one of the following parameters: the interface name, the user name of the interface to be tested, the password of the interface to be tested and the expected test result of the interface to be tested; and responding to the selection operation of the target object, and determining the interface parameters from the preset interface parameters.
It should be noted that, the expected test result has a corresponding relationship with the test purpose of the interface to be tested, for example, in the case that the interface to be tested is a "login interface", the expected test result may be set as successful login, failed login, abnormal login, etc.; in the case that the interface to be tested is a "network interface", the expected test result may be set as a success of networking, a failure of networking, or the like.
In an exemplary embodiment, the obtaining module 64 is further configured to: searching the interface name in a preset interface name record; the preset interface name record comprises the corresponding relation between the interface name and the test type; and under the condition of successful searching, determining the test type corresponding to the interface name according to the corresponding relation.
Optionally, in an embodiment, in the case of a failure in the search, a prompt message may be sent to the user to prompt that the interface name does not exist, and prompt the user to re-determine the test type.
In an exemplary embodiment, the obtaining module 64 is further configured to: determining that the test type is a correct case test under the condition that the interface name is a correct interface name, wherein the correct interface name comprises at least one of the following: correct user name, correct password; determining that the test type is a wrong case test under the condition that the interface name is a wrong interface name, wherein the wrong interface name comprises at least one of the following items: wrong user, wrong password; determining the test type to be null case test under the condition that the interface name is null interface name, wherein the null interface name comprises at least one of the following: the username does not exist and the password does not exist.
In an exemplary embodiment, the obtaining module 64 is further configured to: under the condition that the test type is determined to be a correct use case test, acquiring a first function corresponding to the correct use case test, wherein the first function is used for generating a correct user name and/or a correct password; under the condition that the first function is used for generating a correct user name, acquiring a plurality of first user names generated in a plurality of first functions; acquiring a first user name corresponding to the interface number of the interface to be tested in the plurality of first user names; determining a first function that generates the first username as the objective function.
Optionally, under the condition that the test type is determined to be the wrong case test, obtaining a second function corresponding to the wrong case test, where the second function is used to generate a wrong user name and/or a correct password; under the condition that the second function is used for generating wrong user names, acquiring a plurality of second user names generated in a plurality of second functions; acquiring a second user name corresponding to the interface number of the interface to be tested in the plurality of second user names; determining a second function that generates the second username as the objective function, wherein the second username is different from the first username.
Optionally, after obtaining the corresponding first function of the correct case test, a technical scheme is further provided, which specifically includes: after the first function is used for generating a correct password, acquiring a second user name corresponding to the interface number of the interface to be tested from a plurality of second user names generated in a plurality of second functions; generating the error password using a second function that generates the second username; determining the second function as the objective function.
It should be noted that the case where the test type is null case test is similar to the case where the test type is correct case test, and details are not described herein again.
In an exemplary embodiment, the obtaining module 64 is further configured to: under the condition that the first function is used for generating a correct password, acquiring a first user name corresponding to the interface number of the interface to be tested from a plurality of first user names generated in a plurality of first functions; generating the correct password using a first function that generates the first username; determining the first function as the target function if the cryptographic format of the correct password is determined to be verified.
It should be noted that the above-mentioned password format represents a character string format formed by multiple types of data, and these data types may include letters, numbers, special symbols, and the like.
In an exemplary embodiment, the apparatus for generating target test data further includes: the test module is used for determining a target function from a plurality of functions corresponding to the test type, generating target test data for testing the interface to be tested by using the target function, and then testing the interface to be tested by using the target test data to obtain a target test result; under the condition that the target test result is determined to be consistent with the expected test result of the interface to be tested, storing the target test data to a server; and sending prompt information to the target object under the condition that the target test result is determined to be inconsistent with the expected test result, wherein the prompt information is used for prompting that the test result of the target test data is wrong.
Fig. 5 is a block diagram (ii) of a structure of a target test data generation apparatus according to an embodiment of the present application, and as shown in fig. 5, in an exemplary embodiment, the target test data generation apparatus further includes:
a generating module 52, configured to, in a process of determining an objective function from a plurality of functions corresponding to the test type, generate the target test data by using the objective function in the following manner: generating the target test data according to a plurality of data structures and a random number algorithm; generating the target test data using a random number generation tool.
Optionally, in the above embodiment, the process of generating the password or the user name using the target function may be understood as a process of generating data using various data structures such as int, long int, char, tree, heap, hash manpu, linked list, and a random number algorithm. Or the random number generation tool may be used directly to generate the randomly variable data.
Embodiments of the present application further provide a storage medium including a stored program, where the program executes the method of any one of the above.
Alternatively, in the present embodiment, the storage medium may be configured to store program codes for performing the following steps:
s1, acquiring interface parameters for testing an interface to be tested;
s2, obtaining the interface name of the interface to be tested from the interface parameters, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested;
and S3, determining a target function from the plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function.
Embodiments of the present application further provide an electronic device comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring interface parameters for testing an interface to be tested;
s2, obtaining the interface name of the interface to be tested from the interface parameters, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested;
and S3, determining a target function from the plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function.
Optionally, in this embodiment, the storage medium may include but is not limited to: various media capable of storing program codes, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present application described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The foregoing is only a preferred embodiment of the present application and it should be noted that, as will be apparent to those skilled in the art, numerous modifications and adaptations can be made without departing from the principles of the present application and such modifications and adaptations are intended to be considered within the scope of the present application.

Claims (10)

1. A method for generating target test data, comprising:
acquiring interface parameters for testing an interface to be tested;
obtaining the interface name of the interface to be tested from the interface parameters, and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested;
and determining a target function from a plurality of functions corresponding to the test type, and generating target test data for testing the interface to be tested according to the target function.
2. The method for generating target test data according to claim 1, wherein obtaining interface parameters for testing an interface to be tested comprises:
acquiring preset interface parameters corresponding to the interface to be tested, wherein the preset interface parameters at least comprise one of the following parameters: the interface name, the user name of the interface to be tested, the password of the interface to be tested and the expected test result of the interface to be tested;
and responding to the selection operation of the target object, and determining the interface parameters from the preset interface parameters.
3. The method for generating target test data according to claim 1, wherein determining the test type of the test data according to the interface name comprises:
searching the interface name in a preset interface name record; the preset interface name record comprises the corresponding relation between the interface name and the test type;
and under the condition of successful searching, determining the test type corresponding to the interface name according to the corresponding relation.
4. The method for generating target test data according to claim 3, wherein, in the case of successful search, determining the test type corresponding to the interface name according to the correspondence includes:
determining that the test type is a correct use case test under the condition that the interface name is a correct interface name, wherein the correct interface name comprises at least one of the following: correct user name, correct password;
determining the test type to be a wrong use case test under the condition that the interface name is a wrong interface name, wherein the wrong interface name comprises at least one of the following: wrong user, wrong password;
determining the test type to be null case test under the condition that the interface name is null interface name, wherein the null interface name comprises at least one of the following: the username is not present and the password is not present.
5. The method for generating target test data according to claim 4, wherein determining the target function from a plurality of functions corresponding to the test type includes:
under the condition that the test type is determined to be a correct use case test, acquiring a first function corresponding to the correct use case test, wherein the first function is used for generating a correct user name and/or a correct password;
under the condition that the first function is used for generating a correct user name, acquiring a plurality of first user names generated in a plurality of first functions;
acquiring a first user name corresponding to the interface number of the interface to be tested in the plurality of first user names;
determining a first function that generates the first username as the objective function.
6. The method for generating target test data according to claim 5, wherein after obtaining the corresponding first function of the correct use case test, the method further comprises:
under the condition that the first function is used for generating a correct password, acquiring a first user name corresponding to the interface number of the interface to be tested from a plurality of first user names generated in a plurality of first functions;
generating the correct password using a first function that generates the first username;
determining the first function as the target function if the cryptographic format of the correct password is determined to be verified.
7. The method for generating target test data according to claim 1, wherein after determining a target function from a plurality of functions corresponding to the test type to generate target test data for testing the interface to be tested using the target function, the method further comprises:
testing the interface to be tested by using the target test data to obtain a target test result;
under the condition that the target test result is determined to be consistent with the expected test result of the interface to be tested, storing the target test data to a server;
and sending prompt information to a target object under the condition that the target test result is determined to be inconsistent with the expected test result, wherein the prompt information is used for prompting that the test result of the target test data is wrong.
8. An apparatus for generating target test data, comprising:
the acquisition module is used for acquiring interface parameters for testing the interface to be tested;
the obtaining module is used for obtaining the interface name of the interface to be tested from the interface parameters and determining the test type of test data according to the interface name, wherein the test data is used for testing the interface to be tested;
and the determining module is used for determining a target function from a plurality of functions corresponding to the test types and generating target test data for testing the interface to be tested according to the target function.
9. A computer-readable storage medium, comprising a stored program, wherein the program is operable to perform the method of any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 7 by means of the computer program.
CN202211510685.5A 2022-11-29 2022-11-29 Target test data generation method and device, storage medium and electronic device Pending CN115934523A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211510685.5A CN115934523A (en) 2022-11-29 2022-11-29 Target test data generation method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211510685.5A CN115934523A (en) 2022-11-29 2022-11-29 Target test data generation method and device, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN115934523A true CN115934523A (en) 2023-04-07

Family

ID=86556972

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211510685.5A Pending CN115934523A (en) 2022-11-29 2022-11-29 Target test data generation method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN115934523A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117171056A (en) * 2023-11-02 2023-12-05 绿城科技产业服务集团有限公司 Test method and device based on automatic interface

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117171056A (en) * 2023-11-02 2023-12-05 绿城科技产业服务集团有限公司 Test method and device based on automatic interface
CN117171056B (en) * 2023-11-02 2024-01-09 绿城科技产业服务集团有限公司 Test method and device based on automatic interface

Similar Documents

Publication Publication Date Title
CN115934523A (en) Target test data generation method and device, storage medium and electronic device
CN111030840A (en) Method and device for generating topological graph, electronic equipment and storage medium
CN112115060A (en) Audio test method and system based on terminal
CN115687806A (en) Method and device for determining target equipment list, storage medium and electronic device
CN116107975A (en) Control method and device of equipment, storage medium and electronic device
CN114924908A (en) Data backup method and device, storage medium and electronic device
CN111444091B (en) Test case generation method and device
CN115345225A (en) Method and device for determining recommended scene, storage medium and electronic device
CN115454851A (en) Interface regression testing method and device, storage medium and electronic device
CN114860675A (en) Log generation method, device, equipment and storage medium
CN114861678A (en) Method and apparatus for determining time information, storage medium, and electronic apparatus
CN106776257B (en) Response time statistical method and device for system performance test
CN115834435A (en) Interface test method and device, storage medium and electronic device
CN115002014A (en) Method and device for determining test result, storage medium and electronic device
CN116301767A (en) Interface file generation method and device, storage medium and electronic device
CN115794116A (en) Dynamic project publishing method and device, storage medium and electronic device
CN115357446A (en) Device testing method and device, storage medium and electronic device
CN109547305B (en) Operation control method, device, household appliance, system and storage medium
CN115297096A (en) Resource package deployment method and device, storage medium and electronic device
CN115687349A (en) Database table generation method and device, storage medium and electronic device
CN115865650A (en) Service deployment method and device, storage medium and electronic device
CN114999494A (en) Voice interaction function testing method and device, storage medium and electronic device
CN114860592A (en) Application function testing method and device, storage medium and electronic device
CN113890846A (en) Distribution network detection method, device and system, storage medium and terminal equipment
CN115480796A (en) Application program file updating method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination