CN110442370B - Test case query method and device - Google Patents

Test case query method and device Download PDF

Info

Publication number
CN110442370B
CN110442370B CN201910697340.7A CN201910697340A CN110442370B CN 110442370 B CN110442370 B CN 110442370B CN 201910697340 A CN201910697340 A CN 201910697340A CN 110442370 B CN110442370 B CN 110442370B
Authority
CN
China
Prior art keywords
code
function
codes
code data
test case
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.)
Active
Application number
CN201910697340.7A
Other languages
Chinese (zh)
Other versions
CN110442370A (en
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201910697340.7A priority Critical patent/CN110442370B/en
Publication of CN110442370A publication Critical patent/CN110442370A/en
Application granted granted Critical
Publication of CN110442370B publication Critical patent/CN110442370B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • G06F16/316Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management

Abstract

The embodiment of the invention provides a test case query method and a device, wherein the method comprises the following steps: acquiring code data to be processed; aiming at codes in the code data, analyzing word meanings, parameter meanings and logic relations among code rows in the codes, and determining a first function according to code analysis results; running codes in the code data and determining a second function according to the code running result; according to the determined first function and second function, respectively determining test cases corresponding to the first function and the second function, and establishing corresponding relations between codes in the code data and the determined test cases; and searching the test cases corresponding to the target query codes according to the established corresponding relation. The embodiment of the invention can enable program developers to discover the affected functions in time, thereby reducing program defects.

Description

Test case query method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a test case query method and apparatus.
Background
In the process of program development, a large number of test cases are required to be used for testing and debugging the program. Where a test case is a set of test inputs, execution conditions, and expected results that are tailored to a particular goal in order to test a program path or verify whether a particular requirement is met.
However, the inventors have found that in implementing the present invention, the prior art has at least the following problems: in the prior art, when a program is developed, as functions in the program are more and more, some functions are modified, other functions which are not quite seemingly relevant are often influenced, so that missing situations occur to the influenced functions before the program is online and during regression testing, namely, a tester is difficult to find the influenced functions, and then the program is defective (bug) is caused.
Disclosure of Invention
The embodiment of the invention aims to provide a test case query method and device, so as to reduce program defects caused by missing of affected functions. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a test case query method, where the method includes:
acquiring code data to be processed, wherein the code data comprises a plurality of lines of codes;
analyzing word meanings, parameter meanings and logic relations among code lines in the code aiming at the code in the code data, and determining a first function according to a code analysis result, wherein the first function is a function realized by the code in the code data;
running codes in the code data, and determining a second function according to a code running result, wherein the second function is a function realized by the codes in the code data, and the first function and the second function are different;
according to the determined first function and the second function, respectively determining test cases corresponding to the first function and the second function, and establishing corresponding relations between codes in the code data and the determined test cases;
and searching the test cases corresponding to the target query codes according to the established corresponding relation.
Optionally, the step of establishing a correspondence between the code in the code data and each determined test case includes:
establishing index information between codes in the code data and the determined test cases, wherein the index information records the corresponding relation between the codes in the code data and the test cases, the name information of the code data and the function name information of the codes in the code data.
Optionally, the step of running the code in the code data and determining the second function according to the code running result includes:
weaving a preset code when the code in the code data runs;
and determining and recording a second function realized when the codes in the code data run through the woven preset codes.
Optionally, the step of determining test cases corresponding to the first function and the second function respectively according to the determined first function and the determined second function, and establishing a correspondence between codes in the code data and the determined test cases includes:
according to the determined first function, determining a test case corresponding to the first function in a preset test case set;
according to the determined second function, determining a test case corresponding to the second function in a preset test case set;
and establishing a corresponding relation between codes in the code data and each test case in the preset test case set.
Optionally, after the correspondence between the codes in the code data and the determined test cases is established, the method further includes:
if the preset test case set contains the test cases which do not establish the corresponding relation with the codes in the code data, a reminding notification is sent, and the reminding notification carries the information of the test cases which do not establish the corresponding relation with the codes in the code data.
Optionally, the step of searching the test case corresponding to the target query code according to the established correspondence includes:
receiving a query instruction, wherein the query instruction carries a target query code;
and searching the test cases corresponding to the target query code according to the corresponding relation between the established code and each test case.
Alternatively to this, the method may comprise,
the method further comprises the steps of:
after the codes in the code data are modified, acquiring modified code fragments in the code data by using a preset hook program;
the step of searching the test case corresponding to the target query code according to the established corresponding relation comprises the following steps:
and searching the test cases corresponding to the modified code fragments in the corresponding relation between the codes and the test cases.
In a second aspect, an embodiment of the present invention provides a test case query device, where the device includes:
the first acquisition module is used for acquiring code data to be processed, wherein the code data comprises a plurality of lines of codes;
the first determining module is used for analyzing word meanings, parameter meanings and logic relations among code rows in the code aiming at the code in the code data, and determining a first function according to a code analysis result, wherein the first function is a function realized by the code in the code data;
the second determining module is used for running codes in the code data and determining a second function according to a code running result, wherein the second function is a function realized by the codes in the code data, and the first function and the second function are different;
the building module is used for respectively determining test cases corresponding to the first function and the second function according to the determined first function and the determined second function, and building a corresponding relation between codes in the code data and the determined test cases;
and the searching module is used for searching the test case corresponding to the target query code according to the established corresponding relation.
Optionally, the establishing module is specifically configured to:
establishing index information between codes in the code data and the determined test cases, wherein the index information records the corresponding relation between the codes in the code data and the test cases, the name information of the code data and the function name information of the codes in the code data.
Optionally, the second determining module includes:
an embedding sub-module for embedding a preset code when the code in the code data runs;
and the first determining submodule is used for determining and recording a second function realized when the code in the code data runs through the woven preset code.
Optionally, the establishing module includes:
the second determining submodule is used for determining a test case corresponding to the first function in a preset test case set according to the determined first function;
the second determining submodule is used for determining a test case corresponding to the second function in a preset test case set according to the determined second function;
the establishing sub-module is used for establishing the corresponding relation between the codes in the code data and each test case in the preset test case set.
Optionally, the apparatus further includes:
and the sending module is used for sending a reminding notification if the test case which does not establish a corresponding relation with the codes in the code data exists in the preset test case set, wherein the reminding notification carries information of the test case which does not establish a corresponding relation with the codes in the code data.
Optionally, the searching module includes:
the receiving sub-module is used for receiving a query instruction, wherein the query instruction carries a target query code;
and the searching sub-module is used for searching the test case corresponding to the target query code according to the established corresponding relation between the code and each test case.
Optionally, the apparatus further includes:
the second acquisition module is used for acquiring the modified code segments in the code data by using a preset hook program after the codes in the code data are modified;
the searching module is specifically configured to:
and searching the test cases corresponding to the modified code fragments in the corresponding relation between the codes and the test cases.
In yet another aspect of the present invention, a computer readable storage medium is provided, where instructions are stored that, when executed on a computer, cause the computer to perform any of the test case query methods described above.
In yet another aspect of the present invention, an embodiment of the present invention further provides a computer program product containing instructions that, when executed on a computer, cause the computer to perform any of the test case query methods described above.
According to the test case query method and device provided by the embodiment of the invention, after the code data to be processed is obtained, the first function and the second function which are used for realizing the codes in the code data are respectively determined based on the analysis result and the operation result by analyzing and operating the codes in the code data, and further the test cases corresponding to the first function and the second function are respectively determined, so that the corresponding relation between the codes in the code data and the test cases is established, a tester can search for the target query test case according to the established corresponding relation, and the corresponding function of the test case is determined, so that the program developer can find the affected function in time, and the program defect is reduced. Of course, it is not necessary for any one product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a flow chart of a test case query method according to an embodiment of the present invention;
FIG. 2 is a flowchart of step S130 in the test case query method according to the embodiment of the present invention;
FIG. 3 is a flowchart of step S140 in the test case query method according to the embodiment of the present invention;
FIG. 4 is a flowchart of step S150 in the test case query method according to the embodiment of the present invention;
FIG. 5 is a schematic diagram of a test case query device according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a second determining module in the test case query device according to the embodiment of the present invention;
FIG. 7 is a schematic structural diagram of a building module in a test case query device according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of another test case query device according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of a device for testing case query according to another embodiment of the present invention;
FIG. 10 is a schematic diagram of a fourth test case query device according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
In the prior art, especially for large programs, the number of test cases or test units is increased, and because program codes are not well correlated with the test cases, after some functions of the program are tested by the test cases and some functions in the program are modified, other seemingly irrelevant functions in the program are often affected, so that the program is defective. Ideally, the modification of the code should trigger and only trigger the execution of the relevant test case, which can save development time and can fully test. Based on the above problems, the embodiment of the invention provides a test case query method and a device.
The following first describes a test case query method provided by the embodiment of the present invention.
The embodiment of the invention provides a test case query method, as shown in fig. 1, which can comprise the following steps:
s110, acquiring code data to be processed.
In the embodiment of the invention, the obtained code data can be the source code of the program, and it can be understood that the code data can contain a plurality of lines of codes, and the program realizes corresponding functions by executing the codes in the code data.
S120, analyzing word meanings, parameter meanings and logic relations among code lines in the codes aiming at the codes in the code data, and determining a first function according to the code analysis result.
In the above code data, different codes may be used to implement different functions, and in order to determine the association relationship between the codes and the different functions, in the embodiment of the present invention, each code in the code data may be analyzed, for example, the word meaning, the parameter meaning, and the logic relationship between the code lines in the code data are analyzed, so as to determine the function that the code in the code data is used to implement, and since the code is not run during the analysis, the above analysis process may be considered as a static analysis process, and the functions determined by the analysis may be referred to as the first function.
In addition, these functions are usually implemented by adjusting parameters in the code, so that different function entries can be corresponding, and after determining the code in the code data is used for implementing the first function, the correspondence between the code and the first function entry can be established.
Illustratively, taking a common search input box as an example, one search input box may generally correspond to the following functional entries: a text input box function entry, a display function entry, a trigger function entry that triggers a back-end search, etc. Therefore, after the code data is obtained, the static analysis can be directly carried out on the codes to determine which codes are used for realizing the text input box function, which codes are used for realizing the display function and which codes are used for realizing the triggering back-end search function, so that the corresponding relation between the codes and the functional entries is established.
As an alternative implementation of the embodiment of the present invention, the first function used for implementation of the code in the code data may be analyzed and determined by static analysis software.
S130, running codes in the code data, and determining a second function according to the code running result.
The above analysis can determine the correspondence between most codes and functions in the code data, but because of the great use of dynamic binding and other technologies in modern programming, the analysis cannot completely analyze all the correspondence, so that the function used for implementation in the code execution process, namely, the second function, can be analyzed and determined by running the codes in the code data. After determining the second function for implementation of the code in the code data, a correspondence between the code and the second function entry may be established.
S140, according to the determined first function and second function, respectively determining the test cases corresponding to the first function and the second function, and establishing the corresponding relation between the codes in the code data and the determined test cases.
In the development of large programs, a large number of test cases or test units are usually required to test different functions of the program, wherein a test case may refer to a set of test inputs, execution conditions and expected results compiled for a specific target, so as to test whether a certain function meets a specific requirement; a test unit may refer to the smallest functional module under test in a program, e.g., a function, a class, a window, a menu, etc.
In the embodiment of the invention, after determining different functions in the code data, since the functions generally need different test cases to be tested, the test cases corresponding to the functions, that is, the test cases corresponding to the first function and the second function, can be easily determined.
According to the foregoing, after determining the first function for implementing the code in the code data, the correspondence between the code and the first function entry may be established, and after determining the second function for implementing the code in the code data, the correspondence between the code and the second function entry may be established.
As an optional implementation manner of the embodiment of the present invention, index information between the code in the code data and each determined test case may be further established, where the index information may record a correspondence between the code in the code data and the test case, for example, a first code line to a fifth code line in the code data correspond to test case 1, a sixth code line to a ninth code line in the code data correspond to test case 2, name information of the code data may also be recorded in the index information, for example, a source code file name of the code data, and function name information of the code in the code data may also be recorded in the index information.
Referring to fig. 1, S150 searches for a test case corresponding to the target query code according to the established correspondence.
After the corresponding relation between the codes and the test cases is established, the test cases corresponding to the target query codes, which are codes of the test cases to be searched, can be searched according to the corresponding relation.
As an alternative implementation manner of the embodiment of the present invention, as shown in fig. 2, the step S130 may include:
s1301, weaving in preset codes when the codes in the code data run.
In the embodiment of the invention, the code can be woven in when the code in the code data runs, namely, the preset code is woven in, and the data which is expected to be obtained can be obtained through the preset code, for example, the function realized by the code in the code data when the code runs is obtained.
S1302, determining and recording a second function realized by the code running time in the code data through the woven preset code.
After the preset codes are woven, the second functions realized by the codes in the code data in the running process can be obtained through the preset codes, namely, the second functions corresponding to the codes in the running process are determined, so that the corresponding relation between the codes and the functions is determined.
As an optional implementation manner of the embodiment of the present invention, the corresponding relationship between the code and the function may also be determined by configuring an AOP (Aspect Oriented Programming, tangent plane oriented programming) interceptor in the code of the code data. Of course, other ways of implementing this feature are within the scope of embodiments of the invention, except as shown in the illustrated examples.
As an optional implementation manner of the embodiment of the invention, after the corresponding relation between the codes and the functions is determined, the index information can be uploaded to a server, and the index information between the codes in the code data and each test case is stored through the server.
As an alternative implementation manner of the embodiment of the present invention, as shown in fig. 3, the step S140 may include:
s1401, according to the determined first function, determining a test case corresponding to the first function in a preset test case set.
In the embodiment of the invention, a test case set can be pre-established, and the test case set can comprise all test cases used in developing a program, so that after the first function is determined, the test cases corresponding to the first function can be rapidly determined from the test case set without searching the test cases corresponding to the functions one by one, and the processing efficiency is improved.
S1402, according to the determined second function, determining a test case corresponding to the second function in a preset test case set.
Similar to the above steps, after the second function is determined, the test case corresponding to the second function may be quickly determined from the test case set.
S1403, establishing a corresponding relation between codes in the code data and each test case in the preset test case set.
Aiming at a preset test case set, the embodiment of the invention can establish the corresponding relation between the codes in the code data and each test case in the preset test case set, thereby facilitating the subsequent search of the test cases corresponding to the target query codes.
As an optional implementation manner of the embodiment of the present invention, on the basis of the above embodiment, the test case query method of the embodiment of the present invention may further include:
if a test case set is preset, and test cases which do not have a corresponding relation with codes in code data exist, namely codes which are not covered by certain test cases, a reminding notification can be sent, wherein the reminding notification carries information of the test cases which do not have a corresponding relation with the codes in the code data, such as identification numbers of the test cases, names of the test cases and the like, so that a program developer can timely learn which test cases are not covered by the codes through the reminding notification, the codes are improved, and the defects of the program are timely eliminated.
As an alternative implementation manner of the embodiment of the present invention, based on the foregoing embodiment, as shown in fig. 4, the step S150 may specifically include:
s1501, a query instruction is received.
Program developers need to determine test cases corresponding to codes in certain code data sometimes, so that a query instruction can be sent to a server storing the corresponding relation between the codes and the test cases, the server can receive the query instruction, and the query instruction carries a target query code for querying the test cases corresponding to the codes in the code data to be queried, namely, the target query test cases. In addition, fewer test cases can be selected as much as possible to test functions in the program, so that time and server operation cost when unnecessary test cases are executed are saved.
It can be understood that, in order to facilitate the server to store and manage the correspondence, the server may store the correspondence between the codes and the test cases in the form of index information, where the index information may record not only the correspondence between the codes in the code data and the test cases, but also name information of the code data and function name information of the codes in the code data.
S1502, according to the corresponding relation between the established codes and the test cases, the test cases corresponding to the target query codes are searched.
After receiving the query instruction, the server can search the test cases corresponding to the target query code according to the corresponding relation between the codes in the established code data and the test cases.
Illustratively, the server may find a test case corresponding to the target query code in the stored index information.
As an optional implementation manner of the embodiment of the invention, after searching for the test case corresponding to the target query code, the server can send the test case to the client used by the program developer, so that the program developer can debug the test case, and the usability of program debugging is improved.
In the process of program development, codes in the code data are often modified, so that in order to obtain test cases corresponding to the modified codes more conveniently, as an optional implementation manner of the embodiment of the invention, after the codes in the code data are modified, the modified code segments in the code data can be obtained by using a preset hook program. The above-mentioned hook program is a commonly used program or function for obtaining information, and a program developer may compile the hook program according to actual needs to obtain the required information, and the application principle of the present invention is not described herein.
The step of searching the test case corresponding to the target query code may specifically be:
and searching the test cases corresponding to the modified code fragments in the corresponding relation between the determined codes and the test cases.
Optionally, because the function name of the code may be recorded in the index information, the embodiment of the present invention may search the corresponding test case of the modified code segment in the corresponding relationship according to the function name of the modified code segment. For example, the function name of the modified code segment is input into the index information storing the corresponding relation between the code in the code data and each test case, so that the test case corresponding to the code can be easily searched, thereby further improving the searching efficiency.
According to the test case query method provided by the embodiment of the invention, after the code data to be processed is obtained, the first function and the second function which are used for realizing the codes in the code data are respectively determined based on the analysis result and the operation result by analyzing and operating the codes in the code data, and further the test cases corresponding to the first function and the second function are respectively determined, so that the corresponding relation between the codes in the code data and each test case is established, a tester can search for the target query test case according to the established corresponding relation, and the corresponding function of the test case is determined, so that the program developer can find the affected function in time, and the program defect is reduced.
Corresponding to the method embodiment, the embodiment of the invention also provides a test case query device, corresponding to the flow shown in fig. 1, as shown in fig. 5, which comprises:
the first acquiring module 301 is configured to acquire code data to be processed, where the code data includes a plurality of lines of codes.
The first determining module 302 is configured to analyze, for the code in the code data, a word meaning, a parameter meaning, and a logic relationship between code lines, and determine, according to a result of the code analysis, a first function, where the first function is a function implemented by the code in the code data.
The second determining module 303 is configured to run the code in the code data, and determine a second function according to the code running result, where the second function is a function implemented by the code in the code data, and the first function and the second function are different.
The establishing module 304 is configured to determine test cases corresponding to the first function and the second function according to the determined first function and the determined second function, and establish a correspondence between codes in the code data and the determined test cases.
The searching module 305 is configured to search the test case corresponding to the target query code according to the established correspondence.
The building module is specifically configured to:
and establishing index information between the codes in the code data and the determined test cases, wherein the index information records the corresponding relation between the codes in the code data and the test cases, the name information of the code data and the function name information of the codes in the code data.
As shown in fig. 6, the second determining module 303 includes:
the weave-in submodule 3031 is used for weaving in preset codes when the codes in the code data run.
The first determining submodule 3032 is configured to determine and record, through the woven preset code, a second function implemented when the code in the code data is run.
As shown in fig. 7, the establishing module 304 includes:
the second determining submodule 3041 is configured to determine, according to the determined first function, a test case corresponding to the first function in a preset test case set.
And a third determining submodule 3042, configured to determine, according to the determined second function, a test case corresponding to the second function in the preset test case set.
The building submodule 3043 is used for building a corresponding relation between codes in the code data and each test case in the preset test case set.
On the basis of the device shown in fig. 5, as shown in fig. 8, the test case query device according to the embodiment of the present invention may further include:
the sending module 401 is configured to send a notification of a reminder if a test case that does not establish a corresponding relationship with a code in the code data exists in the preset test case set, where the notification of the reminder carries information of the test case that does not establish a corresponding relationship with the code in the code data.
On the basis of the apparatus shown in fig. 5, as shown in fig. 9, the above-mentioned searching module 305 includes:
the receiving sub-module 3051 is configured to receive a query instruction, where the query instruction carries a target query code.
And the searching sub-module 3052 is used for searching the test cases corresponding to the target query code according to the established corresponding relation between the code and each test case.
On the basis of the device shown in fig. 5, as shown in fig. 10, the test case query device according to the embodiment of the present invention may further include:
the second obtaining module 601 is configured to obtain, after the code in the code data is modified, a modified code segment in the code data by using a preset hook program.
The above-mentioned searching module may be specifically configured to:
and searching the test cases corresponding to the modified code fragments in the corresponding relation between the determined codes and the test cases.
According to the test case query device provided by the embodiment of the invention, after the code data to be processed is obtained, the first function and the second function which are used for realizing the codes in the code data are respectively determined based on the analysis result and the operation result by analyzing and operating the codes in the code data, and further the test cases corresponding to the first function and the second function are respectively determined, so that the corresponding relation between the codes in the code data and each test case is established, a tester can search for the target query test case according to the established corresponding relation, and the corresponding function of the test case is determined, so that the program developer can find the affected function in time, and the program defect is reduced.
The embodiment of the present invention further provides an electronic device, as shown in fig. 11, including a processor 701, a communication interface 702, a memory 703, and a communication bus 704, where the processor 701, the communication interface 702, and the memory 703 perform communication with each other through the communication bus 704,
a memory 703 for storing a computer program;
the processor 701 is configured to execute the program stored in the memory 703, and implement the following steps:
acquiring code data to be processed, wherein the code data comprises a plurality of lines of codes;
aiming at codes in the code data, analyzing word meanings, parameter meanings and logic relations among code rows in the codes, and determining a first function according to code analysis results, wherein the first function is a function realized by the codes in the code data;
running codes in the code data, determining a second function according to the code running result, wherein the second function is realized by the codes in the code data, and the first function and the second function are different;
according to the determined first function and second function, respectively determining test cases corresponding to the first function and the second function, and establishing corresponding relations between codes in the code data and the determined test cases;
and searching the test cases corresponding to the target query codes according to the established corresponding relation.
According to the electronic equipment provided by the embodiment of the invention, after the code data to be processed is obtained, the first function and the second function which are used for realizing the codes in the code data are respectively determined based on the analysis result and the operation result by analyzing and operating the codes in the code data, and further the test cases corresponding to the first function and the second function are respectively determined, so that the corresponding relation between the codes in the code data and each test case is established, a tester can search the target query test case according to the established corresponding relation, the corresponding function of the test case is determined, and the program developer can find the affected function in time, thereby reducing the program defects.
The communication bus mentioned by the above electronic device may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, or the like. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, where instructions are stored, which when executed on a computer, cause the computer to perform the test case query method of any of the above embodiments.
In yet another embodiment of the present invention, a computer program product containing instructions that, when run on a computer, cause the computer to perform the test case query method of any of the above embodiments is also provided.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (9)

1. A test case query method, the method comprising:
acquiring code data to be processed, wherein the code data comprises a plurality of lines of codes;
analyzing word meanings, parameter meanings and logic relations among code lines in the code aiming at the code in the code data, and determining a first function according to a code analysis result, wherein the first function is a function realized by the code in the code data;
running codes in the code data, and determining a second function according to a code running result, wherein the second function is a function realized by the codes in the code data, and the first function and the second function are different;
according to the determined first function and the second function, respectively determining test cases corresponding to the first function and the second function, and establishing corresponding relations between codes in the code data and the determined test cases;
searching a test case corresponding to the target query code according to the established corresponding relation;
the step of establishing the corresponding relation between the codes in the code data and the determined test cases comprises the following steps:
establishing index information between codes in the code data and the determined test cases, wherein the index information records the corresponding relation between the codes in the code data and the test cases, the name information of the code data and the function name information of the codes in the code data;
the step of running the codes in the code data and determining the second function according to the code running result comprises the following steps:
weaving a preset code when the code in the code data runs;
determining and recording a second function realized when the codes in the code data run through the woven preset codes;
the step of determining test cases corresponding to the first function and the second function respectively according to the determined first function and the determined second function, and establishing a corresponding relation between codes in the code data and the determined test cases, includes:
according to the determined first function, determining a test case corresponding to the first function in a preset test case set;
according to the determined second function, determining a test case corresponding to the second function in a preset test case set;
and establishing a corresponding relation between codes in the code data and each test case in the preset test case set.
2. The method of claim 1, wherein after establishing the correspondence between the codes in the code data and the determined test cases, the method further comprises:
if the preset test case set contains the test cases which do not establish the corresponding relation with the codes in the code data, a reminding notification is sent, and the reminding notification carries the information of the test cases which do not establish the corresponding relation with the codes in the code data.
3. The method of claim 1, wherein the step of searching for the test case corresponding to the target query code according to the established correspondence includes:
receiving a query instruction, wherein the query instruction carries a target query code;
and searching the test cases corresponding to the target query code according to the corresponding relation between the established code and each test case.
4. The method according to claim 1, wherein the method further comprises:
after the codes in the code data are modified, acquiring modified code fragments in the code data by using a preset hook program;
the step of searching the test case corresponding to the target query code according to the established corresponding relation comprises the following steps:
and searching the test cases corresponding to the modified code fragments in the corresponding relation between the codes and the test cases.
5. A test case query device, the device comprising:
the first acquisition module is used for acquiring code data to be processed, wherein the code data comprises a plurality of lines of codes;
the first determining module is used for analyzing word meanings, parameter meanings and logic relations among code rows in the code aiming at the code in the code data, and determining a first function according to a code analysis result, wherein the first function is a function realized by the code in the code data;
the second determining module is used for running codes in the code data and determining a second function according to a code running result, wherein the second function is a function realized by the codes in the code data, and the first function and the second function are different;
the building module is used for respectively determining test cases corresponding to the first function and the second function according to the determined first function and the determined second function, and building a corresponding relation between codes in the code data and the determined test cases;
the searching module is used for searching the test case corresponding to the target query code according to the established corresponding relation;
the building module is specifically configured to:
establishing index information between codes in the code data and the determined test cases, wherein the index information records the corresponding relation between the codes in the code data and the test cases, the name information of the code data and the function name information of the codes in the code data;
the second determining module includes:
an embedding sub-module for embedding a preset code when the code in the code data runs;
the first determining submodule is used for determining and recording a second function realized when the codes in the code data run through the woven preset codes;
the establishing module comprises:
the second determining submodule is used for determining a test case corresponding to the first function in a preset test case set according to the determined first function;
the second determining submodule is used for determining a test case corresponding to the second function in a preset test case set according to the determined second function;
the establishing sub-module is used for establishing the corresponding relation between the codes in the code data and each test case in the preset test case set.
6. The apparatus of claim 5, wherein the apparatus further comprises:
and the sending module is used for sending a reminding notification if the test case which does not establish a corresponding relation with the codes in the code data exists in the preset test case set, wherein the reminding notification carries information of the test case which does not establish a corresponding relation with the codes in the code data.
7. The apparatus of claim 5, wherein the lookup module comprises:
the receiving sub-module is used for receiving a query instruction, wherein the query instruction carries a target query code;
and the searching sub-module is used for searching the test case corresponding to the target query code according to the established corresponding relation between the code and each test case.
8. The apparatus of claim 5, wherein the apparatus further comprises:
the second acquisition module is used for acquiring the modified code segments in the code data by using a preset hook program after the codes in the code data are modified;
the searching module is specifically configured to:
and searching the test cases corresponding to the modified code fragments in the corresponding relation between the codes and the test cases.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
CN201910697340.7A 2019-07-30 2019-07-30 Test case query method and device Active CN110442370B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910697340.7A CN110442370B (en) 2019-07-30 2019-07-30 Test case query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910697340.7A CN110442370B (en) 2019-07-30 2019-07-30 Test case query method and device

Publications (2)

Publication Number Publication Date
CN110442370A CN110442370A (en) 2019-11-12
CN110442370B true CN110442370B (en) 2023-10-27

Family

ID=68432389

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910697340.7A Active CN110442370B (en) 2019-07-30 2019-07-30 Test case query method and device

Country Status (1)

Country Link
CN (1) CN110442370B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111581076A (en) * 2020-03-30 2020-08-25 平安科技(深圳)有限公司 System code testing method and device, computer equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030093716A1 (en) * 2001-11-13 2003-05-15 International Business Machines Corporation Method and apparatus for collecting persistent coverage data across software versions
CN106557413A (en) * 2015-09-25 2017-04-05 伊姆西公司 Based on the method and apparatus that code coverage obtains test case
CN108874661B (en) * 2018-05-07 2020-12-22 未鲲(上海)科技服务有限公司 Test mapping relation library generation method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110442370A (en) 2019-11-12

Similar Documents

Publication Publication Date Title
US9026998B2 (en) Selecting relevant tests to quickly assess code stability
US20170132119A1 (en) Method and device for retrieving test case based on code coverage
CN107766236B (en) Test task automatic management method, device, equipment and storage medium
US10303587B2 (en) System and method for generating regression test suite
US10860464B2 (en) Test selection for application commit
US8397104B2 (en) Creation of test plans
CN107798047B (en) Repeated work order detection method, device, server and medium
CN110879781B (en) Program debugging method, device, electronic equipment and computer readable storage medium
US9116779B2 (en) Test management domain asset discovery and analysis
US20130091490A1 (en) Method to automatically discover whether new code is covered by tests
CN110908888B (en) Server testing method and device
CN111552632B (en) Interface testing method and device
CN111897724A (en) Automatic testing method and device suitable for cloud platform
US10824541B1 (en) System and method for test data fabrication
JP2015011372A (en) Debug support system, method, program, and recording medium
US9563541B2 (en) Software defect detection identifying location of diverging paths
CN110704311B (en) Application program testing method and device, electronic equipment and readable storage medium
US11422917B2 (en) Deriving software application dependency trees for white-box testing
CN110442370B (en) Test case query method and device
US10922217B1 (en) Adaptive regression testing
CN109376285B (en) Data sorting verification method based on json format, electronic device and medium
CN108829590B (en) Software testing method, device and system
CN114355171B (en) Reconfigurable chip performance bottleneck detection platform, detection method and electronic equipment
CN109165127B (en) Problem interface positioning method and device and electronic equipment
KR20190020363A (en) Method and apparatus for analyzing program by associating dynamic analysis with static analysis

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
GR01 Patent grant
GR01 Patent grant