Programming language project testing method and device, electronic equipment and readable storage medium

By recording and replaying interface traffic in production and testing environments, the problem of inaccurate testing of programming language projects in existing technologies is solved, the consistency of functional logic is guaranteed, and a more accurate testing method is provided.

CN122111819APending Publication Date: 2026-05-29SHENZHEN YISHIHUOLALA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN YISHIHUOLALA TECH CO LTD
Filing Date
2026-03-17
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing programming language project testing methods are insufficient for comparing the differences in functional logic details, resulting in inaccurate test comparisons and an inability to effectively guarantee the consistency of functional logic before and after modifications.

Method used

By recording interface traffic in the production environment and replaying the interface traffic before and after translation in the test environment, the replay traffic can be used to determine the test results. Alternatively, the interface traffic before and after modification can be recorded and replayed in the same language scenario for comparison, thus enabling accurate testing of programming language projects.

Benefits of technology

It enables more accurate testing of programming language projects, ensuring consistency of functional logic before and after modifications, and improving the accuracy and reliability of testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111819A_ABST
    Figure CN122111819A_ABST
Patent Text Reader

Abstract

The application discloses a programming language project testing method and device, electronic equipment and a computer readable storage medium. The method comprises the following steps: determining a test scenario of a target programming language project; when the test scenario is a cross-language scenario, recording interface traffic in a production environment to obtain first recorded traffic; playing back the first recorded traffic through a pre-translation interface and a post-translation interface in a test environment to obtain first playback traffic and second playback traffic; determining a test result of the target programming language project in the cross-language scenario according to the first playback traffic and the second playback traffic; when the test scenario is a same-language scenario, recording interface traffic of a pre-modified interface to obtain second recorded traffic; playing back the second recorded traffic through a post-modified interface to obtain third playback traffic; and determining a test result of the target programming language project in the same-language scenario according to the second recorded traffic and the third playback traffic. The technical solution provided by the application can realize more accurate programming language project testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software testing technology, and in particular to a programming language project testing method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] In some computer programming language projects, different requirements may necessitate cross-language translation (e.g., translating PHP into Java) or language-specific modifications (e.g., modifying a specific interface in a PHP project). To avoid logical problems or data inconsistencies after modification, it's necessary to perform pre- and post-modification testing and analysis. However, conventional code comparison tools can only handle syntax and character comparisons at the code level, failing to address subtle differences in functional logic, leading to inaccurate testing comparisons.

[0003] Therefore, how to achieve more accurate testing of programming language projects in order to effectively ensure the consistency of functional logic before and after modifications is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] The purpose of this application is to provide a programming language project testing method that can achieve more accurate programming language project testing and effectively ensure the consistency of functional logic before and after the modification of the programming language project. Another purpose of this application is to provide a programming language project testing device, electronic device, and computer-readable storage medium, all of which have the above-mentioned beneficial effects.

[0005] Firstly, this application discloses a method for testing programming language projects, including:

[0006] Determine the test scenarios for the target programming language project;

[0007] When the test scenario is a cross-language scenario, the interface traffic is recorded in the production environment to obtain the first recorded traffic; the first recorded traffic is replayed in the pre-translation interface and post-translation interface in the test environment to obtain the first replay traffic and the second replay traffic; the test result of the target programming language project in the cross-language scenario is determined based on the first replay traffic and the second replay traffic.

[0008] When the test scenario is a same language scenario, the interface traffic is recorded for the interface before modification to obtain the second recorded traffic; the second recorded traffic is replayed for the interface after modification to obtain the third replayed traffic; the test result of the target programming language project in the same language scenario is determined based on the second recorded traffic and the third replayed traffic.

[0009] Optionally, interface traffic is recorded in a production environment to obtain the first recorded traffic, including:

[0010] Obtain the first configuration information of the production environment;

[0011] Determine whether the recording and playback function is enabled based on the first configuration information;

[0012] When the recording and playback function is enabled, the recording function component is loaded in the production environment to record the interface traffic, thereby obtaining the first recorded traffic.

[0013] Optionally, interface traffic is recorded in a production environment to obtain the first recorded traffic, including:

[0014] Determine the entry API for the production environment;

[0015] The first recorded traffic is obtained by recording traffic and sub-traffic on the ingress API.

[0016] The ingress API sub-traffic includes communication traffic and / or storage traffic.

[0017] Optionally, interface traffic is recorded in a production environment to obtain the first recorded traffic, including:

[0018] Obtain the second configuration information of the test environment;

[0019] A coloring plan is determined based on the second configuration information; the coloring plan includes recording interface information and / or the interface traffic recording ratio.

[0020] The interface traffic is recorded in the production environment according to the dyeing plan to obtain the first recorded traffic.

[0021] Optionally, the interface traffic before modification is recorded to obtain the second recorded traffic, including:

[0022] Obtain the interface configuration information and determine the interface traffic recording ratio based on the interface configuration information;

[0023] The interface traffic before modification is recorded according to the interface traffic recording ratio to obtain the second recorded traffic.

[0024] Optionally, determining the test results of the target programming language project in the cross-language scenario based on the first replay traffic and the second replay traffic includes:

[0025] When the first replay traffic matches the second replay traffic, the test result of the target programming language project in the cross-language scenario is determined to be a successful test.

[0026] When the first playback traffic is inconsistent with the second playback traffic, the test result of the target programming language project in the cross-language scenario is determined to be a test failure.

[0027] Optionally, the programming language project testing method further includes:

[0028] When the test result is that the test fails, a traffic comparison report is generated based on the first replay traffic and the second replay traffic.

[0029] Output the traffic comparison report.

[0030] Secondly, this application discloses a programming language project testing device, comprising:

[0031] The determination module is used to determine the test scenarios for the target programming language project;

[0032] The first testing module is used to record interface traffic in a production environment to obtain first recorded traffic when the test scenario is a cross-language scenario; to replay the first recorded traffic in the pre-translation interface and post-translation interface in the test environment to obtain first replay traffic and second replay traffic; and to determine the test result of the target programming language project in the cross-language scenario based on the first replay traffic and the second replay traffic.

[0033] The second testing module is used to record interface traffic for the interface before modification to obtain a second recorded traffic when the test scenario is a same language scenario; to replay the second recorded traffic for the interface after modification to obtain a third replayed traffic; and to determine the test result of the target programming language project in the same language scenario based on the second recorded traffic and the third replayed traffic.

[0034] Thirdly, this application discloses an electronic device, comprising:

[0035] Memory, used to store computer programs;

[0036] A processor, used to implement the steps of any programming language project testing method as described above when executing the computer program.

[0037] Fourthly, this application discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the programming language project testing methods described above.

[0038] This application provides a method for testing a programming language project, comprising: determining a test scenario for the target programming language project; when the test scenario is a cross-language scenario, recording interface traffic in a production environment to obtain first recorded traffic; replaying the first recorded traffic in the pre-translation interface and post-translation interface in the test environment to obtain first replay traffic and second replay traffic; determining the test result of the target programming language project in the cross-language scenario based on the first replay traffic and the second replay traffic; when the test scenario is a same-language scenario, recording interface traffic for the pre-modification interface to obtain second recorded traffic; replaying the second recorded traffic in the post-modification interface to obtain third replay traffic; and determining the test result of the target programming language project in the same-language scenario based on the second recorded traffic and the third replay traffic.

[0039] The technical solution provided in this application offers programming language project testing in both cross-language translation and same-language modification scenarios. In the cross-language translation scenario, interface traffic in a real production environment can be recorded and replayed to the pre-translation and post-translation interfaces in a virtual test environment, obtaining the replay traffic of both. Since the pre-translation and post-translation interfaces are based on different programming languages, the test results for the programming language project in the cross-language translation scenario can be obtained by comparing and analyzing the replay traffic of the two interfaces. In the same-language translation scenario, interface traffic of the pre-modification interface can be recorded and replayed to the post-modification interface. The test results for the programming language project in the same-language modification scenario can then be obtained by comparing and analyzing the recorded traffic of the pre-modification interface and the replay traffic of the post-modification interface. Therefore, this technical solution achieves programming language project testing through real traffic recording and replay. Compared to traditional programming language project testing methods based on single code comparison tools, it can achieve more accurate programming language project testing, thereby effectively ensuring the consistency of functional logic before and after the modification of the programming language project.

[0040] The programming language project testing device, electronic device, and computer-readable storage medium provided in this application also have the above-mentioned technical effects, and will not be described in detail here. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the prior art and the embodiments of this application, the accompanying drawings used in the description of the prior art and the embodiments of this application will be briefly introduced below. Of course, the accompanying drawings described below with respect to the embodiments of this application are only a part of the embodiments in this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort, and such other drawings also fall within the protection scope of this application.

[0042] Figure 1A flowchart illustrating a programming language project testing method provided in an embodiment of this application;

[0043] Figure 2 This is a schematic diagram of the structure of a programming language project testing device provided in an embodiment of this application;

[0044] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0045] The core of this application is to provide a programming language project testing method, which can achieve more accurate programming language project testing and effectively ensure the consistency of functional logic before and after the modification of the programming language project; another core aspect of this application is to provide a programming language project testing device, electronic device, and computer-readable storage medium, all of which have the above-mentioned beneficial effects.

[0046] To provide a clearer and more complete description of the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0047] This application provides a method for testing programming language projects.

[0048] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a programming language project testing method provided in an embodiment of this application. The programming language project testing method may include, but is not limited to, the following S101~S103.

[0049] S101: Determine the test scenario for the target programming language project.

[0050] This step aims to determine the test scenarios for the target programming language project. The target programming language project is the project that needs to be tested. Test scenarios can be divided into cross-language scenarios and intra-language scenarios. Cross-language scenarios involve translating and modifying one programming language into another, such as translating PHP into Java. Intra-language scenarios involve modifying the functionality of an interface within a programming language project, such as modifying the functionality of an interface within a PHP project. It is understood that different test scenarios correspond to different test plans for different programming language projects. The specific implementation process can be referred to as S102 and S103 below.

[0051] S102: When the test scenario is a cross-language scenario, record the interface traffic in the production environment to obtain the first recorded traffic; replay the first recorded traffic in the pre-translation interface and post-translation interface in the test environment to obtain the first replay traffic and the second replay traffic; determine the test results of the target programming language project in the cross-language scenario based on the first replay traffic and the second replay traffic.

[0052] This step aims to test programming language projects in cross-language scenarios. Specifically, it involves first recording interface traffic in a real production environment to obtain the first recorded traffic. Then, this first recorded traffic is replayed in the test environment for both the pre-translation and post-translation interfaces to obtain the corresponding replay traffic. This results in the first replay traffic for the pre-translation interface and the second replay traffic for the post-translation interface. The pre-translation and post-translation interfaces are based on different programming languages. Taking the translation of PHP into Java as an example, the pre-translation interface is based on PHP, and the post-translation interface is based on Java. By comparing and analyzing the first and second replay traffic, the test results of the target programming language project in a cross-language scenario can be obtained.

[0053] The method of determining the test result of the target programming language project in a cross-language scenario based on the first and second replay traffic can include: when the first and second replay traffic match, the test result of the target programming language project in the cross-language scenario is determined to be a pass; when the first and second replay traffic do not match, the test result of the target programming language project in the cross-language scenario is determined to be a fail. Furthermore, this programming language project testing method can also include: when the test result is a fail, generating a traffic comparison report based on the first and second replay traffic; and outputting the traffic comparison report. Of course, when the test result is a pass, a corresponding traffic comparison report can also be generated and output.

[0054] In one embodiment of this application, recording interface traffic in a production environment to obtain first recorded traffic may include: obtaining first configuration information of the production environment; determining whether the recording and playback function is enabled based on the first configuration information; and when the recording and playback function is enabled, loading the recording function component in the production environment to record interface traffic to obtain the first recorded traffic.

[0055] Specifically, recording interface traffic in the production environment can be implemented based on configuration information. The production environment configuration information (i.e., the test configuration information of the target programming language project) determines whether to enable the recording and playback function. When the recording and playback function is enabled, interface traffic can be recorded by loading the recording component (and subsequently replayed by loading the playback component). When the recording and playback function is disabled, the recording component will not be loaded for interface traffic recording. In one possible implementation, the recording / playback component can be an SDK component.

[0056] In one embodiment of this application, recording interface traffic in a production environment to obtain first recorded traffic may include: determining the entry API of the production environment; recording traffic and sub-traffic of the entry API to obtain first recorded traffic; wherein, the sub-traffic of the entry API includes communication traffic and / or storage traffic.

[0057] Specifically, in the testing process of programming language projects in cross-language scenarios, interface traffic recording can include the sending and receiving traffic of the production environment entry API itself (such as request parameters, header information, path information, URI information, etc.) and its internal sub-traffic. Among them, the entry API sub-traffic can include communication traffic and / or storage traffic. Communication traffic is such as downstream data traffic for RPC / HTTP / SOA requests, and storage traffic is such as Redis traffic, MySQL traffic, Kafka production message traffic, etc.

[0058] In one embodiment of this application, recording interface traffic in a production environment to obtain first recorded traffic may include: obtaining second configuration information of the test environment (i.e., test configuration information of the target programming language project); determining a coloring plan based on the second configuration information; the coloring plan includes recording interface information and / or the interface traffic recording ratio; and recording interface traffic in the production environment according to the coloring plan to obtain the first recorded traffic.

[0059] Specifically, interface traffic recording in a production environment can be implemented using a pre-configured coloring plan. This plan can include recording interface information and / or interface traffic recording ratios. The recording interface information indicates which interfaces require traffic recording, and the interface traffic recording ratio indicates the proportion of traffic to be recorded for those interfaces. It is understood that recording traffic only for a subset of interfaces in the target programming language project, or recording traffic at a certain ratio, rather than recording traffic for all interfaces in the target programming language project or recording all traffic within each interface, can effectively reduce system load.

[0060] S103: When the test scenario is a same language scenario, record the interface traffic before modification to obtain the second recorded traffic; replay the second recorded traffic after modification to obtain the third replay traffic; determine the test results of the target programming language project in the same language scenario based on the second recorded traffic and the third replay traffic.

[0061] This step aims to test programming language projects within the same language context. Specifically, it involves first recording the interface traffic before modification (resulting in a second recorded traffic), then replaying this second recorded traffic with the modified interface (resulting in a third replayed traffic). The functionalities of the interface before and after modification differ. By comparing and analyzing the second recorded traffic and the third replayed traffic, the test results for the target programming language project within the same language context can be obtained.

[0062] The method of determining the test result of the target programming language project in the same language scenario based on the second recorded traffic and the third playback traffic can include: when the second recorded traffic and the third playback traffic are consistent, the test result of the target programming language project in the same language scenario is determined to be a pass; when the second recorded traffic and the third playback traffic are inconsistent, the test result of the target programming language project in the same language scenario is determined to be a fail. Furthermore, the programming language project testing method can also include: when the test result is a fail, generating a traffic comparison report based on the second recorded traffic and the third playback traffic; and outputting the traffic comparison report. Of course, when the test result is a pass, a corresponding traffic comparison report can also be generated and output.

[0063] In one embodiment of this application, recording interface traffic of the interface before modification to obtain the second recorded traffic may include: obtaining test configuration information of the target programming language project; determining whether the recording and playback function is enabled based on the test configuration information; and when the recording and playback function is enabled, loading the recording function component to record interface traffic of the interface before modification to obtain the second recorded traffic.

[0064] In one embodiment of this application, recording interface traffic of the interface before modification to obtain second recorded traffic may include: determining the entry API of the target programming language project; recording traffic of the entry API to obtain second recorded traffic. It is understood that, unlike testing programming language projects in cross-language scenarios, testing programming language projects in the same language scenario only requires recording interface traffic of the entry API of the target programming language project, without recording its internal sub-traffic. This is because target programming language projects in the same language scenario are generally rarely modified as a whole. Even if they are modified as a whole, the syntax is consistent and the writing style is similar; only the consistency of the final result needs to be determined. However, target programming language projects in cross-language scenarios, due to inconsistent syntax and writing style, are prone to omissions or errors in logic or sub-traffic logic that differs from the original programming language (the programming language before translation) during translation.

[0065] In one embodiment of this application, recording interface traffic for the interface before modification to obtain second recorded traffic may include: obtaining interface configuration information (i.e., test configuration information of the target programming language project), and determining the interface traffic recording ratio based on the interface configuration information; recording interface traffic for the interface before modification according to the interface traffic recording ratio to obtain second recorded traffic. Similarly, recording only a portion of the traffic of the corresponding interface, rather than recording all the traffic, can effectively reduce system pressure.

[0066] As can be seen, the programming language project testing method provided in this application provides testing for both cross-language translation and same-language modification scenarios. In the cross-language translation scenario, interface traffic in a real production environment can be recorded and replayed to the pre-translation and post-translation interfaces in a virtual test environment, obtaining the replay traffic of both. Since the pre-translation and post-translation interfaces are based on different programming languages, the test results for the programming language project in the cross-language translation scenario can be obtained by comparing and analyzing the replay traffic of the two interfaces. In the same-language translation scenario, interface traffic of the pre-modification interface can be recorded and replayed to the post-modification interface. Then, the test results for the programming language project in the same-language modification scenario can be obtained by comparing and analyzing the recorded traffic of the pre-modification interface and the replay traffic of the post-modification interface. Therefore, this technical solution achieves programming language project testing through real traffic recording and replay. Compared with traditional programming language project testing methods based on a single code comparison tool, it can achieve more accurate programming language project testing, thereby effectively ensuring the consistency of functional logic before and after the modification of the programming language project.

[0067] For example, this application provides a method for testing programming language projects, using a PHP project as an example.

[0068] I. Cross-language recording and playback.

[0069] 1. The PHP project downloads and updates the PHP simulation SDK components through the Composer repository source, and determines the SDK version number and configuration information.

[0070] 2. The PHP project entry point (index.php or other framework entry point) imports the SDK initialization component and starts the registration initialization.

[0071] (1) Obtain configuration information and determine whether it is necessary to load SDK components for recording and playback;

[0072] (2) Load SDK components, determine the header, initialize recording and playback attributes, and set basic attribute parameters. The header is used to determine whether the traffic is for recording or playback, and the header can carry the playback token and link information; attribute initialization is used by the SDK to globally determine whether to record and play back sub-traffic, Kafka message queue, etc. before recording and playback; attribute parameter setting is used to construct sub-traffic recording queues (redis, sql, kafka), ingress traffic queues, etc.

[0073] 3. The entry API introduces the SDK to start recording method, which takes in the unique code of the entry traffic and parameters such as whether it is an entry point.

[0074] (1) Determine the coloring plan according to the input entry code. If the coloring plan is matched, return that the coloring was successful.

[0075] (2) After successful coloring, start recording the ingress traffic and sub-traffic;

[0076] (3) Assemble ingress traffic information by adding request parameters, header information, path information, URI information, etc. into the traffic data queue;

[0077] (4) When the downstream of the RPC / HTTP / SOA request starts recording, the parameters, response data and sub-traffic of the downstream request are uniquely encoded, assembled and added to the traffic data queue;

[0078] (5) Redis starts recording, assembles the Redis function methods, parameter information, and sub-traffic unique codes, and adds them to the traffic data pair column;

[0079] (6) Start recording MySQL, assemble the MySQL function methods, parameter information, and sub-traffic unique codes, and add them to the traffic data queue;

[0080] (7) Kafka production message recording begins. The Kafka generated message information and sub-traffic uniquely encoded are assembled and added to the data traffic queue.

[0081] 4. Introduce an end-of-recording method in the unified API response function of the project framework: assemble the response data of the entry API method, exception information and other data, and add them to the traffic data queue.

[0082] 5. Record data traffic reporting: Use Kafka to produce messages and send the recorded traffic data queue to the backend system for processing.

[0083] 6. The backend system begins playback processing.

[0084] (1) The backend system uses the recorded ingress traffic and sub-traffic as control group data and starts replaying requests to the experimental group environment project API interface (pre-translation interface and post-translation interface).

[0085] (2) Replay the RPC / HTTP / SOA requests of the experimental group interface, obtain the RPC / HTTP / SOA request sub-traffic data recorded by the backend system according to the sub-traffic encoding, return it directly as a mock, skip the real RPC / HTTP / SOA requests of the experimental group interface, and report the replayed sub-traffic data.

[0086] (3) Replay the Redis execution of the experimental group interface, obtain the Redis sub-traffic data recorded by the background system according to the sub-traffic encoding, return it directly as a mock, skip the real Redis execution of the experimental group interface, and report the replayed sub-traffic data.

[0087] (4) Replay the MySQL execution of the experimental group interface, obtain the MySQL sub-traffic data recorded by the background system according to the sub-traffic encoding, return it directly as a mock, skip the real MySQL execution of the experimental group interface, and report the replayed sub-traffic data.

[0088] (5) Replay the Kafka production messages of the experimental group interface, obtain the Kafka sub-traffic data recorded by the background system according to the sub-traffic encoding, return it directly as a mock, skip the real Kafka execution of the experimental group interface, and report the replayed sub-traffic data.

[0089] (6) Report the playback entry request traffic data.

[0090] 7. The backend system compares the recorded control group data and the playback traffic data reported by the experimental group according to the inflow traffic code and sub-flow traffic code, and outputs a comparison report.

[0091] (1) Verify whether the inbound traffic request parameters and response data are consistent;

[0092] (2) Whether the information of the control group and the experimental group in the RPC / HTTP / SOA request is consistent;

[0093] (3) Whether the information of the Redis control group and the experimental group is consistent;

[0094] (4) Whether the comparison information between the MySQL control group and the experimental group is consistent;

[0095] (5) Whether the information of the Kafka control group and the experimental group is consistent.

[0096] 8. Comparison report of control group and experimental group: Check whether the markings are logically consistent and the data is consistent.

[0097] II. Same language recording and playback.

[0098] 1. The PHP project downloads and updates the PHP simulation SDK components through the Composer repository source, and determines the SDK version number and configuration information.

[0099] 2. The PHP project entry point (index.php or other framework entry point) imports the SDK initialization component and starts the registration initialization.

[0100] (1) Obtain configuration information and determine whether it is necessary to load SDK components for recording and playback;

[0101] (2) Load SDK components, determine the header, initialize recording and playback properties, and set basic property parameters.

[0102] 3. Introduce an end-of-recording method into the unified API response function of the project framework.

[0103] (1) Perform traffic recording judgment on the API interface according to the configuration, and determine the traffic recording percentage;

[0104] (2) Assemble the API interface request parameters, header information, path information, URI parameter information, etc., and add them to the recording traffic queue.

[0105] 4. Record data traffic reporting: Use Kafka to produce messages and send the recorded traffic data queue to the backend system for processing.

[0106] 5. The backend system begins playback processing.

[0107] (1) Use the data recorded as a control group, and start replaying the recorded ingress traffic to the experimental group environment project API interface (modified interface).

[0108] (2) Report the replay request parameters and the experimental group API interface response data.

[0109] 6. The backend system compares the recorded control group data with the playback traffic data reported by the experimental group and outputs a comparison report.

[0110] As can be seen, the programming language project testing method provided in this application provides testing for both cross-language translation and same-language modification scenarios. In the cross-language translation scenario, interface traffic in a real production environment can be recorded and replayed to the pre-translation and post-translation interfaces in a virtual test environment, obtaining the replay traffic of both. Since the pre-translation and post-translation interfaces are based on different programming languages, the test results for the programming language project in the cross-language translation scenario can be obtained by comparing and analyzing the replay traffic of the two interfaces. In the same-language translation scenario, interface traffic of the pre-modification interface can be recorded and replayed to the post-modification interface. Then, the test results for the programming language project in the same-language modification scenario can be obtained by comparing and analyzing the recorded traffic of the pre-modification interface and the replay traffic of the post-modification interface. Therefore, this technical solution achieves programming language project testing through real traffic recording and replay. Compared with traditional programming language project testing methods based on a single code comparison tool, it can achieve more accurate programming language project testing, thereby effectively ensuring the consistency of functional logic before and after the modification of the programming language project.

[0111] This application provides a programming language project testing device.

[0112] Please refer to Figure 2 , Figure 2 This is a schematic diagram of the structure of a programming language project testing device provided in an embodiment of this application. The programming language project testing device may include:

[0113] Module 1 is used to determine the test scenarios for the target programming language project;

[0114] The first test module 2 is used to record interface traffic in the production environment to obtain the first recorded traffic when the test scenario is a cross-language scenario; to replay the first recorded traffic in the pre-translation interface and post-translation interface in the test environment to obtain the first replay traffic and the second replay traffic; and to determine the test results of the target programming language project in the cross-language scenario based on the first replay traffic and the second replay traffic.

[0115] The second test module 3 is used to record interface traffic for the interface before modification and obtain the second recorded traffic when the test scenario is a same language scenario; to replay the second recorded traffic for the interface after modification and obtain the third replayed traffic; and to determine the test results of the target programming language project in the same language scenario based on the second recorded traffic and the third replayed traffic.

[0116] As can be seen, the programming language project testing device provided in this application provides programming language project testing in both cross-language translation and same-language modification scenarios. In the cross-language translation scenario, interface traffic in a real production environment can be recorded and replayed to the pre-translation and post-translation interfaces in a virtual test environment, obtaining the replay traffic of both. Since the pre-translation and post-translation interfaces are based on different programming languages, the test results for the programming language project in the cross-language translation scenario can be obtained by comparing and analyzing the replay traffic of the two interfaces. In the same-language translation scenario, interface traffic of the pre-modification interface can be recorded and replayed to the post-modification interface. Then, the test results for the programming language project in the same-language modification scenario can be obtained by comparing and analyzing the recorded traffic of the pre-modification interface and the replay traffic of the post-modification interface. Therefore, this technical solution achieves programming language project testing through real traffic recording and playback. Compared with traditional programming language project testing methods based on a single code comparison tool, it can achieve more accurate programming language project testing, thereby effectively ensuring the consistency of functional logic before and after the modification of the programming language project.

[0117] In one embodiment of this application, the first test module 2 described above can be specifically used to obtain first configuration information of the production environment; determine whether the recording and playback function is enabled based on the first configuration information; when the recording and playback function is enabled, load the recording function component recording interface traffic in the production environment to obtain the first recording traffic.

[0118] In one embodiment of this application, the first test module 2 described above can be specifically used to determine the entry API of the production environment; to record traffic and sub-traffic of the entry API to obtain the first recorded traffic; wherein, the entry API sub-traffic includes communication traffic and / or storage traffic.

[0119] In one embodiment of this application, the first test module 2 described above may be specifically used to obtain second configuration information of the test environment; determine a coloring plan based on the second configuration information; the coloring plan includes recording interface information and / or interface traffic recording ratio; and record interface traffic in the production environment according to the coloring plan to obtain the first recorded traffic.

[0120] In one embodiment of this application, the second test module 3 described above can be specifically used to obtain interface configuration information and determine the interface traffic recording ratio based on the interface configuration information; record interface traffic on the interface before modification according to the interface traffic recording ratio to obtain the second recorded traffic.

[0121] In one embodiment of this application, the first test module 2 can be specifically used to determine that the test result of the target programming language project in the cross-language scenario is a pass when the first replay traffic is consistent with the second replay traffic; and to determine that the test result of the target programming language project in the cross-language scenario is a fail when the first replay traffic is inconsistent with the second replay traffic.

[0122] In one embodiment of this application, it may further include an output device for generating a flow comparison report based on the first playback flow and the second playback flow when the test result is that the test fails; and outputting the flow comparison report.

[0123] For a description of the apparatus provided in the embodiments of this application, please refer to the above method embodiments; further details will not be repeated here.

[0124] This application provides an electronic device.

[0125] Please refer to Figure 3 , Figure 3 This application provides a schematic diagram of the structure of an electronic device, which may include:

[0126] Memory 11 is used to store computer programs;

[0127] The processor 10 is configured to execute computer programs and implement the steps of any of the programming language project testing methods described above.

[0128] like Figure 3 The diagram shows the structural composition of an electronic device, which may include a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, memory 11, and communication interface 12 all communicate with each other through the communication bus 13.

[0129] In this embodiment, the processor 10 may be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic devices.

[0130] The processor 10 can call programs stored in the memory 11. Specifically, the processor 10 can execute operations in the embodiments of the programming language project testing method.

[0131] The memory 11 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment, the memory 11 stores at least a program for implementing the following functions:

[0132] Determine the test scenario for the target programming language project; when the test scenario is a cross-language scenario, record interface traffic in the production environment to obtain the first recorded traffic; replay the first recorded traffic in the pre-translation and post-translation interfaces in the test environment to obtain the first replay traffic and the second replay traffic; determine the test results of the target programming language project in the cross-language scenario based on the first and second replay traffic; when the test scenario is a same-language scenario, record interface traffic for the pre-modification interface to obtain the second recorded traffic; replay the second recorded traffic in the post-modification interface to obtain the third replay traffic; determine the test results of the target programming language project in the same-language scenario based on the second recorded traffic and the third replay traffic.

[0133] In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0134] In addition, memory 11 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.

[0135] Communication interface 12 can be an interface for the communication module, used to connect with other devices or systems.

[0136] Of course, it should be noted that, Figure 3 The structure shown does not constitute a limitation on the electronic device in the embodiments of this application. In practical applications, the electronic device may include more than Figure 3 More or fewer components as shown, or combinations of certain components.

[0137] This application provides a computer-readable storage medium.

[0138] The computer-readable storage medium provided in this application embodiment stores a computer program, which, when executed by a processor, can implement the steps of any of the programming language project testing methods described above.

[0139] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0140] For a description of the computer-readable storage medium provided in this application, please refer to the above method embodiments; further details will not be repeated here.

[0141] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0142] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0143] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0144] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the methods and core ideas of this application. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for testing programming language projects, characterized in that, include: Determine the test scenarios for the target programming language project; When the test scenario is a cross-language scenario, the interface traffic is recorded in the production environment to obtain the first recorded traffic. The first recorded traffic was replayed in the pre-translation interface and post-translation interface in the test environment to obtain the first playback traffic and the second playback traffic. The test results of the target programming language project in the cross-language scenario are determined based on the first replay traffic and the second replay traffic. When the test scenario is a same language scenario, the interface traffic is recorded for the interface before modification to obtain the second recorded traffic; After modifying the interface, the second recorded traffic is replayed to obtain the third replayed traffic; The test results of the target programming language project in the same language scenario are determined based on the second recording traffic and the third playback traffic.

2. The programming language project testing method according to claim 1, characterized in that, Record interface traffic in the production environment to obtain the first recorded traffic, including: Obtain the first configuration information of the production environment; Determine whether the recording and playback function is enabled based on the first configuration information; When the recording and playback function is enabled, the recording function component is loaded in the production environment to record the interface traffic, thereby obtaining the first recorded traffic.

3. The programming language project testing method according to claim 1, characterized in that, Record interface traffic in the production environment to obtain the first recorded traffic, including: Determine the entry API for the production environment; The first recorded traffic is obtained by recording traffic and sub-traffic on the ingress API. The ingress API sub-traffic includes communication traffic and / or storage traffic.

4. The programming language project testing method according to claim 1, characterized in that, Record interface traffic in the production environment to obtain the first recorded traffic, including: Obtain the second configuration information of the test environment; A coloring plan is determined based on the second configuration information; the coloring plan includes recording interface information and / or the interface traffic recording ratio. The interface traffic is recorded in the production environment according to the dyeing plan to obtain the first recorded traffic.

5. The programming language project testing method according to claim 1, characterized in that, Record the interface traffic before modification to obtain the second recorded traffic, including: Obtain the interface configuration information and determine the interface traffic recording ratio based on the interface configuration information; The interface traffic before modification is recorded according to the interface traffic recording ratio to obtain the second recorded traffic.

6. The programming language project testing method according to claim 1, characterized in that, Determining the test results of the target programming language project in the cross-language scenario based on the first replay traffic and the second replay traffic includes: When the first replay traffic matches the second replay traffic, the test result of the target programming language project in the cross-language scenario is determined to be a successful test. When the first playback traffic is inconsistent with the second playback traffic, the test result of the target programming language project in the cross-language scenario is determined to be a test failure.

7. The programming language project testing method according to claim 6, characterized in that, Also includes: When the test result is that the test fails, a traffic comparison report is generated based on the first replay traffic and the second replay traffic. Output the traffic comparison report.

8. A programming language project testing device, characterized in that, include: The determination module is used to determine the test scenarios for the target programming language project; The first test module is used to record interface traffic in a production environment to obtain the first recorded traffic when the test scenario is a cross-language scenario. The first recorded traffic was replayed in the pre-translation interface and post-translation interface in the test environment to obtain the first playback traffic and the second playback traffic. The test results of the target programming language project in the cross-language scenario are determined based on the first replay traffic and the second replay traffic. The second testing module is used to record the interface traffic of the interface before modification when the test scenario is a same language scenario, and obtain the second recorded traffic. After modifying the interface, the second recorded traffic is replayed to obtain the third replayed traffic; The test results of the target programming language project in the same language scenario are determined based on the second recording traffic and the third playback traffic.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the programming language project testing method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the programming language project testing method as described in any one of claims 1 to 7.