IOC-based testing method, device, equipment and storage medium
Through IOC container receiving and splitting code modules, clustering processing and automated detection, the code detection time consumption problem caused by developers not doing a good job in module testing planning is solved, and the code detection automation and efficiency is realized.
Patent Information
- Application Number
- CN202210247535.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-14
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-03-14
AI Technical Summary
The developer did not make good module testing plans, which resulted in the subsequent testing process that the code statements in the code need to be detected one by one, which took a lot of time for the tester.
The code module to be tested is received through the IOC container, split it into multiple code statements, perform clustering processing, detect the number of statements, extract the target code statement collection, determine variable dimensions, form parameter lists and dynamic codes, and send them to the tester for automated detection.
It realizes automated detection of target code statements, reduces the workload and time of testers, and improves testing efficiency.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to an IOC-based testing method, device, equipment and storage medium. Background Art
[0002] The main tools used for front-end unit testing are Mocha, Jasmine, Jest, Karma, Ava, etc. The main way to use these tools is to create corresponding test files for the files to be tested, and then test the test files through configuration and start command execution. When developers do not plan module testing well, the code statements in the code need to be checked one by one during the subsequent testing process, which takes a lot of time for testers. Summary of the invention
[0003] The main purpose of the present invention is to provide an IOC-based testing method, device, equipment and storage medium, which aims to solve the problem that when developers do not make a good plan for module testing, the code statements in the code need to be checked one by one during the subsequent testing process, which takes a lot of time for testers.
[0004] The present invention provides a testing method based on IOC, comprising:
[0005] Receive the code module to be tested through the IOC container;
[0006] Splitting the code module into a plurality of code statements;
[0007] Clustering the code statements to obtain sets of code statements in multiple categories;
[0008] Detecting whether the number of statements in the code statement set exceeds a preset number;
[0009] Recording a code statement set in which the number of statements exceeds a preset number as a target code statement set;
[0010] Determining a variable dimension of each code statement according to the target code statement set;
[0011] Extract any one target code statement in the target code statement set, and set the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement, and obtain the parameters of each target code statement in the target code statement set corresponding to the variable dimension, and establish a parameter list;
[0012] Sending the dynamic code to a tester;
[0013] Receiving a first test case uploaded by the tester based on the dynamic code;
[0014] The variables in the dynamic code are replaced in sequence by the parameters in the parameter list, and the test is performed based on the first test case to obtain the first test result of each target code statement.
[0015] Furthermore, after the step of detecting whether the number of statements in the code statement set exceeds a preset number, the step further includes:
[0016] Recording a code statement set whose number of statements does not exceed a preset number as a temporary code statement set, and sending it to a tester;
[0017] Receiving second test cases uploaded by the tester based on each code statement in the temporary code statement set;
[0018] Testing is performed based on the second test case to obtain second test results for each code statement in the temporary code statement set.
[0019] Furthermore, the step of clustering the code statements to obtain a plurality of categories of code statement sets includes:
[0020] Detecting the grammar of each of the code statements through a preset grammar analyzer to obtain a plurality of sentence grammars of different categories;
[0021] The code statements are clustered according to the grammar of each sentence to obtain code statement sets of multiple categories.
[0022] Furthermore, the step of extracting any one target code statement from the target code statement set and setting the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement includes:
[0023] Determining a target field in the target code statement according to the variable dimension;
[0024] The target field is converted into variables corresponding to each dimension to obtain a dynamic code statement.
[0025] Furthermore, after the step of replacing the variables in the dynamic code in sequence with the parameters in the parameter list and testing based on the first test case to obtain the first test result of each target code statement, the step further includes:
[0026] Determining whether the first test result is consistent with a preset result;
[0027] If so, the dynamic code and the parameter list are removed.
[0028] Furthermore, before the step of sending the dynamic code to the tester, the method further includes:
[0029] Extract parameters from the parameter list to assign values to the dynamic code to obtain a test code statement;
[0030] Searching the target code statement set to see whether there is a target code statement identical to the test code statement;
[0031] If so, it is determined that the step of sending the dynamic code to the tester is satisfied.
[0032] Furthermore, the step of splitting the code module into multiple code statements includes:
[0033] Pre-splitting the code module to obtain temporary code statements;
[0034] Acquire the coupling relationship between the temporary code statements;
[0035] The IOC container is injected into the temporary code statement based on the coupling relationship to obtain a single code statement after decoupling.
[0036] The present invention also provides a test device based on IOC, comprising:
[0037] A code receiving module is used to receive the code module to be tested through the IOC container;
[0038] A splitting module, used for splitting the code module into multiple code statements;
[0039] A clustering module, used for clustering the code statements to obtain a plurality of categories of code statement sets;
[0040] A detection module, used to detect whether the number of statements in the code statement set exceeds a preset number;
[0041] A marking module, used for marking a code statement set whose number of statements exceeds a preset number as a target code statement set;
[0042] A determination module, configured to determine a variable dimension of each code statement according to the target code statement set;
[0043] An extraction module is used to extract any one target code statement in the target code statement set, and set the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement, and obtain the parameters of each target code statement in the target code statement set corresponding to the variable dimension, and establish a parameter list;
[0044] A sending module, used to send the dynamic code to a tester;
[0045] A test case receiving module, used for receiving a first test case uploaded by the tester based on the dynamic code;
[0046] The test module is used to replace the variables in the dynamic code in sequence with the parameters in the parameter list, and to perform a test based on the first test case to obtain a first test result for each target code statement.
[0047] The present invention also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
[0048] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods are implemented.
[0049] The beneficial effects of the present invention are as follows: the corresponding code modules are obtained through the IOC container, and clustered, and then a target code statement set is extracted therefrom, and a variable dimension is determined, and the variable dimension is formed into a parameter list and corresponding dynamic code. Subsequently, only the dynamic code needs to be replaced by the data on the parameter list, and the target code statements in the target code statement set need to be templated. Then, the tester can use relevant tools to automatically restore the parameter list and the dynamic code into the corresponding target code statements for detection, thereby realizing automatic detection of the target code statements. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a flowchart of an IOC-based testing method according to an embodiment of the present invention;
[0051] Figure 2 is a schematic block diagram of the structure of an IOC-based testing device according to an embodiment of the present invention;
[0052] Figure 3 A schematic block diagram of the structure of a computer device according to an embodiment of the present application.
[0053] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.
[0056] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone.
[0057] In addition, in the present invention, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0058] Reference Figure 1 The present invention proposes a testing method based on IOC, comprising:
[0059] S1: Receive the code module to be tested through the IOC container;
[0060] S2: splitting the code module into multiple code statements;
[0061] S3: clustering the code statements to obtain a set of code statements in multiple categories;
[0062] S4: Detect whether the number of statements in the code statement set exceeds a preset number;
[0063] S5: Recording a code statement set whose number of statements exceeds a preset number as a target code statement set;
[0064] S6: determining a variable dimension of each code statement according to the target code statement set;
[0065] S7: extract any one target code statement in the target code statement set, and set the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement, and obtain the parameters of each target code statement in the target code statement set corresponding to the variable dimension, and establish a parameter list;
[0066] S8: Send the dynamic code to the tester;
[0067] S9: receiving a first test case uploaded by the tester based on the dynamic code;
[0068] S10: replacing the variables in the dynamic code in sequence with the parameters in the parameter list, and performing a test based on the first test case to obtain a first test result for each target code statement.
[0069] As described in step S1 above, the code module to be tested is received through the IOC container. Among them, the IOC (Inversion of Control) container is a design principle in object-oriented programming, which can be used to reduce the coupling between computer codes. Therefore, the code module is received through the IOC container to decouple the code module later. The code module is a functional module in the app, and during the test process, it is generally tested for some functions of the app.
[0070] As described in step S2 above, the code module is split into multiple code statements, wherein the splitting method is based on the IOC container, and the specific splitting method will be described in detail later, which will not be repeated here.
[0071] As described in step S3 above, each of the code statements is clustered to obtain a set of code statements of multiple categories. The clustering method can be implemented by any clustering algorithm in the prior art, such as the K-MEANS clustering algorithm or the mean shift clustering algorithm. In the present application, it is preferred to use the syntax of identifying each code statement, and cluster each code statement based on the syntax. The method of identifying the syntax will be described in detail later and will not be repeated here.
[0072] As described in the above steps S4-S5, it is detected whether the number of statements in the code statement set exceeds the preset number. Since it is more convenient and efficient to use manual methods to detect some code statement sets with less than the preset number of statements, manual testing is used to test this part of the code statement set. This application only targets the code statement set with a redundant preset number, i.e., the target code statement set.
[0073] As described in step S6 above, the variable dimension of each code statement is determined according to the target code statement set. Since the syntax in the target code statement set is the same, it is only necessary to base on the different fields in the statement, and record the field as the variable dimension.
[0074] As described in step S7 above, extract any one of the target code statements in the target code statement set, set the variable dimension corresponding to the target code statement as a variable, obtain a dynamic code statement, and obtain the parameters of the variable dimension corresponding to each target code statement in the target code statement set, and establish a parameter list. Among them, since the syntax of each target code statement in the target code statement set is the same, after determining the variable dimension, any one of the target code statements can be obtained, and the parameters of the variable dimension corresponding to the target code statement can be set as a variable, thereby obtaining a dynamic code statement, wherein the variable has several attributes, specifically including a variable description, a variable data type, and a variable initial value. Then obtain the parameters of the variable dimension corresponding to each target code statement, and establish a parameter list for subsequent replacement.
[0075] As described in the above step S8, the dynamic code is sent to the tester, wherein the sending method can be to send it to the tester's terminal through wired or wireless transmission, or it can be displayed on a display interface and presented to the tester in the form of graphics and text, so as to achieve the purpose of sending it to the tester.
[0076] As described in step S9 above, the first test case uploaded by the tester based on the dynamic code is received, wherein the method for code detection has not yet been designed, therefore, the dynamic code needs to be sent to the tester, and the tester writes a corresponding test case based on the dynamic code. The test case is a program for testing the dynamic code, including the items to be detected, the test software involved, etc.
[0077] As described in step S10 above, the variables in the dynamic code are replaced in sequence by the parameters in the parameter list, and the test is performed based on the first test case to obtain the first test result of each target code statement. The replacement method is to replace the variables once, thereby realizing the restoration of the target code statements one by one, and realizing the automatic detection of the target code statements.
[0078] In one embodiment, after the step S4 of detecting whether the number of statements in the code statement set exceeds a preset number, the method further includes:
[0079] S501: Recording a code statement set whose number of statements does not exceed a preset number as a temporary code statement set, and sending it to a tester;
[0080] S502: receiving second test cases uploaded by the tester based on each code statement in the temporary code statement set;
[0081] S503: Perform testing based on the second test case to obtain a second test result for each code statement in the temporary code statement set.
[0082] As described in the above steps S501-S503, the detection of recording a code statement set whose number of statements does not exceed a preset number as a temporary code statement set is implemented. Since the number of statements in the temporary code statement set is insufficient, if the above method is used for testing, it will consume more resources. Therefore, for this part, the code statements are directly sent to the tester, and the tester uploads a second test case. Subsequently, each code statement in the temporary code statement set is detected based on the second test case.
[0083] In one embodiment, the step S3 of clustering the code statements to obtain a plurality of categories of code statement sets includes:
[0084] S301: Detecting the grammar of each of the code statements through a preset grammar analyzer to obtain a plurality of sentence grammars of different categories;
[0085] S302: Clustering each code statement according to each sentence grammar to obtain a plurality of categories of code statement sets.
[0086] As described in the above steps S301-S302, clustering of each code statement is achieved. That is, the syntax of each code statement is detected by a syntax analyzer, wherein the syntax analyzer is an existing syntax analyzer. In a specific embodiment, the present application can use an ANTLR (Another Tool for Language Recognition) syntax analyzer (ANTLR refers to an open source syntax analyzer that can automatically generate a syntax tree based on input and display it visually. It provides a framework for automatically constructing a recognizer, a compiler, and an interpreter (translator) of a custom language through a syntax description for languages including Java, C++, and C#). It is actually a compiler that can obtain the part of speech of each field in the code statement, thereby obtaining the syntax of the entire code statement. Here, different types of syntax can be annotated by preset parameters, and then the code statements corresponding to the same syntax are clustered according to the syntax, that is, the code statements annotated the same are clustered, thereby obtaining a set of code statements of multiple categories.
[0087] In one embodiment, the step S7 of extracting any one target code statement in the target code statement set and setting the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement includes:
[0088] S701: Determine a target field in the target code statement according to the variable dimension;
[0089] S702: Convert the target field into variables corresponding to each dimension to obtain a dynamic code statement.
[0090] As described in the above steps S701-S702, the acquisition of dynamic code statements is realized, and the corresponding target field in the target code statement is determined according to the variable dimension, that is, the grammatical dimension of each field in the target code statement can be obtained through the syntax analyzer, and then compared with the variable dimension, and the field corresponding to the dimension with the same dimension as the variable dimension is regarded as the target field, and the target field is converted into a variable to obtain a dynamic code statement. Among them, the dynamic code statement means that the statement can be expanded, and the expansion is achieved by replacing the variables in the dynamic code statement with specific parameters. The variable has several attributes, which specifically include variable description, variable data type and variable initial value. The several attributes are obtained according to the attributes of the information of the data set, that is, the attribute information corresponding to each data in the information of the data set, including the characteristics of the first data, and the dimension information of the change, etc.
[0091] In one embodiment, after the step S10 of replacing the variables in the dynamic code in sequence with the parameters in the parameter list and testing based on the first test case to obtain the first test result of each target code statement, the method further includes:
[0092] S1101: Determine whether the first test result is consistent with a preset result;
[0093] S1102: If yes, remove the dynamic code and the parameter list.
[0094] As described in the above steps S1101-S1102, the data is updated to avoid the dynamic code and parameter list from continuously occupying the space in the IOC container. Therefore, when it is detected that the first test result matches the preset result, the dynamic code and parameter list are directly moved out to avoid continuously occupying the space in the IOC container, so that the IOC container can continue to work efficiently.
[0095] In one embodiment, before the step S8 of sending the dynamic code to the tester, the method further includes:
[0096] S701: extracting parameters from the parameter list and assigning values to the dynamic code to obtain a test code statement;
[0097] S702: Searching the target code statement set to see whether there is a target code statement that is the same as the test code statement;
[0098] S703: If yes, it is determined that the step of sending the dynamic code to the tester is satisfied.
[0099] As described in the above steps S701-S703, the detection of dynamic code is realized, specifically, the parameters in the parameter list are extracted to assign values to the dynamic code, a test code statement is obtained, and then compared with the target code statement in the target code statement set. When there is a target code statement, it can be considered that it meets the test requirements, and then sent to the tester, and the first test case uploaded by the tester is received. It should be noted that in order to improve the accuracy of the detection, multiple parameters can be selected for assignment and detected one by one.
[0100] In one embodiment, the step S2 of splitting the code module into multiple code statements includes:
[0101] S201: pre-splitting the code module to obtain temporary code statements;
[0102] S202: Acquire the coupling relationship between the temporary code statements;
[0103] S203: Injecting the IOC container into the temporary code statement based on the coupling relationship to obtain a single code statement after decoupling.
[0104] As described in the above steps S201-S203, the decoding of the code statements in the code module is realized. Among them, the code module is pre-split to obtain temporary code statements. The splitting method is to split based on the period in the code statement to obtain the temporary code statement. The coupling relationship can be directly obtained from the code module, and then the coupling relationship is input into the IOC container. By establishing the connection between the middleware and each code statement, the coupling between each code statement is reduced to achieve the acquisition of a single code statement after decoupling.
[0105] The beneficial effects of the present invention are as follows: the corresponding code modules are obtained through the IOC container, and clustered, and then a target code statement set is extracted therefrom, and a variable dimension is determined, and the variable dimension is formed into a parameter list and corresponding dynamic code. Subsequently, only the dynamic code needs to be replaced by the data on the parameter list, and the target code statements in the target code statement set need to be templated. Then, the tester can use relevant tools to automatically restore the parameter list and the dynamic code into the corresponding target code statements for detection, thereby realizing automatic detection of the target code statements.
[0106] Reference Figure 2 The present invention also provides a test device based on IOC, comprising:
[0107] A code receiving module 10 is used to receive a code module to be tested through an IOC container;
[0108] A splitting module 20, used for splitting the code module into multiple code statements;
[0109] A clustering module 30, configured to cluster the code statements to obtain a plurality of code statement sets;
[0110] A detection module 40, configured to detect whether the number of statements in the code statement set exceeds a preset number;
[0111] A marking module 50, configured to mark a code statement set whose number of statements exceeds a preset number as a target code statement set;
[0112] A determination module 60, configured to determine a variable dimension of each code statement according to the target code statement set;
[0113] The extraction module 70 is used to extract any one target code statement in the target code statement set, and set the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement, and obtain the parameters of each target code statement in the target code statement set corresponding to the variable dimension, and establish a parameter list;
[0114] A sending module 80, used to send the dynamic code to a tester;
[0115] A test case receiving module 90, configured to receive a first test case uploaded by the tester based on the dynamic code;
[0116] The test module 100 is used to replace the variables in the dynamic code in sequence with the parameters in the parameter list, and to perform a test based on the first test case to obtain a first test result for each target code statement.
[0117] Reference Figure 3 In the embodiment of the present application, a computer device is also provided. The computer device may be a server, and its internal structure may be as follows: Figure 3As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store various code statements, etc. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the IOC-based test method described in any of the above embodiments can be implemented.
[0118] Those skilled in the art will understand that Figure 3 The structure shown in is merely a block diagram of a portion of the structure related to the present application solution and does not constitute a limitation on the computer device to which the present application solution is applied.
[0119] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the IOC-based testing method described in any of the above embodiments can be implemented.
[0120] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0121] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.
[0122] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0123] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0124] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of the claims of the present invention.
Claims
1. A testing method based on IOC, characterized in that: include: Receive the code module to be tested through the IOC container; Splitting the code module into a plurality of code statements; Clustering the code statements to obtain sets of code statements in multiple categories; Detecting whether the number of statements in the code statement set exceeds a preset number; Recording a code statement set in which the number of statements exceeds a preset number as a target code statement set; Determining a variable dimension of each code statement according to the target code statement set, wherein the syntax in the target code statement set is the same, and different fields in the statement are recorded as variable dimensions; Extract any one target code statement in the target code statement set, and set the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement, and obtain the parameters of each target code statement in the target code statement set corresponding to the variable dimension, and establish a parameter list; Sending the dynamic code to a tester; Receiving a first test case uploaded by the tester based on the dynamic code; The variables in the dynamic code are replaced in sequence by the parameters in the parameter list, and the test is performed based on the first test case to obtain a first test result for each target code statement; The step of extracting any one target code statement from the target code statement set and setting the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement includes: Determining a target field in the target code statement according to the variable dimension; Convert the target field into variables corresponding to each dimension to obtain a dynamic code statement; The step of splitting the code module into multiple code statements includes: Pre-splitting the code module to obtain temporary code statements; Acquire the coupling relationship between the temporary code statements; The IOC container is injected into the temporary code statement based on the coupling relationship to obtain a single code statement after decoupling.
2. The IOC-based testing method according to claim 1, characterized in that: After the step of detecting whether the number of statements in the code statement set exceeds a preset number, the method further includes: Recording a code statement set whose number of statements does not exceed a preset number as a temporary code statement set, and sending it to a tester; Receiving second test cases uploaded by the tester based on each code statement in the temporary code statement set; Testing is performed based on the second test case to obtain second test results for each code statement in the temporary code statement set.
3. The IOC-based testing method according to claim 2, characterized in that: The step of clustering the code statements to obtain a set of code statements of multiple categories includes: Detecting the grammar of each of the code statements through a preset grammar analyzer to obtain a plurality of sentence grammars of different categories; The code statements are clustered according to the grammar of each sentence to obtain code statement sets of multiple categories.
4. The IOC-based testing method according to claim 1, characterized in that: After the step of replacing the variables in the dynamic code in sequence with the parameters in the parameter list and testing based on the first test case to obtain the first test result of each target code statement, the method further includes: Determining whether the first test result is consistent with a preset result; If so, the dynamic code and the parameter list are removed.
5. The IOC-based testing method according to claim 1, characterized in that: Before the step of sending the dynamic code to the tester, the method further includes: Extract parameters from the parameter list to assign values to the dynamic code to obtain a test code statement; Searching the target code statement set to see whether there is a target code statement identical to the test code statement; If so, it is determined that the step of sending the dynamic code to the tester is satisfied.
6. A test device based on IOC, used to implement the method described in any one of claims 1 to 5, characterized in that: include: A code receiving module is used to receive the code module to be tested through the IOC container; A splitting module, used for splitting the code module into multiple code statements; A clustering module, used for clustering the code statements to obtain a plurality of categories of code statement sets; A detection module, used to detect whether the number of statements in the code statement set exceeds a preset number; A marking module, used for marking a code statement set whose number of statements exceeds a preset number as a target code statement set; A determination module, configured to determine a variable dimension of each code statement according to the target code statement set; An extraction module is used to extract any one target code statement in the target code statement set, and set the variable dimension corresponding to the target code statement as a variable to obtain a dynamic code statement, and obtain the parameters of each target code statement in the target code statement set corresponding to the variable dimension, and establish a parameter list; A sending module, used to send the dynamic code to a tester; A test case receiving module, used for receiving a first test case uploaded by the tester based on the dynamic code; The test module is used to replace the variables in the dynamic code in sequence with the parameters in the parameter list, and to perform a test based on the first test case to obtain a first test result for each target code statement.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Generating executable test automation code automatically according to a test case
US20200019492A1
Methods and apparatus for self-supervised software defect detection
US20210081310A1