Interface test case generation method and device, equipment and storage medium

By generating interface test cases, the method automates the addition of SOMEIP interface test code, solving the inefficiency and error problems caused by manually adding test code, and achieving efficient interface testing.

CN116610589BActive Publication Date: 2025-12-19HUIZHOU DESAY SV AUTOMOTIVE
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310758220.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-26
Publication Date
2025-12-19
Estimated Expiration
2043-06-26

AI Technical Summary

Technical Problem

In existing technologies, testing SOMEIP interfaces requires manually adding test code, which leads to low testing efficiency and a high risk of errors.

Method used

By obtaining the target communication matrix table of the communication interface, traversing the interface parameters, querying the target structure in the code file, and using a preset script to add preset test code at the location of the target structure, interface test cases are generated.

Benefits of technology

It reduces the error rate of manually adding test code, improves testing efficiency, and saves manpower.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116610589B_ABST
    Figure CN116610589B_ABST
Patent Text Reader

Abstract

The application provides a method, device and equipment for generating an interface test case and a storage medium. The method comprises the following steps: obtaining a target communication matrix table of a communication interface, the communication interface comprising a server interface and a client interface; traversing an interface parameter of the target communication matrix table, and querying a target structure corresponding to the interface parameter in a code file; adding a preset test code corresponding to the communication interface at a code position of the target structure by using a preset script, and generating an interface test case. When testing the Someip interface, the script is used to query a function position corresponding to the software code according to the correspondence between the matrix table and the software code, and the SOMEIP interface calling test code is automatically added, so that the error rate is reduced, the test efficiency is improved, and manpower is greatly saved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of interface testing, and in particular relates to a method and device for generating an interface test case, an apparatus and a storage medium. BACKGROUND

[0002] With the rapid development of intelligent driving technology, intelligent driving scenarios are increasingly rich, and the communication interaction between vehicle controllers is also more complex. SOMEIP (Scalable service-Oriented Middleware over IP) as the core communication protocol in the current automotive industry, its communication application has become increasingly common. To ensure vehicle driving safety, it is very important to test the SOMEIP communication interface.

[0003] Currently, when testing the SOMEIP communication interface, the interface sending service or the interface receiving service needs to be called in each module of the microcontroller unit (MCU) and the system-on-a-chip (SOC), so it is necessary to add test codes such as interface corresponding relationship and data structure body assignment. However, the current test code addition for SOMEIP interface testing needs to be added manually by the user, which has the problems of long test time and easy errors in manual test code addition, resulting in low SOMEIP interface testing efficiency. SUMMARY

[0004] To solve the above technical problems, the present application provides a method and device for generating an interface test case, an apparatus and a storage medium.

[0005] In a first aspect, the present application provides a method for generating an interface test case, applied to a computer device, the method comprising:

[0006] obtaining a target communication matrix table of a communication interface, the communication interface comprising a server interface and a client interface;

[0007] traversing an interface parameter of the target communication matrix table, and querying a target structure corresponding to the interface parameter in a code file;

[0008] adding a preset test code corresponding to the communication interface at a code position of the target structure by using a preset script, to generate an interface test case.

[0009] In some implementations of the first aspect, obtaining the target communication interface of the target communication matrix table comprises:

[0010] obtaining a first communication matrix table of the server interface and a second communication matrix table of the client interface;

[0011] The first communication matrix table and the second communication matrix table are processed in format to generate a target communication matrix table with the same data format.

[0012] In some implementations of the first aspect, the interface parameters include first interface parameters corresponding to the server interfaces and second interface parameters corresponding to the client interfaces, the target structure bodies corresponding to the interface parameters in the code file are queried by traversing all the interface parameters of the target communication matrix table, and the target structure bodies include:

[0013] The first code file corresponding to the server interfaces and the second code file corresponding to the client interfaces are determined based on the flag bit of the code file.

[0014] The first target structure bodies corresponding to the first interface parameters in the first code file are queried by traversing the first interface parameters in the target communication matrix.

[0015] The second target structure bodies corresponding to the second interface parameters in the second code file are queried by traversing the second interface parameters in the target communication matrix.

[0016] In some implementations of the first aspect, the first target structure bodies corresponding to the first interface parameters in the first code file are queried by traversing the first interface parameters in the target communication matrix, and the method includes:

[0017] The first code sub-file with the same first sub-parameter as the first interface parameter in the first code file is determined by performing parameter passing processing on the first sub-parameter and the second sub-parameter in the first interface parameter.

[0018] The first target structure body corresponding to the second sub-parameter is queried in the first code sub-file.

[0019] In some implementations of the first aspect, the second target structure bodies corresponding to the second interface parameters in the second code file are queried by traversing the second interface parameters in the target communication matrix, and the method includes:

[0020] The second code sub-file with the same third sub-parameter as the third sub-parameter in the second code file is determined by performing parameter passing processing on the third sub-parameter and the fourth sub-parameter in the second interface parameter.

[0021] The second target structure body corresponding to the fourth sub-parameter is queried in the second code sub-file.

[0022] In some implementations of the first aspect, the preset test code corresponding to the communication interface is added to the code position of the target structure body by using a preset script to generate an interface test case, and the method includes:

[0023] For each target structure body, the preset test code corresponding to the communication interface is added to the code position of the target structure body by using a preset code adding function.

[0024] The consistency of the code parameters of the preset test code and the interface parameters of the communication matrix table is verified by using a preset logic script.

[0025] If the code parameters are consistent with the interface parameters, it is determined that the interface test case is successfully generated.

[0026] In some implementations of the first aspect, the consistency of the code parameters of the preset test code and the interface parameters of the communication matrix table is verified by using a preset logic script, including:

[0027] The preset logic script is used to query a keyword function in the code parameters, and it is determined whether a preset keyword corresponding to the keyword function and the interface parameters are in the same code position.

[0028] If the preset keyword and the interface parameters are in the same code position, it is determined that the code parameters are consistent with the interface parameters.

[0029] In the second aspect, the application further provides an interface test case generation device, applied to a computer device, and the device includes:

[0030] The acquisition module is configured to acquire a target communication matrix table of a communication interface, the communication interface including a server interface and a client interface.

[0031] The query module is configured to traverse interface parameters of the target communication matrix table and query a target structure corresponding to the interface parameters in a code file.

[0032] The adding module is configured to add preset test code corresponding to the communication interface at a code position of the target structure by using a preset script, to generate an interface test case.

[0033] In the third aspect, the application further provides a computer device including a processor and a memory, the memory being configured to store a computer program, the computer program being configured to implement the interface test case generation method of the first aspect when executed by the processor.

[0034] In the fourth aspect, the application further provides a computer readable storage medium storing a computer program, the computer program being configured to implement the interface test case generation method of the first aspect when executed by a processor.

[0035] Compared with the prior art, the application has at least the following beneficial effects:

[0036] Since the Someip interface is usually distributed in the MCU software and the SOC software, and the signal data structure type of each service sent is complex, involving thousands of signal assignments, manually adding test code is time-consuming and has a high error rate. The application obtains a target communication matrix table of a communication interface, including a server interface and a client interface, iterates interface parameters of the target communication matrix table, and queries a target structure corresponding to the interface parameters in a code file. A preset script is used to add preset test code corresponding to the communication interface at a code position of the target structure, to generate an interface test case. When testing the Someip interface, the script can query a function position corresponding to the software code according to the correspondence between the matrix table and the software code, and automatically add SOMEIP interface call test code, to reduce the error rate and improve the test efficiency, greatly saving manpower. BRIEF DESCRIPTION OF DRAWINGS

[0037] Figure 1 A flowchart of a method for generating an interface test case shown in the application;

[0038] Figure 2 A schematic diagram of a first communication matrix table shown in the application;

[0039] Figure 3 A schematic diagram of a second communication matrix table shown in the application;

[0040] Figure 4 A schematic diagram of a target communication matrix table shown in the application;

[0041] Figure 5 A structural schematic diagram of a device for generating an interface test case shown in the application;

[0042] Figure 6 A structural schematic diagram of a computer device shown in the application. DETAILED DESCRIPTION

[0043] The technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the application.

[0044] Please refer to Figure 1 , Figure 1A flowchart of an interface test case generation method provided by an embodiment of the present application is shown. The interface test case generation method of the embodiment of the present application can be applied to a computer device, including but not limited to a smart phone, a notebook computer, a tablet computer, a desktop computer, a physical server, a cloud server, and the like. As shown in Figure 1 , the interface test case generation method of the embodiment includes steps S101 to S103, which are described in detail as follows.

[0045] In step S101, a target communication matrix table of a communication interface is obtained, the communication interface including a server interface and a client interface.

[0046] In this step, the communication interface can be a SOMEIP communication protocol interface, and the SOMEIP communication protocol is a communication protocol between the server interface and the client interface, such as communication between an MCU and an SOC.

[0047] In some embodiments, the step S101 includes:

[0048] obtaining a first communication matrix table of the server interface and a second communication matrix table of the client interface;

[0049] performing format processing on the first communication matrix table and the second communication matrix table to generate the target communication matrix table with the same data format.

[0050] In this embodiment, for the SOMEIP communication protocol, the MCU end is taken as the server, and the SOC end is taken as the client. The SOMEIP communication matrix table of the MCU end (e.g., the first communication matrix shown in Figure 2 ) and the SOMEIP communication matrix table of the SOC end (e.g., the second communication matrix shown in Figure 3 ) are obtained. The interface parameters in the service name column, the service ID column, the method / event name column, the event / notification event parameter column, the server APP column, and the App / SWC column of the two communication matrix tables are extracted, and the extracted interface parameters are uniformly formatted to generate the target communication matrix table shown in Figure 4 . The target communication matrix table can be a target communication matrix table format. It should be noted that, by uniformly formatting the first communication matrix table and the second communication matrix table, the interface test case generation efficiency of the computer device can be improved.

[0051] In step S102, the interface parameters of the target communication matrix table are traversed, and a target structure corresponding to the interface parameters in the code file is queried.

[0052] In this step, the interface parameters include, but are not limited to, the column data such as Service Name, SeriveID, Client APP, MCU_Event, SOC_Event and Data Type as shown in the table below; the code file can be a ".c file" or a ".cpp file" under the code path of the server software (such as MCU software) and the client software (such as SOC software); and the target structure is a data structure such as the data structure of the Data Type column as shown in the table below. Figure 4 Figure 4

[0053] It can be understood that, since the communication interface includes the server interface and the client interface, test codes need to be added for the server interface and the client interface respectively. Therefore, the application queries the target structure corresponding to the interface parameters of the server and the client, so as to effectively identify and classify the data structures of the complex data types involved in the server and the client, thereby realizing automatic addition of test codes and improving the efficiency and accuracy of use cases.

[0054] In some embodiments, the interface parameters include first interface parameters corresponding to the server interface and second interface parameters corresponding to the client interface, and the step S102 includes:

[0055] Based on the flag of the code file, the first code file corresponding to the server interface and the second code file corresponding to the client interface are determined;

[0056] The first interface parameters in the target communication matrix are traversed, and the first target structure corresponding to the first interface parameters in the first code file is queried;

[0057] The second interface parameters in the target communication matrix are traversed, and the second target structure corresponding to the second interface parameters in the second code file is queried.

[0058] In this embodiment, the flag can be direction, so as to distinguish between the server code and the client code, and add test codes for the server code and the client code respectively.

[0059] Optionally, the target structure query of the server includes: performing parameter passing processing on the first sub-parameter and the second sub-parameter in the first interface parameters, so as to determine the first code sub-file with the same first sub-parameter in the first code file; and in the first code sub-file, the first target structure corresponding to the second sub-parameter is queried.

[0060] ​​In the optional embodiment, the first sub-parameter can be an interface parameter of the Server APP column, and the second sub-parameter can be an interface parameter of the MCU Event column, that is, in the software code file, a.cpp file with the same name as the Server APP column in the target communication matrix table is queried, and a code position with the same structure as the MCU Event column in the file is queried, and the code position is used to add the test code of the server.

[0061] Exemplarily, the Server App column data and the MCU Event column data in the target communication matrix table are subjected to parameter passing processing to obtain the code in the.cpp format file under the software code path. When a.cpp file with the same Server App column data is queried, a data structure corresponding to the MCU Event column is queried in the.cpp file. If the corresponding.cpp file cannot be found, a message of "can't find.cpp file" is reported, and the next structure is searched.

[0062] Optionally, for the target structure body query of the client, the third sub-parameter and the fourth sub-parameter in the second interface parameter are subjected to parameter passing processing to determine a second code sub-file with the same third sub-parameter in the second code file; and in the second code sub-file, the second target structure corresponding to the fourth sub-parameter is queried.

[0063] In the optional embodiment, the third sub-parameter can be an interface parameter of the Client APP column, and the fourth sub-parameter can be a parameter of the SOC Event column, that is, in the software code file, a.cpp file with the same name as the Client APP column in the target communication matrix table is queried, and a code position with the same structure as the SOC Event column in the file is queried, and the code position is used to add the test code of the client.

[0064] In step S103, the preset script is used to add preset test code corresponding to the communication interface at the code position of the target structure body, to generate an interface test case.

[0065] In this step, the preset script can be a python script, which cyclically traverses all data structure names and data types corresponding to service Name in the target communication matrix table, and adds all Server test codes and Client test codes defined by the target communication matrix table.

[0066] Exemplarily, taking adding a test code function in the.cpp file of the SOC end as an example:

[0067] The soc_path: software code.cpp path address, module corresponding to the service name column, event_name corresponding to the soc_Event column, direction flag bit, event_data_type corresponding to the DataType column, and module_path storing the absolute path of the completed.cpp file, src_name storing the complete name of.cpp, and file_path storing the absolute path and name information of all.cpp files under the path are obtained by the soc_disruptor_someip_frame_code_gen() function.

[0068] The structure data length corresponding to the data_type column is calculated by the sig_datalength_analyse() function, and the length is returned to the parameter name. The length is used to distinguish between adding test code greater than 4 bytes and test code less than 4 bytes at the test code addition position.

[0069] The key_str variable is assigned a value by the direction flag bit to distinguish the keywords of the sending end code and the receiving end code.

[0070] The.cpp file is opened in sequence, and the key_str and the corresponding event_name in the code are queried line by line to lock the structure position where the test code needs to be added. The test code to be added is inserted into the structure position by the context_lines.insert function to complete the test code addition at the event_name. The for loop traverses the entire target communication matrix table to add all test codes.

[0071] Exemplarily, for the MCU, test code calling the Rte interface is added in the Runnable function closest to the code position with the same structure as the SOC Event column.

[0072] In some embodiments, the step S103 comprises:

[0073] For each target structure, a preset code addition function is used to add the corresponding preset test code of the communication interface to the code position of the target structure.

[0074] A preset logic script is used to verify the consistency of the code parameters of the preset test code with the interface parameters of the communication matrix table.

[0075] If the code parameters and the interface parameters are consistent, it is determined that the interface test case is successfully generated.

[0076] In the embodiment, the preset code adding function can be the mcu_vector_someip_sync_code_gen() function, and the preset logic script can be a Python script logic for comparing whether the interface parameters (including interface function names, etc.) in the code are consistent with the definitions in the target communication matrix table. If not, an error is reported, that is, the event can't checkout interface_str in file is displayed on the user terminal interface.

[0077] Optionally, the parameter consistency verification comprises: querying a keyword function in the code parameter by using the preset logic script, and determining whether a preset keyword corresponding to the keyword function and the interface parameter are in the same code position; if the preset keyword and the interface parameter are in the same code position, it is determined that the code parameter and the interface parameter are consistent.

[0078] In the optional embodiment, for example, the mcu_vector_someip_sync_code_gen() function is used to obtain interface parameters such as an mcu_path software.c code path, a directon flag, a module: Server App column, an event_name: mcu_event column, and an event_data_type: DataType column. It is queried whether there is an Rte_Read or Rte_Write keyword containing the mcu_event column in the corresponding Server App.c file, and it is determined whether the "std_ReturnType" preset keyword and the Even Name are in the same code position. If the corresponding Rte function is found, and the "std_ReturnType" preset keyword and the Even Name are in the same code position, the function name in the code is assigned to the variable of interface_str. After the line-by-line query is completed, if the corresponding Rte function cannot be found in the.c file, interface_str = None, and the terminal is printed with "event can't checkout interface_str in file", so as to realize the comparison between the matrix table definition name and the name in the code. When all the EventName in the target communication matrix table are looped, the computer device displays all the log prints that cannot complete the test code adding due to the name or other reasons.

[0079] In order to perform the interface test case generation method corresponding to the above method embodiment, to realize the corresponding functions and technical effects. Referring to Figure 5 , Figure 5A structural block diagram of an interface test case generation apparatus provided by an embodiment of the present application is shown. For ease of illustration, only parts related to the present embodiment are shown. The interface test case generation apparatus provided by the present embodiment comprises:

[0080] The acquisition module 501 is configured to acquire a target communication matrix table of a communication interface, the communication interface comprising a server interface and a client interface.

[0081] The query module 502 is configured to traverse an interface parameter of the target communication matrix table, and query a target structure corresponding to the interface parameter in a code file.

[0082] The adding module 503 is configured to add a preset test code corresponding to the communication interface at a code position where the target structure is located by using a preset script, to generate an interface test case.

[0083] In some embodiments, the acquisition module 501 is specifically configured to:

[0084] acquire a first communication matrix table of the server interface and a second communication matrix table of the client interface;

[0085] perform format processing on the first communication matrix table and the second communication matrix table to generate the target communication matrix table having the same data format.

[0086] In some embodiments, the interface parameter comprises a first interface parameter corresponding to the server interface and a second interface parameter corresponding to the client interface, and the query module 502 comprises:

[0087] a determination unit configured to determine a first code file corresponding to the server interface and a second code file corresponding to the client interface based on a flag bit of a code file;

[0088] a first traversal unit configured to traverse a first interface parameter in the target communication matrix, and query a first target structure corresponding to the first interface parameter in the first code file;

[0089] a second traversal unit configured to traverse a second interface parameter in the target communication matrix, and query a second target structure corresponding to the second interface parameter in the second code file.

[0090] In some embodiments, the first traversal unit is specifically configured to:

[0091] perform parameter passing processing on a first sub-parameter and a second sub-parameter in the first interface parameter, to determine a first code sub-file in the first code file which is identical to the first sub-parameter;

[0092] In the first code sub-file, the first target structure corresponding to the second sub-parameter is queried.

[0093] In some embodiments, the second traversing unit is specifically configured to:

[0094] The third sub-parameter and the fourth sub-parameter in the second interface parameter are subjected to parameter processing, so as to determine a second code sub-file in the second code file which is the same as the third sub-parameter;

[0095] In the second code sub-file, the second target structure corresponding to the fourth sub-parameter is queried.

[0096] In some embodiments, the adding module 503 comprises:

[0097] An adding unit is configured to, for each target structure, add, by using a preset code adding function, preset test code corresponding to the communication interface to a code position where the target structure is located;

[0098] A verifying unit is configured to verify, by using a preset logic script, consistency between a code parameter of the preset test code and an interface parameter of the communication matrix table;

[0099] A determining unit is configured to, if the code parameter is consistent with the interface parameter, determine that the interface test case is successfully generated.

[0100] In some embodiments, the verifying unit is specifically configured to:

[0101] The preset logic script is used to query a keyword function in the code parameter, and it is determined whether a preset keyword corresponding to the keyword function is in a same code position as the interface parameter;

[0102] If the preset keyword is in the same code position as the interface parameter, it is determined that the code parameter is consistent with the interface parameter.

[0103] The interface test case generation apparatus described above can implement the interface test case generation method of the method embodiment described above. The options in the method embodiment described above are also applicable to this embodiment, and thus will not be described in detail herein. The remaining content of the embodiment of the present application can refer to the content of the method embodiment described above, and will not be described in detail herein.

[0104] Figure 6 A structural schematic diagram of a computer device is provided in an embodiment of the present application. As shown in Figure 6 The computer device 6 in this embodiment comprises at least one processor 60 (for example, a central processing unit (CPU), a microprocessor, or an application-specific integrated circuit (ASIC)), a memory 61, a communication interface 62, and a bus 63. Figure 6(Only one is shown in the diagram) a processor, a memory 61, and a computer program 62 stored in the memory 61 and executable on the at least one processor 60, wherein the processor 60 executes the computer program 62 to implement the steps in any of the above method embodiments.

[0105] The computer device 6 may be a smartphone, tablet, desktop computer, or cloud server, among other computing devices. This computer device may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will understand that... Figure 6 The computer device 6 is merely an example and does not constitute a limitation on the computer device 6. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0106] The processor 60 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0107] In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 may be an external storage device of the computer device 6, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 6. Furthermore, the memory 61 may include both internal and external storage units of the computer device 6. The memory 61 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 61 can also be used to temporarily store data that has been output or will be output.

[0108] In addition, the embodiment of the present application further provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the steps in any method embodiment described above.

[0109] The embodiment of the present application provides a computer program product. When the computer program product is run on a computer device, the computer device is caused to execute the steps in each method embodiment described above.

[0110] In several embodiments provided in the present application, it can be understood that each block in the flowchart or block diagram can represent a module, a segment or a portion of code which includes one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in a different order than that noted in the figure. For example, two blocks that are consecutive in the figure can actually be executed substantially in parallel, or they can be executed in reverse order, depending on the involved functions.

[0111] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various other media capable of storing program codes.

[0112] The above-described specific embodiments further illustrate the purpose, technical solutions and beneficial effects of the present application. It should be understood that the above-described embodiments are merely specific embodiments of the present application and are not intended to limit the protection scope of the present application. It is particularly pointed out that any modification, equivalent replacement, improvement, etc. made by those skilled in the art within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for generating interface test cases, characterized in that, The method is applied to a computer device and comprises the following steps: obtaining a target communication matrix table of a communication interface, wherein the communication interface comprises a server interface and a client interface; traversing an interface parameter of the target communication matrix table, and querying a target structure corresponding to the interface parameter in a code file of the communication interface; adding preset test code corresponding to the communication interface to a code position of the target structure by using a preset script to generate an interface test case; wherein the interface parameter comprises a first interface parameter corresponding to the server interface and a second interface parameter corresponding to the client interface, and the step of traversing the interface parameter of the target communication matrix table and querying the target structure corresponding to the interface parameter in the code file of the communication interface comprises the following steps: determining a first code file corresponding to the server interface and a second code file corresponding to the client interface based on a flag bit of the code file; traversing the first interface parameter in the target communication matrix, and querying a first target structure corresponding to the first interface parameter in the first code file; traversing the second interface parameter in the target communication matrix, and querying a second target structure corresponding to the second interface parameter in the second code file; the step of traversing the first interface parameter in the target communication matrix and querying the first target structure corresponding to the first interface parameter in the first code file comprises the following steps: performing parameter passing processing on a first sub-parameter and a second sub-parameter in the first interface parameter to determine a first code sub-file in the first code file that is identical to the first sub-parameter; in the first code sub-file, querying the first target structure corresponding to the second sub-parameter; the step of traversing the second interface parameter in the target communication matrix and querying the second target structure corresponding to the second interface parameter in the second code file comprises the following steps: performing parameter passing processing on a third sub-parameter and a fourth sub-parameter in the second interface parameter to determine a second code sub-file in the second code file that is identical to the third sub-parameter; in the second code sub-file, querying the second target structure corresponding to the fourth sub-parameter.

2. The method of claim 1, wherein the interface test case is generated by: the step of obtaining the target communication matrix table of the communication interface comprises the following steps: obtaining a first communication matrix table of the server interface and a second communication matrix table of the client interface; performing format processing on the first communication matrix table and the second communication matrix table to generate the target communication matrix table with the same data format.

3. The method of claim 2, wherein the interface test case is generated by: the step of adding the preset test code corresponding to the communication interface to the code position of the target structure by using the preset script to generate the interface test case comprises the following steps: for each target structure, adding the preset test code corresponding to the communication interface to the code position of the target structure by using a preset script according to a preset code adding function; verifying consistency between a code parameter of the preset test code and an interface parameter of the communication matrix table; if the code parameter is consistent with the interface parameter, it is determined that the interface test case is successfully generated.

4. The method of claim 3, wherein the interface test case is generated by: The consistency of the code parameters of the preset test code with the interface parameters of the communication matrix table is verified by using the preset script, and the verification includes: The preset script is used to query a keyword function in the code parameters, and it is determined whether a preset keyword corresponding to the keyword function and the interface parameters are in the same code position; If the preset keyword and the interface parameters are in the same code position, it is determined that the code parameters and the interface parameters are consistent.

5. An interface test case generation device, characterized in that, The device is applied to a computer device, and the device includes: An acquisition module is configured to acquire a target communication matrix table of a communication interface, the communication interface including a server interface and a client interface; A query module is configured to traverse interface parameters of the target communication matrix table, and query a target structure corresponding to the interface parameters in a code file of the communication interface; An adding module is configured to add, by using a preset script, preset test code corresponding to the communication interface at a code position of the target structure, to generate an interface test case; The interface parameters include first interface parameters corresponding to the server interface and second interface parameters corresponding to the client interface, and the traversal of the interface parameters of the target communication matrix table and the query of the target structure corresponding to the interface parameters in the code file of the communication interface include: Based on a flag bit of the code file, a first code file corresponding to the server interface and a second code file corresponding to the client interface are determined; The first interface parameters in the target communication matrix are traversed, and a first target structure corresponding to the first interface parameters in the first code file is queried; The second interface parameters in the target communication matrix are traversed, and a second target structure corresponding to the second interface parameters in the second code file is queried; The traversal of the first interface parameters in the target communication matrix and the query of the first target structure corresponding to the first interface parameters in the first code file include: The first and second sub-parameters in the first interface parameters are subjected to parameter passing processing, to determine a first code sub-file in the first code file that is the same as the first sub-parameter; In the first code sub-file, the first target structure corresponding to the second sub-parameter is queried; The traversal of the second interface parameters in the target communication matrix and the query of the second target structure corresponding to the second interface parameters in the second code file include: The third and fourth sub-parameters in the second interface parameters are subjected to parameter passing processing, to determine a second code sub-file in the second code file that is the same as the third sub-parameter; In the second code sub-file, the second target structure corresponding to the fourth sub-parameter is queried.

6. A computer device, comprising: The device includes a processor and a memory, the memory is used to store a computer program, and the computer program is executed by the processor to implement the interface test case generation method in any one of claims 1 to 4.

7. A computer readable storage medium characterized by The device has a computer program stored therein, and the computer program is executed by a processor to implement the interface test case generation method in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Controller interface configuration method and device

    CN115542882A

  • Low-cost and high-efficiency CAN message automatic test method and system

    CN115604078A

  • Service test method and device, storage medium and electronic equipment

    CN115712562A