CN115658552A - Test data recommendation method and device, storage medium and electronic equipment - Google Patents

Test data recommendation method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN115658552A
CN115658552A CN202211670919.2A CN202211670919A CN115658552A CN 115658552 A CN115658552 A CN 115658552A CN 202211670919 A CN202211670919 A CN 202211670919A CN 115658552 A CN115658552 A CN 115658552A
Authority
CN
China
Prior art keywords
code
test
name
test data
data
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
CN202211670919.2A
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.)
Haima Cloud Tianjin Information Technology Co Ltd
Original Assignee
Haima Cloud Tianjin Information Technology 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 Haima Cloud Tianjin Information Technology Co Ltd filed Critical Haima Cloud Tianjin Information Technology Co Ltd
Priority to CN202211670919.2A priority Critical patent/CN115658552A/en
Publication of CN115658552A publication Critical patent/CN115658552A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application provides a test data recommendation method, a test data recommendation device, a storage medium and electronic equipment, wherein the method comprises the following steps: obtaining a method of change in the change code; determining a method corresponding to the changed method and a method influenced by a change code according to the corresponding relation between the prestored method name and the associated method name, wherein the method influenced by the change code comprises the method corresponding to the changed method and the method correspondingly related to the changed method; determining a test scene corresponding to the method influenced by the change code according to the corresponding relation between the prestored method name and the test scene and/or determining test data corresponding to the method influenced by the change code according to the corresponding relation between the prestored method name and the test data; and determining the test scene and/or the test data as the data to be tested for recommendation. The invention can improve the efficiency of software testing.

Description

Test data recommendation method and device, storage medium and electronic equipment
Technical Field
The application relates to the field of testing, in particular to a test data recommendation method and device, a storage medium and electronic equipment.
Background
In the development of software products, testing is a very important task, which determines whether the software product can work properly. Each software development or modification requires testing to ensure that the software product is available. Software development is generally not completed at one time, and the development process of software products is a continuous process. This is because there may be hidden problems with the software product, and the software product is subsequently modified and optimized for these problems. Meanwhile, with the increase of the demand, the software product can be upgraded after being released and used.
In the optimization and upgrade process of the software product, the software product needs to be tested every time the software product is optimized and upgraded. Since the optimized functions or upgraded functions may affect other functions, most of the current testing methods are full-scale functional testing methods, that is, all functions of the software are tested, so as to ensure the usability of the software product. However, as software products are developed and software functions are continuously increased, the full-scale function test takes more and more time, consumes a great deal of manpower, and prolongs the time for the software products to be released again.
Disclosure of Invention
In view of the above problems, the present application provides a test data recommendation method, a storage medium, and an electronic device, so as to solve the problems that, when optimizing or upgrading a software product at present, all functions of the software product need to be tested, which results in long test time and large manpower consumption.
In a first aspect, an embodiment of the present application provides a test data recommendation method, where the method includes the following steps:
obtaining a method of change in the change code;
determining a method corresponding to the changed method and a method influenced by a change code according to the corresponding relation between the prestored method name and the associated method name, wherein the method influenced by the change code comprises the method corresponding to the changed method and the method correspondingly related to the changed method;
determining a test scene corresponding to the method influenced by the change code according to the corresponding relation between the prestored method name and the test scene and/or determining test data corresponding to the method influenced by the change code according to the corresponding relation between the prestored method name and the test data;
and determining the test scene and/or the test data as the data to be tested for recommendation.
In a second aspect, an embodiment of the present application further provides a device for recommending test data, where the device includes: an acquisition unit configured to acquire a method of change in a change code;
the first determining unit is used for determining a method corresponding to the changed method and a method influenced by the changed code according to the corresponding relation between the prestored method name and the associated method name, wherein the method influenced by the changed code comprises the changed method and the method corresponding to the changed method;
the second determining unit is used for determining a test scene corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test scene and/or determining test data corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test data;
and the recommending unit is used for determining the test scene and/or the test data as the test data to recommend.
In a third aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the test data recommendation method according to the first aspect.
In a fourth aspect, an embodiment of the present application further provides an electronic device, including: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the test data recommendation method according to the first aspect.
Different from the prior art, the test data recommendation method, device, storage medium and electronic device provided by the embodiment of the application include: and determining the corresponding associated method of the changed method and determining the method influenced by the change code according to the corresponding relation between the prestored method name and the associated method name. The method for changing the code influence is determined, and the test scene corresponding to the method for changing the code influence is determined according to the corresponding relation between the pre-stored method name and the test scene. Therefore, the functional test can be performed on the affected scenes in a targeted manner, the test on all the scenes is avoided, and the problems of long test time and large labor consumption caused by all the tests are avoided. And further determining the test data corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test data. Therefore, the pre-stored test data can be used for testing, the required test data does not need to be manually input in the test process, and the test efficiency is improved. And finally, determining the test scene and/or the test data as the test data to recommend, wherein the test user can select the scene and the data from the recommended scene and data to test, and the test efficiency is improved.
The above description of the present invention is only an overview of the technical solutions of the present application, and in order to make the technical solutions of the present application more clearly understood by those skilled in the art, the present invention may be further implemented according to the content described in the text and drawings of the present application, and in order to make the above objects, other objects, features, and advantages of the present application more easily understood, the following description is made in conjunction with the detailed description of the present application and the drawings.
Drawings
The drawings are only for purposes of illustrating the principles, implementations, applications, features, and effects of particular embodiments of the present application, as well as others related thereto, and are not to be construed as limiting the application.
In the drawings of the specification:
FIG. 1 is a flowchart of a test data recommendation method according to a first exemplary embodiment of the present application;
fig. 2 is a flowchart of obtaining a correspondence between a method name and a test scenario according to an exemplary embodiment of the present application;
fig. 3 is a flowchart of obtaining a correspondence between a method name and test data according to a first exemplary embodiment of the present application;
FIG. 4 is a schematic structural diagram of a test data recommendation device according to an exemplary embodiment of the present application;
FIG. 5 is a schematic structural diagram of a test data recommendation device according to another exemplary embodiment of the present application;
FIG. 6 is a block diagram of an electronic device according to an exemplary embodiment of the present application;
the reference numerals referred to in the above figures are explained below:
10. a test data recommendation device; 101. an acquisition unit; 102. a first determination unit; 103. a second determination unit; 104. a recommendation unit; 105. a scene correspondence relationship establishing unit; 106. a method correspondence establishing unit; 107. a data corresponding relation establishing unit;
600. an electronic device; 601. a processor; 602. a memory; 603. a bus.
Detailed Description
In order to explain in detail possible application scenarios, technical principles, practical embodiments, and the like of the present application, the following detailed description is given with reference to the accompanying drawings in conjunction with the listed embodiments. The embodiments described herein are merely for more clearly illustrating the technical solutions of the present application, and therefore, the embodiments are only used as examples, and the scope of the present application is not limited thereby.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase "in one embodiment" in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or related to other embodiments specifically defined. In principle, in the present application, the technical features mentioned in the embodiments can be combined in any manner to form a corresponding implementable technical solution as long as there is no technical contradiction or conflict.
Unless defined otherwise, technical terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the use of relational terms herein is intended only to describe particular embodiments and is not intended to limit the present application.
In the description of the present application, the term "and/or" is a expression for describing a logical relationship between objects, meaning that three relationships may exist, for example a and/or B, meaning: there are three cases of A, B, and both A and B. In addition, the character "/" herein generally indicates that the former and latter associated objects are in a logical relationship of "or".
In this application, terms such as "first" and "second" are used merely to distinguish one entity or operation from another entity or operation without necessarily requiring or implying any actual such relationship or order between such entities or operations.
Without further limitation, in this application, the use of "including," "comprising," "having," or other similar open-ended expressions in phrases is intended to cover a non-exclusive inclusion, and such expressions do not exclude the presence of additional elements in a process, method, or article that includes the elements, such that a process, method, or article that includes a list of elements may include not only those elements defined, but other elements not expressly listed or inherent to such process, method, or article.
As is understood in the examination of the guidelines, the terms "greater than", "less than", "more than" and the like in this application are to be understood as excluding the number; the expressions "above", "below", "within" and the like are understood to include the present numbers. Furthermore, the description of embodiments herein of the present application of the term "plurality" means more than two (including two), and the analogous meaning of "plurality" is also to be understood, e.g., "plurality", etc., unless explicitly specified otherwise.
In a first aspect, please refer to fig. 1, which is a flowchart illustrating a method for recommending test data according to a first exemplary embodiment of the present application, the method includes the following steps:
the process first proceeds to step S101 to obtain the method of change in the change code. It should be noted that, the methods described herein are not methods of method steps, but methods in software code, which may be called software methods or code methods, where there are generally multiple code files in a piece of software, each code file includes more than one method, and a piece of code is included in a method for implementing the functions of the method, and in software code developed by Java, the method corresponds to the method of the code of the present invention. When the code in the software method is changed, the software method in which the code is located is the method changed in the changed code. Specifically, the modified method obtained here may include a method name (i.e., a method name) of the method, and since the method name may be repeated in different class files (or code files), the method name may further include a class name or a code file name. The obtained modified method may further include a line number where the modified code line is located in the method, in addition to the method name of the method. Since the modified methods may include one or more, a list of modified methods may be output to facilitate processing of the next step.
And then, step S102 is carried out, according to the corresponding relation between the pre-stored method name and the associated method name, the method corresponding to the changed method and the method influenced by the changed code are determined, wherein the method influenced by the changed code comprises the changed method and the method corresponding to the changed method. The method changed here is the method where the code changed is located, and the associated method includes the method where the code of the changed method is located. If the method A internally comprises a code for calling the method B, the changed method is the method B after the code of the method B is changed, and the method A is the associated method. Both method A and method B are methods affected by the change code. Further, if method C contains a code for calling method a, since method a is a method affected by a change code and method C is also a method associated with method a, method C is also a method affected by a change code. Other methods of software analogize to this.
And then, step S103 is carried out to determine a test scene corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test scene and/or determine test data corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test data. A scenario herein refers to a software function, and a software function comprises one or more methods when executed, and a method corresponds to one or more software functions. The test scenario is a software function that includes the method affected by the change code. If one software comprises a user name conflict detection method, and the new registration function scene and the user name modification function scene both need to detect whether the user name conflicts, namely, the new registration function scene and the user name modification function scene both correspondingly comprise the user name conflict detection method, and the corresponding relation is prestored in the corresponding relation between the method name and the test scene. When the code of the user name conflict detection method is changed, the method where the changed code is located is the user name conflict detection method, and the corresponding test scene is a new registration function scene and a user name function modification scene. The test data in this embodiment is data required by the software method during testing, and generally refers to entry data of the software method, and the software method may receive the test data and execute the internal code during testing to implement data processing, and one software method may correspond to one or more groups of test data. The "and/or" in step S103 means that the test scenario or the test data may be determined separately, and the determination of the test scenario separately may play a role in reducing the test scenario, thereby improving the test efficiency. The independent determination of the test data can avoid manual input of the test data, so that the test efficiency is improved. The sum means that the test scene can be determined and the test data can be determined independently, so that the test scene can be reduced, the test data can be prevented from being input manually, and the test efficiency is improved.
And then, the step S104 is carried out to determine the test scene and/or the test data as the tested data for recommendation. The recommendation of the embodiment may be that the displayed test scenario and/or test data is given to the test user, and the user may select the displayed test scenario and/or test data to test the software. The test scene or the test data can have multiple groups, and the test user can select one group or several groups to test. Therefore, after the code is changed, a test user can obtain a test scene and/or test data to be tested, so that the software with the changed code can be tested in a targeted manner, all functions of the software do not need to be tested, and the test efficiency is improved.
In some embodiments, the recommending step S104 may also be sending the test scenario and/or the test data to an automated test program, and the automated test program receives the recommended test scenario and/or the test data, automatically tests the software that changes the code using the test scenario and/or the test data, and then may output the test result. Therefore, automatic testing can be realized, manual operation is saved, and the testing efficiency is further improved.
In the above embodiments, the modified codes are for convenience of description of the codes, and are not limited to the actual modified codes at present, because the codes themselves are a process from scratch, and all the codes can be regarded as modified codes. The modified codes can be currently modified codes, such as codes added, deleted or changed on the basis of original codes; the modified codes can also be codes which are not actually modified currently, such as codes selected by a user or specified codes, and the invention can acquire the codes and realize the method for acquiring the codes. In some embodiments, the altered code may also be a code with an alteration flag, such as adding an alteration flag (e.g., a specific string) to the annotation of the code, and the code with the flag may then be considered the altered code. Or the modified code may be obtained by comparing the two code files. The method specifically comprises the following steps: and comparing the two different code files, determining a different code and taking the different code as the change code. Because one piece of software contains a plurality of code files, the two code files to be compared in the embodiment can be files with different versions and the same file name (including the path where the file is located) in the same piece of software, and all the code files in the piece of software can be automatically compared with all the code files in different versions of the piece of software, so that the changed codes in all the codes in two different versions of the same piece of software can be compared. Typically, one of the two code files is pre-modified and the other is post-modified. The code file before modification and the code file after modification can be determined by comparing the modification time or the version number of the code file, and the code file after modification and with a larger version number can be used as the modified code file, or a certain code file can be designated as the modified code file by a test user. The altered code here is generally the code that was altered in the modified code file. If the modified code files in different versions of the same software are deleted during comparison, namely the code files are contained before modification and the code files are not contained after modification, all codes in the code files before modification are considered to be deleted, and all codes in the code files before modification are used as change codes. Therefore, the change code can be automatically determined by comparing the two code files, and the efficiency of determining the change code is improved.
In some embodiments, aligning two different code files may employ the following steps: and comparing the code files among different versions with the same file name by using an algorithm of solving the maximum continuous sub-sequence to obtain the lines of the code files with different lines. And analyzing the code file to obtain the interval of the starting line and the ending line of which method the differential line is located in, and finally outputting a method list, namely, changing the method of the corresponding change of the code. The naming format of the altered method may be to contain the file name (which may contain the file path) and the method name so that it is known which method of which file was altered. In some embodiments, the naming format may also include a line number for the change code, where the line number may be multiple lines, i.e., the change code line number in a changed method may be multiple lines, and the change code line number in a changed method naming may include multiple line numbers. Therefore, the specific modified lines can be known, and after the subsequent related test, if the test fails, the modified codes can be quickly positioned according to the line numbers of the modified codes to analyze the codes. In Java software, the code file may be a class file, and the file name may be a class name, so the naming format of the changed method may include the class name and the method name, and further may include a change line number, and the format may be: class name, method name, and change line number.
In some embodiments, the modified method, the content of the specific corresponding modified code and the modification mode (such as deletion, modification or addition) can be stored during comparison, and the corresponding relationship between the method name and the content of the modified code and the modification mode is stored, so that the corresponding modified code can be quickly found out according to the modified method and the corresponding relationship, the code can be quickly analyzed, a test user does not need to open code files one by one for analysis, and the analysis efficiency is improved.
On the basis of the foregoing method embodiment, the correspondence between the pre-stored method name and the associated method name is obtained by the following steps: reading the code file, obtaining the method name of the method in the code file, calling the method name of the method in the code file and storing the method name and the method name as the corresponding relation. The code file may be a code file before modification or a code file after modification.
In the above embodiment, the specific calling meaning in the method name for calling the method in the code file is as follows: and if the code of a certain method comprises a code for calling other methods, the other methods are the methods in the code file, and the method name of the certain method is the name of the method for calling the methods in the code file.
In addition to calling the method name of the method in the code file, the method name of the method called by the method in the code file may be acquired, the method name of the method in the code file and the method name of the method called by the method in the code file are stored as the correspondence between the method names and the associated method names, or the method name of the method in the code file, the method name of the method called by the method in the code file and the method name of the method called by the method in the code file are stored as the correspondence between the method names and the associated method names.
Thus, after determining the corresponding relationship between the method name and the associated method name, the method corresponding to the modified method can be determined by querying the corresponding relationship, and the modified method and the method corresponding to the modified method are used as the method for changing the code influence. After the method for changing the code influence is determined, the line number changed in the method for changing the code influence can be determined, and the storage format can be [ class name ] [ method name ] [ line ].
Thus, by reading and analyzing the code in the code file and the internal method name in the code, the corresponding relation between the method name and the associated method name can be determined, the automatic processing of the device for operating the method can be realized, and the processing efficiency is improved.
On the basis of the foregoing method embodiment, the obtaining a method name of a method in a code file and calling the method name of the method in the code file and storing the method name as a correspondence between the method name and an associated method name includes the following steps: and converting the code file into an abstract syntax tree, and analyzing the abstract syntax tree to obtain a method name for calling the method in the code file and/or a method name for calling the method in the code file. That is, the code file may be loaded into a memory and analyzed using an Abstract Syntax Tree (AST). The code in the code file is represented in a tree form in an abstract syntax structure, each node on the tree represents one structure in the code, key method calls and object references are extracted from the structure, and all calls and called relation lists are stored. By analyzing all code files of a piece of software, the calling and called relations of the methods among all the code files are obtained. The data analyzed may be stored in a relational data structure in a data table, with a master attribute possibly associated with multiple candidate attributes, i.e., a method possibly associated with multiple methods. The format of the data storage can be [ class name ] [ method name ]: [ class name ] [ method name ], and the method name after the colon is the method for associating the method name before the colon. In a specific embodiment, when the abstract syntax tree is analyzed, a code in a code file may be converted into the abstract syntax tree, then each statement of the code may be quickly analyzed through algorithms such as a middle-order traversal, and a method external call and an external call relation are analyzed through the statement, so as to determine the method and the method associated with the method, and then the method name and the method name associated with the method name are stored as a corresponding relation. By the abstract syntax tree and the middle-order traversal algorithm, the analysis and the acquisition of the method and the correlation method in the code can be completed quickly and accurately.
The above-described embodiment completes the preprocessing and storage of the correspondence between the method name and the associated method name, and then the preprocessing and storage of the correspondence between the method name and the test scenario are required. In this embodiment, the correspondence between the pre-stored method name and the test scenario is obtained through the following steps: the method comprises the steps of obtaining code coverage rate data of a plurality of scenes, determining methods related to code running tracks under the scenes and code lines running in the methods by performing deep traversal on the code coverage rate data, establishing corresponding relations between method names of the methods related to the code running tracks under the scenes, line numbers of the code lines running in the methods and the corresponding scenes, and storing the corresponding relations between the method names and test scenes. The code coverage rate data is data of which method and which line of code are executed when a certain scene is triggered during the running of software. It should be noted that, the multiple scenes means that one piece of software includes multiple scenes, the obtained code coverage data of the multiple scenes means code coverage data in each of the multiple scenes, and each scene has its own individual code coverage data, rather than corresponding code coverage data after the multiple scenes are regarded as a whole. Referring to fig. 2 for a specific implementation process of this embodiment, fig. 2 is a flowchart of a method for preprocessing and storing a correspondence between a method name and a test scenario according to an exemplary embodiment of the present application. The method firstly enters a step S201 scene trigger, and the flow enters. If the scene can be a scene of 'registration', 'ordering' or 'sharing', and the like, then manually clicking a functional button of 'registration', 'ordering' or 'sharing' on a webpage page to realize scene triggering, and the data flow can enter an Agent platform (Agent) for running software after triggering. And then, the step S202 is executed by the agent, that is, the agent platform executes the method corresponding to the scenario. In the execution process, step S203 is performed to acquire data by the coverage platform, that is, the coverage platform acquires data of the code when the scene is executed, that is, the coverage data of the scene. After the scene is executed, step S204 is performed to analyze the data and establish a corresponding relationship, where the corresponding relationship is a corresponding relationship between the method name and the test scene, which is referred to as a scene corresponding relationship for short. In specific analysis, a recursive algorithm can be used to perform deep traversal on the coverage rate data, and a code running track executed by a scene is obtained and recorded, wherein the code running track comprises data such as a method name of an operation method, a line number of a code line operated in the method and the like. The format of the record may be [ scene ], [ class name ] [ method name ] [ line ]. The scene corresponding relation coefficient data is stored in a database in a one-to-many mode, namely, one scene corresponds to a plurality of class names and method names. Through deep traversal of the coverage rate data, complete data acquisition of a method and a code line running in one scene can be realized, and then comprehensive test of a test scene corresponding to the method can be realized during test, so that omission of the test scene is avoided. After the corresponding relationship between the method name and the test scene is determined, the corresponding relationship can be inquired to obtain the test scene corresponding to the line number changed in the method for changing the code influence.
On the basis of the foregoing method embodiment, the correspondence between the pre-stored method name and the test data is obtained by the following steps: determining a method run in a code by a byte code instrumentation technology, and acquiring the parameter data of the method run in the code; and establishing a corresponding relation between the method name of the method operated in the code and the reference data, and storing the corresponding relation as the corresponding relation between the method name and the test data. Referring to fig. 3 for a specific implementation process of this embodiment, fig. 3 is a flowchart of a method for preprocessing and storing a corresponding relationship between a method name and test data according to an exemplary embodiment of the present application. Firstly, entering step S301 to mark codes, and performing byte code instrumentation on the codes of the production environment by using an AOP technology (AOP is an abbreviation of Aspect Programming, which means a technology for realizing unified maintenance of program functions by a pre-compiling mode and a dynamic proxy during running, thereby determining a method run in the codes by using the byte code instrumentation technology). For Java software, a Java agent may be used to modify a class file loaded by a JVM (Java virtual machine) when a Java service is started. Therefore, when the code runs, when the real user actually uses the software, the data of the real user can be obtained, wherein the data is the input data of the method run in the code. Then, the data reporting is performed in step S302, that is, the entry parameter data is reported to the device for operating the method of the present embodiment, and then the method of the present embodiment proceeds to step S303 to store the data according to the identifier, where the identifier is the name of the method for operating the method, and the data is the entry parameter data and is stored in the database. Thus, all the parameter data can be searched through the method name. It should be noted here that, since there are a plurality of actual users and a plurality of operating scenarios, there are a plurality of sets of input parameters corresponding to each method. By recording the real data of the user, the same data as the real user can be used in the subsequent software test, and the problems of test scene omission and the like caused by incomplete data can be solved.
In the reference data of the above embodiment, there are some useless data and sensitive data. Then, when recommending in step S104, the original data pre-stored in the database needs a certain processing before being recommended to the test user. Namely, the method also comprises the following steps before recommendation: and carrying out configuration item screening, classifying or desensitizing operation on the test data, and recommending the operated data as the test data. Wherein the configuration item filter discards data of the specified column, e.g., time stamp data, without using the column data. The classification operation comprises the following steps: the effective value in the data is extracted by using an algorithm such as a change vector. For example: and taking some column data which does not exceed the threshold number as effective values of the data. The desensitization and authentication operations include: the personal information of the user is replaced by test data to avoid data leakage, and the authentication information of the user is processed in batch to avoid the request from being rejected. And the operated data can be recommended to a test user, and the test user can adopt the data to perform test operation.
In the above embodiment of the reference data, further, the result of the method operation may be obtained. The results may then be stored as a correspondence of test data to test results in a database. Therefore, automatic testing of software can be realized, namely, automatic testing can be performed on a test scene according to recommended test data, then a test result is obtained and compared with a test result corresponding to the test data in the database, and a test comparison result is returned. Therefore, a test user does not need to manually test, and then can quickly know the test result according to the comparison result, so that the software test is quickly completed. Therefore, the test scenes can be automatically inquired and recommended under the condition of manual intervention, the test results are played back according to the recommended test data, and the test results are compared automatically, so that the verification of the basic functions after the codes are changed can be completed, manual participation is avoided, and the test efficiency is improved.
In a second aspect, an embodiment of the present application further provides a test data recommendation apparatus, as shown in fig. 4, where the test data recommendation apparatus 10 includes: an obtaining unit 101 configured to obtain a method changed in a change code; a first determining unit 102, configured to determine, according to a correspondence between a prestored method name and an associated method name, a method corresponding to the changed method, and a method affected by a change code, where the method affected by the change code includes the changed method and a method corresponding to the changed method; a second determining unit 103, configured to determine, according to a corresponding relationship between a pre-stored method name and a test scenario, the test scenario corresponding to the method affected by the change code and/or determine, according to a corresponding relationship between a pre-stored method name and test data, the test data corresponding to the method affected by the change code; and the recommending unit 104 is configured to determine the test scenario and/or the test data as test data to recommend the test data.
The test data recommendation apparatus 10 of this embodiment may determine the method of influence according to the change code, and may determine the corresponding test scenario according to the method of influence of the change code because the method of influence of the change code is determined. Therefore, the functional test can be performed on the affected scenes in a targeted manner, the test on all the scenes is avoided, and the problems of long test time and large labor consumption caused by the test on all the functions of the software are avoided. Or the test data can be determined according to the method influenced by the change code, and the recommended test data can be directly adopted for testing, so that the test efficiency is improved.
On the basis of the foregoing device embodiment, as shown in fig. 5, the test data recommendation device 10 further includes a scenario correspondence relationship establishing unit 105: the method comprises the steps of obtaining code coverage rate data of a plurality of scenes, determining methods related to code running tracks under the scenes and code lines running in the methods by performing deep traversal on the code coverage rate data, establishing corresponding relations between method names of the methods related to the code running tracks under the scenes, line numbers of the code lines running in the methods and corresponding scenes, and storing the corresponding relations as the corresponding relations between the method names and test scenes. The scene correspondence relationship establishing unit 105 may establish a scene correspondence relationship, that is, a correspondence relationship between the method name and the test scene, and the correspondence relationship may be used by the second determining unit 103.
On the basis of the foregoing device embodiment, as shown in fig. 5, the test data recommendation device 10 further includes a method correspondence relationship establishing unit 106: the method name storage module is used for reading the code file, obtaining the method name of the method in the code file, calling the method name of the method in the code file and storing the method name as the corresponding relation between the method name and the associated method name. The method correspondence relationship establishing unit 106 may establish a method correspondence relationship, that is, a correspondence relationship between a method name and an associated method name, and the correspondence relationship may be used by the first determining unit 102.
In a further embodiment, the method correspondence establishing unit 106 is further configured to convert the code file into an abstract syntax tree, and obtain a name of a method for calling a method in the code file by analyzing the abstract syntax tree.
On the basis of the foregoing device embodiment, as shown in fig. 5, the test data recommendation device 10 further includes a data correspondence relationship establishing unit 107: the method comprises the steps of determining a method run in a code through a byte code instrumentation technology, and acquiring entry parameter data of the method run in the code; and the method name of the method operated in the code is established and stored as the corresponding relation between the method name and the test data. The data correspondence relationship, that is, the correspondence relationship between the method name and the test data, which can be used by the second determination unit 103, can be established by the data correspondence relationship establishment unit 107.
In a third aspect, corresponding to the test data recommendation method, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the test data recommendation method.
In a fourth aspect, as shown in fig. 6, an embodiment of the present application further provides an electronic device 600, including: a processor 601, a memory 602 and a bus 603, wherein the memory 602 stores machine-readable instructions executable by the processor 601, when the electronic device is operated, the processor 601 and the memory 602 communicate through the bus 603, and the processor 601 executes the machine-readable instructions to perform the steps of the test data recommendation method as described above.
Specifically, the memory 602 and the processor 601 may be general-purpose memory and processor, and are not limited in particular, and the data recommendation method can be executed when the processor 601 runs a computer program stored in the memory 602.
It should be noted that the electronic device 600 may be a cloud server, or may be a user terminal device. When the electronic device 600 is a cloud server, the cloud server may obtain a code file uploaded by the user terminal device (for example, uploaded in a browser manner), and the cloud server processes the code file and returns recommended test data. When the electronic device 600 is a user terminal device, the user terminal device may directly obtain a code file in the current device, implement processing of the code file, and return recommended test data.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to corresponding processes in the method embodiments, and are not described in detail in this application. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and there may be other divisions in actual implementation, and for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk or an optical disk, and various media capable of storing program codes.
Finally, it should be noted that, although the above embodiments have been described in the text and drawings of the present application, the scope of the patent protection of the present application is not limited thereby. All technical solutions which are generated by replacing or modifying the equivalent structure or the equivalent flow according to the contents described in the text and the drawings of the present application, and which are directly or indirectly implemented in other related technical fields, are included in the scope of protection of the present application.

Claims (10)

1. A method for recommending test data, the method comprising the steps of:
obtaining a method of change in the change code;
determining a method corresponding to the changed method and a method influenced by a change code according to the corresponding relation between the prestored method name and the associated method name, wherein the method influenced by the change code comprises the changed method and the method corresponding to the changed method;
determining a test scene corresponding to the method influenced by the change code according to the corresponding relation between the prestored method name and the test scene and/or determining test data corresponding to the method influenced by the change code according to the corresponding relation between the prestored method name and the test data;
and determining the test scene and/or the test data as the data to be tested for recommendation.
2. The test data recommendation method of claim 1, further comprising, prior to said obtaining the method altered in the alteration code, the steps of:
and comparing the two different code files, determining a different code and taking the different code as the change code.
3. The test data recommendation method of claim 1, wherein the correspondence of the pre-stored method name to the associated method name is obtained by:
reading the code file, obtaining the method name of the method in the code file, calling the method name of the method in the code file, and storing the method name and the method name in the corresponding relation.
4. The test data recommendation method of claim 3, wherein the obtaining of the method name of the method in the code file and the calling of the method name of the method in the code file and the storing of the method name as the correspondence with the associated method name comprises the steps of:
and converting the code file into an abstract syntax tree, and analyzing the abstract syntax tree to obtain a method name for calling the method in the code file.
5. The test data recommendation method of claim 1, wherein the correspondence between the pre-stored method name and the test scenario is obtained by:
the method comprises the steps of obtaining code coverage rate data of a plurality of scenes, determining methods related to code running tracks under the scenes and code lines running in the methods by performing deep traversal on the code coverage rate data, establishing corresponding relations between method names of the methods related to the code running tracks under the scenes, line numbers of the code lines running in the methods and the corresponding scenes, and storing the corresponding relations between the method names and test scenes.
6. The test data recommendation method of claim 1, wherein the correspondence between the pre-stored method name and the test data is obtained by:
determining a method run in a code by a byte code instrumentation technology, and acquiring the parameter data of the method run in the code;
and establishing a corresponding relation between the method name of the method operated in the code and the reference data, and storing the corresponding relation as the corresponding relation between the method name and the test data.
7. A test data recommendation apparatus, the apparatus comprising:
an acquisition unit configured to acquire a method changed in the change code;
the first determining unit is used for determining a method corresponding to the changed method and a method influenced by the changed code according to the corresponding relation between the prestored method name and the associated method name, wherein the method influenced by the changed code comprises the changed method and the method corresponding to the changed method;
the second determining unit is used for determining a test scene corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test scene and/or determining test data corresponding to the method influenced by the change code according to the corresponding relation between the pre-stored method name and the test data;
and the recommending unit is used for determining the test scene and/or the test data as the test data to recommend.
8. The test data recommendation apparatus of claim 7, further comprising a scene correspondence relationship establishing unit: the method comprises the steps of obtaining code coverage rate data of a plurality of scenes, determining methods related to code running tracks under the scenes and code lines running in the methods through deep traversal of the code coverage rate data, establishing corresponding relations between method names of the methods related to the code running tracks under the scenes, line numbers of the code lines running in the methods and corresponding scenes, and storing the corresponding relations between the method names and test scenes.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the test data recommendation method according to any one of claims 1 to 6.
10. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the test data recommendation method according to any one of claims 1 to 6.
CN202211670919.2A 2022-12-26 2022-12-26 Test data recommendation method and device, storage medium and electronic equipment Pending CN115658552A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211670919.2A CN115658552A (en) 2022-12-26 2022-12-26 Test data recommendation method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211670919.2A CN115658552A (en) 2022-12-26 2022-12-26 Test data recommendation method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115658552A true CN115658552A (en) 2023-01-31

Family

ID=85022290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211670919.2A Pending CN115658552A (en) 2022-12-26 2022-12-26 Test data recommendation method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115658552A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103019923A (en) * 2011-09-22 2013-04-03 腾讯科技(深圳)有限公司 Method and system of simulated click test
CN105760288A (en) * 2014-12-15 2016-07-13 阿里巴巴集团控股有限公司 Method and device testing rewritten application program
CN107368407A (en) * 2016-05-11 2017-11-21 北京京东尚科信息技术有限公司 Information processing method and device
CN114518877A (en) * 2022-02-16 2022-05-20 平安普惠企业管理有限公司 Data processing method and device and computer storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103019923A (en) * 2011-09-22 2013-04-03 腾讯科技(深圳)有限公司 Method and system of simulated click test
CN105760288A (en) * 2014-12-15 2016-07-13 阿里巴巴集团控股有限公司 Method and device testing rewritten application program
CN107368407A (en) * 2016-05-11 2017-11-21 北京京东尚科信息技术有限公司 Information processing method and device
CN114518877A (en) * 2022-02-16 2022-05-20 平安普惠企业管理有限公司 Data processing method and device and computer storage medium

Similar Documents

Publication Publication Date Title
CN108614707B (en) Static code checking method, device, storage medium and computer equipment
US8010844B2 (en) File mutation method and system using file section information and mutation rules
CN112394942B (en) Distributed software development compiling method and software development platform based on cloud computing
CN111475694A (en) Data processing method, device, terminal and storage medium
CN109801677B (en) Sequencing data automatic analysis method and device and electronic equipment
CN115033894B (en) Software component supply chain safety detection method and device based on knowledge graph
WO2022012327A1 (en) Code analysis method and system, and computing device
CN112860265A (en) Method and device for detecting operation abnormity of source code database
CN115576600A (en) Code change-based difference processing method and device, terminal and storage medium
CN111324510A (en) Log processing method and device and electronic equipment
CN116737535A (en) Interface test method, device, computer equipment and storage medium
CN113031995B (en) Rule updating method and device, storage medium and electronic equipment
CN115757174A (en) Database difference detection method and device
CN115658552A (en) Test data recommendation method and device, storage medium and electronic equipment
CN115292178A (en) Test data searching method, device, storage medium and terminal
CN113419738A (en) Interface document generation method and device and interface management equipment
CN113742208A (en) Software detection method, device, equipment and computer readable storage medium
WO2021104027A1 (en) Code performance testing method, apparatus and device, and storage medium
CN110297651A (en) The update method and device of the common variable of protocol interface
CN113568662B (en) Code change influence range analysis method and system based on calling relation
CN118445214B (en) Code file modification-based method, device, equipment, medium and product for obtaining measurement
CN118363603A (en) Code file analysis method, device, electronic equipment and readable storage medium
CN115344297A (en) Configuration data searching method, storage medium and electronic device
CN113935029A (en) Homology detection method, device and equipment based on import class judgment
CN114780952A (en) Method, system and storage medium for detecting sensitive application calling scene

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20230131