Test method, device, equipment and product

By obtaining interface requirements in the test platform, establishing mapping relationships to write test cases, and using coloring matrices to record code coverage, the problem of insufficient interface coverage in existing technologies is solved, an automated closed loop of the entire process is achieved, and test quality and efficiency are improved.

CN120803951APending Publication Date: 2025-10-17CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511153189.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-18
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

The existing testing platform cannot effectively cover all interfaces, resulting in limited improvement in test quality and inability to form a linkage effect with the overall product development process.

Method used

By obtaining the interface requirements of the target application, establishing a mapping relationship to write a test case set, and using a coloring matrix to record the code lines covered by the test case, the coverage rate is calculated. When the preset threshold is reached, deployment instructions are automatically sent to the deployment platform, forming a fully automated closed loop.

Benefits of technology

The test cases have achieved comprehensive coverage of interfaces, improved test quality, shortened test cycles, increased test efficiency and accuracy, and reduced missed test rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803951A_ABST
    Figure CN120803951A_ABST
Patent Text Reader

Abstract

The invention provides a testing method, device, equipment and product, and relates to the technical field of testing. The method comprises the following steps: acquiring a test case set written according to an interface demand of a target application and an interface which establishes a mapping relationship with the interface demand; in the process of executing each test case in the test case set through the target application, recording a first code line of a code of the target application covered by each test case through the constructed staining matrix; obtaining a first coverage rate of the code according to the first code line and the code of the target application; and under the condition that the first coverage rate exceeds a first preset threshold value, sending a deployment instruction of the target application to a deployment platform. The test case is written according to the interface requirement and the interface establishing the mapping relation with the interface requirement, the rigid requirement problem of the test can be met, a linkage effect is formed with the whole process of product research and development, codes covered by the test case are recorded through the dyeing matrix, the interface which is not covered can be processed, and the test quality is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of testing, in particular to a testing method, device, equipment and product. BACKGROUND

[0002] The existing testing platform only solves the problems of demand function testing, automation testing and performance testing in the product development process from the perspective of testing technology, but its function is relatively single, and it does not form a linkage effect with the overall process of product development, the test cases cannot cover all interfaces, and the test quality cannot be effectively improved. SUMMARY

[0003] The purpose of the present application is to provide a testing method, device, equipment and product, which can solve the problem that the test cases cannot cover all interfaces and cannot effectively improve the test quality in the prior art.

[0004] To achieve the above purpose, the embodiment of the present application provides a testing method, which comprises:

[0005] Obtaining a test case set written according to interface requirements of a target application and interfaces determined through a mapping relationship with the interface requirements;

[0006] In the process of executing each test case in the test case set through the target application, a first code line of the code of the target application covered by each test case is recorded through the constructed coloring matrix;

[0007] According to the first code line and the code of the target application, a first coverage rate of the code is obtained;

[0008] If the first coverage rate exceeds a first preset threshold, a deployment instruction of the target application is sent to a deployment platform.

[0009] Optionally, the method, wherein obtaining a test case set written according to interface requirements of a target application and interfaces determined through a mapping relationship with the interface requirements comprises:

[0010] Obtaining the interface requirements of the target application and the interfaces determined through the mapping relationship;

[0011] Generating a first test case according to the interfaces and the interface requirements;

[0012] Performing code coverage analysis on the first test case to obtain a test case set.

[0013] Optionally, the method, wherein obtaining the interface requirements of the target application and the interfaces determined through the mapping relationship comprises:

[0014] obtaining a file including the interface requirement pushed by a requirement management platform;

[0015] obtaining an interface set by dynamically injecting a first probe code into the target application;

[0016] establishing the mapping relationship between the interface requirement and a first interface in the interface set according to the file and the interface set, in a case where a semantic similarity between the first interface and an interface description in the file is greater than a second preset threshold value;

[0017] determining the first interface as the interface.

[0018] Optionally, the method, wherein the generating a first test case according to the interface and the interface requirement comprises:

[0019] generating an input boundary condition set according to a parameter constraint of the interface;

[0020] defining a test script template by using a template engine to obtain a first test script template;

[0021] filling data in the first test script template according to the input boundary condition set and the interface requirement to generate the first test case.

[0022] Optionally, the method, wherein the generating an input boundary condition set according to a parameter constraint of the interface comprises:

[0023] extracting interface parameter information according to the interface;

[0024] analyzing each parameter in the interface parameter information to obtain the parameter constraint of the parameter;

[0025] generating the input boundary condition set according to the parameter constraint.

[0026] Optionally, the method, wherein the performing code coverage analysis on the first test case to obtain a test case set comprises:

[0027] performing code coverage analysis on the first test case by using a code coverage tool to identify uncovered code;

[0028] generating a second test case according to the uncovered code by using a symbolic execution tool;

[0029] obtaining the test case set according to the first test case and the second test case.

[0030] Optionally, the method, wherein, in the process of executing each test case in the test case set by the target application, the first code line of the code of the target application covered by each test case is recorded by the constructed coloring matrix, comprising:

[0031] In the process of executing each test case in the test case set by the target application, the code execution track of the target application is recorded by the second probe code;

[0032] According to the code execution track and the constructed coloring matrix, the first code line covered by each test case is recorded.

[0033] Optionally, the method, wherein, according to the first code line and the code of the target application, the first coverage of the code is obtained, comprising:

[0034] According to the first code line, an association matrix is obtained;

[0035] According to the association matrix, the second code line not covered is identified by a matrix algorithm blind spot detection algorithm;

[0036] According to the second code line and the code of the target application, the first coverage is obtained.

[0037] To achieve the above object, an embodiment of the present application provides a test method, comprising:

[0038] A first obtaining module is configured to obtain a test case set written according to interface requirements of a target application and interfaces mapped with the interface requirements;

[0039] A first processing module is configured to record, in the process of executing each test case in the test case set by the target application, a first code line of the code of the target application covered by each test case by a constructed coloring matrix;

[0040] A second obtaining module is configured to obtain, according to the first code line and the code of the target application, a first coverage of the code;

[0041] A first sending module is configured to send, in the case that the first coverage exceeds a first preset threshold, a deployment instruction of the target application to a deployment platform.

[0042] To achieve the above object, an embodiment of the present application provides a network device, comprising a transceiver, a processor, a memory and a program or instruction stored on the memory and executable on the processor; wherein the processor implements the test method as described above when executing the program or instruction.

[0043] To achieve the above object, the embodiment of the present application provides a readable storage medium, which stores programs or instructions, wherein the programs or instructions are executed by a processor to realize the steps of the test method.

[0044] To achieve the above object, the embodiment of the present application provides a computer program product, which comprises computer instructions, wherein the computer instructions are executed by a processor to realize the steps of the test method.

[0045] The beneficial effects of the above technical solutions of the present application are as follows:

[0046] In the embodiment of the present application, the test cases written according to the interface needs of the target application and the interfaces establishing the mapping relationship with the interface needs are executed in the target application, the code covered by the test cases is recorded by constructing a coloring matrix, the coverage is obtained, and it is judged whether to deploy the target application according to the coverage. The test cases written according to the interface needs and the interfaces establishing the mapping relationship with the interface needs can meet the urgent needs of the test, form a linkage effect with the overall process of product research and development, record the code covered by the test cases through the coloring matrix, process the interfaces not covered, and effectively improve the test quality. BRIEF DESCRIPTION OF DRAWINGS

[0047] Figure 1 The schematic diagram of the test method described in the embodiment of the present application is shown in the figure.

[0048] Figure 2 The schematic diagram of the test device described in the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0049] To make the technical problems, technical solutions and advantages of the present application clearer, the following will be described in detail with reference to the drawings and specific embodiments.

[0050] It should be understood that the term “one embodiment” or “an embodiment” mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, “in one embodiment” or “in an embodiment” appearing throughout the specification does not necessarily mean the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner.

[0051] In various embodiments of the present application, it should be understood that the size of the serial number of the following processes does not mean the execution order, and the execution order of the processes should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0052] In addition, the terms “system” and “network” are often used interchangeably in this document.

[0053] In the embodiments provided herein, it should be understood that "B corresponding to A" means that B is associated with A and B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B based solely on A; B can also be determined based on A and / or other information.

[0054] For ease of understanding, some contents involved in the embodiments of the present invention are described below:

[0055] like Figure 1 As shown, a testing method according to an embodiment of the present invention includes:

[0056] S10, obtaining a test case set written according to the interface requirements of the target application and an interface mapping relationship established with the interface requirements;

[0057] It should be noted that interface requirements are obtained based on the standardized JSON format of the requirement interface document pushed by the requirement management platform, such as ID (unique identifier), title (title), description (description), etc. Through probe technology, interfaces that establish a mapping relationship with the interface requirements are obtained based on the interface requirements, and test case sets are automatically written based on the interface requirements and interfaces.

[0058] S20, in the process of executing each test case in the test case set through the target application, recording the first code line of the target application code covered by each test case through the constructed coloring matrix;

[0059] It should be noted that during the execution of the test case, a coloring matrix is ​​used to record the code that the test case can cover, thereby identifying the uncovered code. When the risk level of the uncovered code is low, the uncovered code is removed to reduce unimportant influencing factors.

[0060] S30, acquiring a first coverage of the code according to the first code line and the code of the target application;

[0061] It should be noted that the first coverage rate is calculated based on the code that can be covered by the test case and the code of the target application. If uncovered code with a low risk level can be removed, the first coverage rate is increased.

[0062] S40: When the first coverage rate exceeds a first preset threshold, sending a deployment instruction of the target application to a deployment platform;

[0063] It should be noted that when the first coverage exceeds the first preset threshold, a deployment instruction is automatically sent to a deployment platform, thereby forming a demand-test-deployment full-link automatic closed loop. A test report is generated after the test case is executed, and a test report containing key indicators is output:

[0064] Report = <Coverage, Defect Density, Risk Assessment>

[0065] The defect density is calculated as follows:

[0066] Defect Density = (Number of Critical Defects x 1.5 + Number of General Defects) / KLOC (Kilo Lines Of Code, Kilo Lines Of Code)

[0067] When the first coverage is greater than or equal to 95% and the defect density is less than 0.5, i.e., when the first coverage exceeds the first preset threshold, the deployment instruction of the target application is sent to the deployment platform.

[0068] In this embodiment, the test case written according to the interface requirement of the target application and the interface establishing a mapping relationship with the interface requirement is executed in the target application, the code covered by the test case is recorded by constructing a coloring matrix, the coverage is obtained, and it is determined whether to deploy the target application according to the coverage. According to the interface requirement and the interface written test case establishing a mapping relationship with the interface requirement, the test requirement problem can be met, and the whole process of product research and development is linked to form a linkage effect. The code covered by the test case is recorded by the coloring matrix, the interface not covered can be processed, and the test quality is effectively improved.

[0069] Optionally, the method, wherein the step S10 comprises:

[0070] obtaining the interface requirement of the target application and the interface determined through the mapping relationship;

[0071] generating a first test case according to the interface and the interface requirement;

[0072] performing code coverage analysis on the first test case to obtain a test case set.

[0073] In this embodiment, the interface corresponding to the interface requirement is determined according to the mapping relationship, and an input boundary condition set is generated based on the parameter constraint of the interface:

[0074] B i = [(min, max, null, invalid)] x param_type

[0075] Wherein, B iB is a boundary condition set, min is a minimum value, max is a maximum value, null is a null value, invalid is an invalid value, and param_type is a parameter type. i According to the parameter type.

[0076] According to the boundary condition set B i A template engine is used to dynamically generate a pytest (Python test framework) script in a Python test field, and the generated script content is written into a Python file to obtain the first test case. A code coverage tool such as coverage.py is used to perform code coverage analysis on the generated first test case. Uncovered code paths are identified, and test cases are supplemented according to the uncovered code. The supplemented test cases are added to the first test case to obtain the test case set, thereby improving the code coverage.

[0077] Optionally, the method, wherein the interface requirements of the target application and the interfaces determined through the mapping relationship comprise:

[0078] A file including the interface requirements pushed by a requirement management platform is obtained.

[0079] An interface set is obtained by dynamically injecting a first probe code into the target application.

[0080] According to the file and the interface set, the mapping relationship between the interface requirements and a first interface in the interface set is established when the semantic similarity between the first interface and the interface description in the file is greater than a second preset threshold.

[0081] The first interface is determined as the interface.

[0082] In this embodiment, after a JSON format file including the interface requirements is obtained, the first probe code is dynamically injected into the target application to capture all application programming interface (API) endpoints and parameters, and an interface set I is constructed:

[0083] I = [(m i , p i , r i )] (i = 1, 2, 3... n)

[0084] Wherein, m i is a HyperText Transfer Protocol (HTTP) method, p i is an interface path, and r iis the number of parameters, i is the number of interfaces.

[0085] A Java Agent (proxy) is written, a ClassFileTransformer (class file transformer) is registered in the premain (pre-main phase) method, the target class (such as the front-end controller (DispatcherServlet) or the controller class) is modified using the bytecode operation framework (Address State Manipulation, ASM), the probe (i.e. the first probe code) logic is inserted before and after the request processing method, and the request mapping information (such as the uniform resource locator (Uniform Resource Locator, URL), HTTP method) is dynamically captured, so as to construct the interface set I. The mapping relationship between the first interface in the interface set and the interface requirement is determined, and the statistical feature to pre-training language model (TF-IDF-BERT, Term Frequency-Inverse Document Frequency-Bidirectional Encoder Representations from Transformers) algorithm is used to calculate the semantic similarity S(r, I j ) between the interface and the interface description in the file:

[0086]

[0087] wherein r is the first interface, I j is the jth interface requirement, ω is a term in r, TF-IDF(ω) represents the weight of the word ω in the global context, TF-IDF(ω, I j ) represents the TF-IDF weight of ω in the document I j , ||r|| represents the norm of the first interface vector, and ||I j || represents the norm of the interface requirement.

[0088] When S>0.7, the mapping relationship between the interface requirement and the first interface is established, and the first interface for which the mapping relationship is established is determined as the interface.

[0089] Optionally, the method, wherein the first test case is generated according to the interface and the interface requirement, comprises:

[0090] An input boundary condition set is generated according to the parameter constraint of the interface.

[0091] A template engine is used to define a test script template, and a first test script template is obtained.

[0092] According to the input boundary condition set and the interface requirement, data is filled in the first test script template to generate the first test case.

[0093] In this embodiment, the input boundary condition set B is generated according to the parameter constraint of the interface i A template engine is used to dynamically generate a Python pytest script, and the code is as follows:

[0094] @pytest.mark.parametrize("input", B i A parameterized decorator is used to implement parameterized testing, and B i represents a plurality of test input parameter combinations

[0095] deftest_api_{i}(input): / / {i} is a variable identifier, and the first test case with a different number can be generated according to the interface requirement

[0096] response = requests.{m_i}(url = p_i, params = input) / / An HTTP request is sent through the requests library, and {m_i} represents a dynamically inserted request method (GET / POST / PUT, etc.)

[0097] assert response.status_code == 200 / / An assertion response status code is verified for an HTTP 200 response

[0098] assert validate_schema(response.json(), schema_i) / / The validate_schema (schema validation) function is called to check the response data structure

[0099] Intelligent assertion generation is obtained, and the response schema is automatically extracted based on the OpenAPI specification:

[0100]

[0101] Wherein, assertion is an assertion, status_code ∈ {200, 201} indicates a status code verification, and schema_valid indicates a data structure verification.

[0102] The Jinja2 template engine of Python is chosen to generate test scripts. First, install the Jinja2 library, which can be completed by the pip install Jinja2 command. Define the test script template by creating a test_template.j2 file, as follows:

[0103] {%for iin range(num_tests)%}{#

[0104] Parameterized decorator:

[0105] -Dynamically inject test input parameters

[0106] -test_inputs[i] corresponds to the input data set of the ith test case (list / tuple)

[0107] For example: @pytest.mark.parametrize("input", [{"page": 1}, {"page": 2}])#

[0108] @pytest.mark.parametrize("input", {test_inputs[i]})

[0109] {# Define test functions:

[0110] -Dynamically generate function names test_api_0, test_api_1, etc.

[0111] -input parameters come from the parameterized decorator injection#}

[0112] def test_api_{{i}}(input):

[0113] {# Send HTTP requests:

[0114] -Dynamically select request methods (request_methods[i])

[0115] -url parameter dynamically binds the corresponding API endpoint (urls[i])

[0116] -params pass in the current parameterized input

[0117] Example: requests.get(url="https: / / api.com / users", params={"page": 1})#}

[0118] response=requests.{{request_methods[i]}}(url={{urls[i]}}, params=input)

[0119] {# Base assertion: verify HTTP status code is 200 #}

[0120] assert response.status_code == 200

[0121] {# Smart mode verification:

[0122] -response.json() gets the response body

[0123] -validate_schema() verifies the JSON structure against the expected schema

[0124] -schemas[i] comes from the response model defined in the OpenAPI specification

[0125] Example: assert validate_schema(res.json(), UserSchema) #}

[0126] assert validate_schema(response.json(), {{schemas[i]}})

[0127] {%endfor%}

[0128] In the test script template, num_tests represents the number of first test cases, test_inputs is a list of input boundary condition sets B i , request_methods is a list of interface request methods (such as get, post, etc.), urls is a list of interface URLs, and schemas is a list of response patterns. In the above Python code, the test script template is read and filled with data. Fill in the interface request method list m_list, the interface URL list p_list, the response pattern list schema_list, and the input boundary condition set list B_list, and write the generated script content to a Python file, such as test_api.py (application program interface test.py), to obtain the first test case.

[0129] Optionally, the method, wherein the input boundary condition set is generated according to the parameter constraints of the interface, comprising:

[0130] extracting interface parameter information according to the interface;

[0131] analyzing each parameter in the interface parameter information to obtain the parameter constraint of the parameter;

[0132] generating the input boundary condition set according to the parameter constraint.

[0133] In this embodiment, the interface parameters are extracted from the interface document or code corresponding to the interface. In the first example, the OpenAPI specification is used, and the parameter definition of the interface can be obtained by parsing the OpenAPI document, including parameter name, type, whether required, etc., so as to obtain the interface parameter information. The constraint condition of each parameter is analyzed to obtain the parameter constraint. For numerical type parameters, the value range is determined. For string type parameters, length limit, character set and other constraints are considered. The input boundary condition set B is generated according to the parameter constraint. i For numerical type, the boundary condition includes minimum value, maximum value, minimum value minus 1, maximum value plus 1, etc. For example, for user_id, the boundary condition set may be B={1, 9999999999, 0, 10000000000} (assuming that the maximum value of user_id on the business is 9999999999). For string type, the boundary condition includes minimum length string, maximum length string, string not meeting the character set requirement, etc. For example, the boundary condition of password parameter may be B={"aA1!", "aA1!12345678901234567890", "abc", "123", "AAAA", "!!!!"}. All interface parameter boundary conditions are combined to form the input boundary condition set B of the interface. i .

[0134] Optionally, the method, wherein the code coverage analysis of the first test case to obtain the test case set comprises:

[0135] using a code coverage tool to perform code coverage analysis on the first test case to identify uncovered code;

[0136] using a symbolic execution tool to generate a second test case according to the uncovered code;

[0137] obtaining the test case set according to the first test case and the second test case.

[0138] In this embodiment, the first test case is analyzed for code coverage using a code coverage tool, such as coverage.py. The first test case is run and a coverage report is generated, which shows which code blocks were covered and which were not. For example, the test can be run using the command coverage run -m pytest test_api.py and the report can be viewed using the command coverage report. The information about the uncovered code is extracted from the coverage report. For Python code, the uncovered code is typically represented as a range of line numbers. For example, if the coverage report shows that lines 10-15 in module my_module are not covered, then a set of uncovered code blocks, uncovered_blocks, is created. The uncovered code is analyzed using a symbolic execution tool, such as angr. First, the angr library is installed using pip install angr. An example of a simple function is shown below:

[0139] import angr

[0140] import claripy

[0141] # create a symbolic execution project

[0142] project = angr.Project("your_script.py", main_opts={'base_addr': 0}) # replace with actual script path

[0143] # create a symbolic variable (32-bit integer)

[0144] x = claripy.BVS('x', 32) # BVS: BitVector Symbol

[0145] # initialize the program state

[0146] state = project.factory.entry_state(args=['your_script.py', x]) # set symbolic argument

[0147] # create a symbolic execution manager

[0148] simgr = project.factory.simulation_manager(state)

[0149] # Perform symbolic exploration (until all reachable paths are found)

[0150] simgr.explore()

[0151] # Output the solutions for all paths

[0152] for path in simgr.deadended:

[0153] # Get the constraint solution for the symbolic variable x for each path

[0154] solution = path.solver.eval(x, cast_to=int)

[0155] print(f"Path {path} -> Input x = {solution}")

[0156] Thus, the second test cases are obtained. The number of the generated second test cases, i.e., the second test case number = len(new_test_cases), is counted, where new_test_cases is a set of the second test cases generated by the symbolic execution technique. The second test cases are added to the set of the first test cases, and the test case set is generated to improve the code coverage.

[0157] Optionally, the method, wherein the step S20 comprises:

[0158] In the process of executing each test case in the test case set by the target application, the code execution track of the target application is recorded by the second probe code.

[0159] According to the code execution track and the constructed dyeing matrix, the first code line covered by each test case is recorded.

[0160] In this embodiment, in the process of executing each test case in the test case set by the target application, the second probe code is inserted when the Java Virtual Machine (JVM) loads a class to record the code execution track of the target application. The code is as follows:

[0161]

[0162] According to the second probe code, the return value obtained in the process of recording the code execution track is recorded, and a dyeing matrix is constructed according to the return value, so as to record the first code line covered by each test case.

[0163] Optionally, the method, wherein the step S30 comprises:

[0164] According to the first code line, an association matrix is obtained.

[0165] According to the association matrix, the second code line not covered is identified by a matrix algorithm blind spot detection algorithm.

[0166] According to the second code line and the code of the target application, the first coverage rate is obtained.

[0167] In this embodiment, according to the first code line, the association matrix is formed, and the formula is as follows:

[0168]

[0169] Wherein, m represents the total number of test cases, n represents the total number of code lines of the target application, i represents the serial number of the test case, j represents the serial number of the code line, a ij =1 is the first code line, a ij =0 is the second code line. According to the association matrix, the second code line not covered is identified by a matrix algorithm blind spot detection algorithm, and the operation formula is as follows:

[0170]

[0171] Wherein, j represents the serial number of the code line, a ij =0 is the second code line, indicating the code line not covered, and i represents the serial number of the test case.

[0172] Next, the second code line is sorted according to the risk level, and the formula is as follows:

[0173] Risk j =ω1criticality(j)+ω2

[0174] Wherein: Risk j represents the risk value of the second code line of the jth line, ω1=0.6, ω2=0.4, and criticality(j) represents the number of the second code line of the jth line. The code line with low risk level is directly ignored, and the code line with high risk level is tested again to complete the test case, and the test is performed again until the first coverage rate exceeds the first preset threshold, and the deployment instruction of the target application is sent to the deployment platform.

[0175] The chromosome coding of the model definition is optimized by a genetic algorithm to be a binary representation of a test case set, and the fitness function is:

[0176]

[0177] Wherein, alpha is a linear scaling coefficient, beta is an amplitude adjustment coefficient, convergence (X) represents the first coverage, 1+cos (X) represents a periodic adjustment term, alpha=0.7, beta=0.3, and the first coverage is iterated by crossover and mutation until the first coverage exceeds the first preset threshold.

[0178] The first coverage is calculated by a data link tracking technology, specifically, an OpenTelemetry (OpenTelemetry) is used to build a call chain to verify end-to-end coverage, and the formula is as follows:

[0179]

[0180] The first coverage is obtained from the above formula.

[0181] The advantages of the embodiment of the application are:

[0182] 1. Full-process automatic closed loop

[0183] End-to-end automation: from requirement analysis to deployment online, the whole process is automated, manual intervention is reduced, and the traditional test cycle is shortened from 5-7 days to 8 hours or less.

[0184] Intelligent feedback mechanism: through real-time code dyeing, defect tracking and coverage optimization, a closed loop quality improvement is formed, and the missed test rate is less than 0.5% (the industry average is 8-12%).

[0185] 2. High-precision requirement-interface mapping

[0186] Hybrid analysis technology: static AST analysis combined with dynamic probe, interface discovery accuracy ≥95% (traditional method about 70-80%).

[0187] Semantic enhancement algorithm: improved TF-IDF-BERT model realizes accurate association between requirements and interfaces, and the mismatch rate is reduced by 40%.

[0188] 3. Intelligent test case generation

[0189] Multi-modal case generation: fusion of symbolic execution (KLEE), fuzz testing (AFL) and machine learning, boundary case coverage rate improved by 3 times.

[0190] Automatic assertion generation: based on OpenAPI specification, response mode is automatically extracted, and assertion generation efficiency is improved by 90%.

[0191] 4. High performance coverage optimization

[0192] Layered bitmap encoding: using RoaringBitmap compression technology, storage efficiency is improved by 10 times, and the time consumption of million-level code line coverage analysis is less than 50ms.

[0193] Genetic algorithm optimization: multi-objective fitness function (coverage, execution time, risk weight) balances test efficiency and quality, and redundant test is reduced by 35%.

[0194] As Figure 2 shown, to achieve the above purpose, the embodiment of the application provides a test party device, which comprises:

[0195] The first acquisition module 201 is configured to acquire a test case set written according to an interface requirement of a target application and an interface established in a mapping relationship with the interface requirement;

[0196] The first processing module 202 is configured to record a first code line of a code of the target application covered by each test case in the test case set during execution of each test case in the test case set by the target application through a constructed coloring matrix;

[0197] The second acquisition module 203 is configured to acquire a first coverage of the code according to the first code line and the code of the target application;

[0198] The first sending module 204 is configured to send a deployment instruction of the target application to a deployment platform in a case where the first coverage exceeds a first preset threshold.

[0199] Optionally, the device, wherein the first acquisition module 201 comprises:

[0200] The first acquisition unit is configured to acquire the interface requirement of the target application and the interface determined through the mapping relationship;

[0201] The first generation unit is configured to generate a first test case according to the interface and the interface requirement;

[0202] The second acquisition unit is configured to perform code coverage analysis on the first test case to acquire a test case set.

[0203] Optionally, the device, wherein the first acquisition unit comprises:

[0204] The first acquisition component is configured to acquire a file including the interface requirement pushed by a requirement management platform;

[0205] The second acquisition component is configured to acquire an interface set by dynamically injecting a first probe code into the target application;

[0206] The first processing component is configured to, according to the file and the interface set, establish the mapping relationship between the interface requirement and a first interface in the interface set when a semantic similarity between the first interface and an interface description in the file is greater than a second preset threshold.

[0207] The first determining component is configured to determine the first interface as the interface.

[0208] Optionally, the apparatus, wherein the first generating unit comprises:

[0209] The first generating component is configured to generate an input boundary condition set according to a parameter constraint of the interface.

[0210] The third obtaining component is configured to define a test script template by using a template engine, and obtain a first test script template.

[0211] The second generating component is configured to fill data in the first test script template according to the input boundary condition set and the interface requirement, and generate the first test case.

[0212] Optionally, the apparatus, wherein the first generating component comprises:

[0213] The first processing sub-component is configured to extract interface parameter information according to the interface.

[0214] The first obtaining sub-component is configured to analyze each parameter in the interface parameter information, and obtain the parameter constraint of the parameter.

[0215] The first generating sub-component is configured to generate the input boundary condition set according to the parameter constraint.

[0216] Optionally, the apparatus, wherein the second obtaining unit comprises:

[0217] The second processing component is configured to perform code coverage analysis on the first test case by using a code coverage tool, and identify uncovered code.

[0218] The third generating component is configured to generate a second test case according to the uncovered code by using a symbolic execution tool.

[0219] The fourth obtaining component is configured to obtain the test case set according to the first test case and the second test case.

[0220] Optionally, the apparatus, wherein the first processing module 202 comprises:

[0221] The first processing unit is configured to record a code execution track of the target application by the second probe code during execution of each test case in the test case set by the target application.

[0222] The second processing unit is configured to record the first code line covered by each test case according to the code execution track and the constructed dyeing matrix.

[0223] Optionally, the apparatus, wherein the second obtaining module 203 comprises:

[0224] The third obtaining unit is configured to obtain an association matrix according to the first code line.

[0225] The third processing unit is configured to identify the second code line not covered by the matrix algorithm blind spot detection algorithm according to the association matrix.

[0226] The fourth obtaining unit is configured to obtain the first coverage according to the second code line and the code of the target application.

[0227] It should be noted that the above apparatus provided by the embodiments of the present application can realize all the method steps realized by the above method embodiments, and achieve the same technical effects, and thus the same parts and beneficial effects of the method embodiments will not be described in detail herein.

[0228] To achieve the above object, the embodiments of the present application provide a network device, comprising a transceiver, a processor, a memory, and a program or instructions stored on the memory and executable on the processor; wherein the processor executes the program or instructions to realize the test method as described above.

[0229] To achieve the above object, the embodiments of the present application provide a readable storage medium having a program or instructions stored thereon, wherein the program or instructions are executed by a processor to realize the steps in the test method as described above.

[0230] To achieve the above object, the embodiments of the present application provide a computer program product, comprising computer instructions, wherein the computer instructions are executed by a processor to realize the steps in the test method as described above.

[0231] It should be further noted that the terminals described in this specification include but are not limited to smart phones, tablet computers, etc., and many functional components described are referred to as modules, in order to more particularly emphasize the independence of their implementation.

[0232] In the embodiments of the invention, modules can be implemented in software for execution by various types of processors. An identified module of executable code may, for instance, comprise one or more physical or logical blocks of computer instructions. These can be organized as an object, procedure, or function. Nevertheless, the executables of an identified module need not be physically located together, but can comprise disparate instructions stored in different locations which, when joined logically together, comprise the module and achieve the stated purpose for the module.

[0233] Indeed, a module of executable code can be a single instruction, or many instructions, and can even be distributed over several different code segments, among different programs, and across several memory devices. Also, operational data can be identified within the modules and can be

[0234] When the modules can be implemented in software, the software can be stored in one or more of the various types of computer-readable storage media, such as a hard disk, a floppy disk, a read-only memory (ROM), a random access memory (RAM), a zip drive, an external storage drive, an optical disk, an magnetic disk, a magnetic tape, a flash drive, or a solid state drive. Similarly, the modules can be presented to a system or other device of a computer system as a propagation signal, for example, a signal on a carrier wave on a transmission medium (for example, an electromagnetic wave, a sound wave, or an optical wave emulating a carrier wave on a transmission medium).

[0235] The foregoing exemplary embodiments are described with reference made to the drawings which are provided for the purpose of explanation and illustration. They are not intended to limit the scope of the invention. Rather, these exemplary embodiments are described in order to enable others skilled in the art to embody the application. As will be understood by those familiar with the art, the application can be embodied in many different forms and should not be limited to the exemplary embodiments set forth herein. Rather, these exemplary embodiments are provided so that this disclosure will be complete and fully convey the scope of the application to those skilled in the art. In the drawings, the size and relative sizes of components can be exaggerated for clarity. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting. As used herein, the singular articles "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. Unless otherwise indicated, a value range includes the upper and lower limits of the range and any sub-ranges therebetween.

[0236] The above description is that of the preferred embodiments of the application. Various modifications and changes can be made thereto without departing from the spirit and scope of the application, which is to be understood. The scope of the application is indicated only by the subjoined claims.

Claims

1. A testing method, characterized in that: include: Obtain a test case set written according to the interface requirements of the target application and an interface that establishes a mapping relationship with the interface requirements; In a process of executing each test case in the test case set through the target application, recording the first code line of the target application code covered by each test case through the constructed coloring matrix; Obtaining a first coverage of the code according to the first code line and the code of the target application; When the first coverage rate exceeds a first preset threshold, a deployment instruction of the target application is sent to a deployment platform.

2. The method according to claim 1, characterized in that Obtain a set of test cases written based on the interface requirements of the target application and the interface mapping relationship established with the interface requirements, including: Obtaining the interface requirement of the target application and the interface determined by the mapping relationship; Generate a first test case according to the interface and the interface requirement; Perform code coverage analysis on the first test case to obtain a test case set.

3. The method according to claim 2, characterized in that Obtaining the interface requirement of the target application and the interface determined by the mapping relationship includes: Obtaining a file including the interface requirements pushed by the requirements management platform; Acquire an interface set by dynamically injecting a first probe code into the target application; According to the file and the interface set, when the semantic similarity between a first interface in the interface set and the interface description in the file is greater than a second preset threshold, establishing the mapping relationship between the interface requirement and the first interface; The first interface is determined as the interface.

4. The method according to claim 2, characterized in that Generating a first test case according to the interface and the interface requirement includes: generating an input boundary condition set according to parameter constraints of the interface; Using a template engine to define a test script template, and obtaining a first test script template; Fill data in the first test script template according to the input boundary condition set and the interface requirements to generate the first test case.

5. The method according to claim 4, characterized in that Generating an input boundary condition set according to the parameter constraints of the interface includes: Extracting interface parameter information according to the interface; Analyze each parameter in the interface parameter information to obtain the parameter constraint of the parameter; The input boundary condition set is generated according to the parameter constraints.

6. The method according to claim 2, characterized in that The performing code coverage analysis on the first test case to obtain a test case set includes: Performing code coverage analysis on the first test case using a code coverage tool to identify uncovered code; Using a symbolic execution tool to generate a second test case based on the uncovered code; The test case set is obtained according to the first test case and the second test case.

7. The method according to claim 1, characterized in that In a process of executing each test case in the test case set through the target application, recording the first code line of the target application code covered by each test case through the constructed coloring matrix, including: In the process of executing each test case in the test case set through the target application, recording the code execution trajectory of the target application through the second probe code; The first code line covered by each test case is recorded according to the code execution trace and the constructed coloring matrix.

8. The method according to claim 1, characterized in that Obtaining a first coverage of the code according to the first code line and the code of the target application includes: According to the first code line, obtaining an incidence matrix; identifying an uncovered second code line according to the incidence matrix using a matrix algorithm blind spot detection algorithm; The first coverage is obtained according to the second code line and the code of the target application.

9. A testing device, characterized in that: include: A first acquisition module is used to acquire a test case set written according to the interface requirements of the target application and an interface mapping relationship established with the interface requirements; A first processing module is configured to record, through a constructed coloring matrix, a first code line of the target application code covered by each test case in a process of executing each test case in the test case set through the target application; A second acquisition module, configured to acquire a first coverage of the code according to the first code line and the code of the target application; The first sending module is configured to send a deployment instruction of the target application to a deployment platform when the first coverage rate exceeds a first preset threshold.

10. A network device comprising: A transceiver, a processor, a memory, and a program or instruction stored in the memory and executable on the processor; wherein the processor implements the test method according to any one of claims 1 to 8 when executing the program or instruction.

11. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps in the testing method according to any one of claims 1 to 8 are implemented.

12. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the testing method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Method and device for automatically generating unit test case based on preferential iterative feedback

    CN122111872A