Test method and device

By obtaining online requests from the production environment and testing them in the pre-release environment and test environment, comparing the test results to obtain uncovered code, and building test cases to optimize the test environment, the test cases in the existing technology are not comprehensive enough and the code is solved. Solve the problem of low coverage and improve testing efficiency and accuracy.

CN119357040APending Publication Date: 2025-01-24BEIJING JINGDONG QIANSHITECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310890172.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-19
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

The test cases in the test environment in the prior art are not comprehensive enough and the code coverage is low, resulting in low testing efficiency and accuracy, requiring a lot of manual verification.

Method used

By obtaining online requests from the production environment, copying the test request, and testing through the pre -issuing environment and the test environment, the test results are compared to obtain the unscrumable code, and the test environment is optimized according to the unscrusable code constructing test cases.

Benefits of technology

It improves the comprehensiveness and code coverage of test cases in the test environment, reduces the need for manual verification, and improves testing efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357040A_ABST
    Figure CN119357040A_ABST
Patent Text Reader

Abstract

The invention discloses a test method and device, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: acquiring an online request from a production environment, and copying the online request to generate a test request; according to the test request, testing is carried out through a pre-sending environment and a test environment, and a pre-sending environment test result and a test environment test result are obtained; comparing the pre-sent environment test result with the test environment test result to obtain an uncovered code; and constructing a test case according to the uncovered codes to optimize a test environment, and performing testing through the optimized test environment. According to the embodiment, testing is carried out through the pre-sending environment and the testing environment, the pre-sending environment testing result and the testing environment testing result are compared to obtain the uncovered code, the testing case is constructed to optimize the testing environment, the comprehensiveness of the testing case in the testing environment can be improved, the code coverage rate is increased, a large amount of manual verification during testing is avoided, and the testing efficiency is improved. And the test efficiency and the test accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a testing method and device. Background Art

[0002] Before the developed software code is put into production, it needs to be tested in advance. The current testing scheme is to construct test cases according to business scenarios, build a test environment through test cases, and use the test environment for testing.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] The test cases in the test environment are not comprehensive enough, the code coverage is low, and a lot of manual verification is required during testing, resulting in low test efficiency and accuracy. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a testing method and device, which performs testing in a pre-development environment and a test environment, compares the test results of the pre-development environment and the test environment to obtain uncovered code, and constructs test cases based on the uncovered code to optimize the test environment. This can improve the comprehensiveness of test cases in the test environment, improve code coverage, avoid a large amount of manual verification during testing, and improve test efficiency and test accuracy.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a testing method is provided.

[0007] A testing method comprises: obtaining an online request from a production environment, and duplicating the online request to generate a test request; performing a test through a pre-release environment and a test environment respectively according to the test request to obtain a pre-release environment test result and a test environment test result; comparing the pre-release environment test result with the test environment test result to obtain uncovered code; constructing a test case according to the uncovered code to optimize the test environment, and performing a test through the optimized test environment.

[0008] Optionally, obtaining an online request from a production environment and duplicating the online request to generate a test request includes: using a proxy recording device to generate the test request by recording the request in the production environment in real time.

[0009] Optionally, the pre-launch environment is generated in the following manner: according to the production environment, an offline environment corresponding to the production environment is constructed, and the offline environment is used as the pre-launch environment.

[0010] Optionally, according to the test request, testing is performed through a pre-release environment and a test environment respectively to obtain a pre-release environment test result and a test environment test result, including: according to the test request, performing a code coverage test on the pre-release environment through a code coverage tool, and using the code coverage test result of the pre-release environment as the pre-release environment test result; according to the test request, performing a code coverage test on the test environment through a code coverage tool, and using the code coverage test result of the test environment as the test environment test result.

[0011] Optionally, comparing the pre-launch environment test results with the test environment test results to obtain uncovered code includes: comparing the pre-launch environment test results with the test environment test results; and taking the code that is covered in the pre-launch environment test results and not covered in the test environment test results as the uncovered code.

[0012] Optionally, constructing test cases according to the uncovered code to optimize the test environment includes: constructing corresponding test cases according to the uncovered code, and adding the test cases to the test environment to optimize the test environment.

[0013] Optionally, after constructing the test case according to the uncovered code to optimize the test environment, it also includes: based on the test request, re-testing the optimized test environment to generate test results of the optimized test environment; verifying the test case according to the test results of the optimized test environment and the uncovered code.

[0014] According to another aspect of an embodiment of the present invention, a testing device is provided.

[0015] A testing device includes: a test request generation module, which is used to obtain online requests from a production environment, and copy the online requests to generate test requests; a test result generation module, which is used to test through a pre-release environment and a test environment respectively according to the test request, and obtain a pre-release environment test result and a test environment test result; an uncovered code generation module, which is used to compare the pre-release environment test result with the test environment test result to obtain uncovered code; and a test environment optimization module, which is used to construct test cases according to the uncovered code to optimize the test environment, and perform testing through the optimized test environment.

[0016] Optionally, the test request generating module is further used to: generate the test request by using a proxy recording device to record the request in the production environment in real time.

[0017] Optionally, it also includes a pre-launch environment generation module, which is used to: construct an offline environment corresponding to the production environment according to the production environment, and use the offline environment as the pre-launch environment.

[0018] Optionally, the test result generation module is also used to: according to the test request, perform code coverage test on the pre-release environment through a code coverage tool, and use the code coverage test result of the pre-release environment as the pre-release environment test result; according to the test request, perform code coverage test on the test environment through a code coverage tool, and use the code coverage test result of the test environment as the test environment test result.

[0019] Optionally, the uncovered code generation module is further used to: compare the pre-release environment test results and the test environment test results; and use the code that is covered in the pre-release environment test results and not covered in the test environment test results as the uncovered code.

[0020] Optionally, the test environment optimization module is further used to: construct corresponding test cases according to the uncovered code, and add the test cases to the test environment to optimize the test environment.

[0021] Optionally, the test environment optimization module is also used to: retest the optimized test environment based on the test request to generate test results of the optimized test environment; and verify the test case according to the test results of the optimized test environment and the uncovered code.

[0022] According to yet another aspect of the embodiments of the present invention, an electronic device is provided.

[0023] An electronic device includes: one or more processors; and a memory for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the test method provided by an embodiment of the present invention.

[0024] According to yet another aspect of an embodiment of the present invention, a computer readable medium is provided.

[0025] A computer readable medium stores a computer program, and when the computer program is executed by a processor, the test method provided by an embodiment of the present invention is implemented.

[0026] An embodiment of the above invention has the following advantages or beneficial effects: by obtaining online requests from the production environment and copying the online requests to generate test requests; according to the test requests, testing is performed through the pre-release environment and the test environment respectively to obtain the pre-release environment test results and the test environment test results; the pre-release environment test results and the test environment test results are compared to obtain uncovered code; a technical solution of constructing test cases according to the uncovered code to optimize the test environment, and testing through the optimized test environment, testing is performed through the pre-release environment and the test environment, and the pre-release environment test results and the test environment test results are compared to obtain uncovered code, and test cases are constructed according to the uncovered code to optimize the test environment, which can improve the comprehensiveness of test cases in the test environment, improve code coverage, avoid a large amount of manual verification during testing, and improve test efficiency and test accuracy.

[0027] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0029] Figure 1 is a schematic diagram of the main steps of a testing method according to an embodiment of the present invention;

[0030] Figure 2 is a flow chart of a testing method according to an embodiment of the present invention;

[0031] Figure 3 is a schematic diagram of main modules of a testing device according to an embodiment of the present invention;

[0032] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0035] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of the present invention are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0036] The current testing plan is to construct test cases based on business scenarios, build a test environment through test cases, and use the test environment for testing. However, the core application business scenarios are complex, and testers are unfamiliar with older businesses. It is difficult for testers to construct test scenarios, resulting in incomplete automated test cases for existing business logic codes and low code coverage. The testing process before going online requires a lot of manual verification.

[0037] The present invention is based on obtaining test requests through real-time or offline diversion of online requests, relying on comparing the test results of the pre-release environment with the test results of the test environment, filtering and screening the real business scenarios of the code not covered by the test environment, so as to construct automated test cases, improve the coverage of core application codes, and thus improve the stability and high availability of the business system.

[0038] Figure 1 It is a schematic diagram of main steps of a testing method according to an embodiment of the present invention.

[0039] like Figure 1 As shown, the testing method of one embodiment of the present invention mainly includes the following steps S101 to S104.

[0040] Step S101: obtain an online request from a production environment, and copy the online request to generate a test request.

[0041] In one embodiment, obtaining online requests from a production environment and duplicating the online requests to generate test requests may include: using a proxy recording device to generate test requests by recording requests in the production environment in real time.

[0042] Specifically, a proxy recording device can be used to record all requests in the production environment within a preset time period to obtain a test request, or to directly forward the online request in the production environment as a test request to the pre-release environment and the test environment. Among them, the proxy recording device may include a recorder Recorder, a buffer Buffer, and a reporter Reporter. The recorder Recorder can intercept online requests in the production environment based on the responsibility chain model. In the responsibility chain model, multiple processors can process the same online request in sequence. An online request is first processed by processor A, and then the online request is passed to processor B, and so on, forming a chain. Each processor in the chain assumes its own processing responsibility. For example, processor A can be used to record online requests, and processor B can be used to process online requests in the production environment; the buffer Buffer can provide a temporary storage function for requests, which is implemented by a small bounded queue internally; the reporter Reporter can asynchronously report the requests in the buffer area to the receiver, thereby obtaining real-time recorded requests.

[0043] Step S102: According to the test request, the pre-release environment and the test environment are tested respectively to obtain the pre-release environment test result and the test environment test result.

[0044] In one embodiment, the pre-launch environment may be generated in the following manner: according to the production environment, an offline environment corresponding to the production environment is constructed, and the offline environment is used as the pre-launch environment.

[0045] Specifically, according to the production environment, an offline environment can be constructed by duplicating the production environment, or when there are multiple production environment backups, one production environment backup can be selected for offline processing to obtain an offline environment.

[0046] In one embodiment, according to the test request, testing is performed through the pre-release environment and the test environment respectively to obtain the pre-release environment test results and the test environment test results, which may include: according to the test request, performing code coverage testing on the pre-release environment through a code coverage tool, and using the code coverage test results of the pre-release environment as the pre-release environment test results; according to the test request, performing code coverage testing on the test environment through a code coverage tool, and using the code coverage test results of the test environment as the test environment test results.

[0047] Code coverage testing refers to the percentage of code covered by test cases through manual testing and automated testing using a test automation framework. Code coverage tools can be Coverage.py (a code coverage tool for Python), Serenity BDD (a code coverage tool that supports Java and Groovy programming languages), JaCoCo (a code coverage tool for Java), JCov (a test framework agnostic code coverage tool), etc. Before code coverage testing, the code coverage tool is deployed to the environment to be tested in an instrumented mode.

[0048] In another embodiment, the test environment test result may be obtained by pre-executing an existing test case in the test environment, the existing test case may be an automated test case, and the pre-launch environment test result is obtained by executing a test request in the pre-launch environment.

[0049] In one embodiment, before testing through the pre-release environment and the test environment respectively, the test requests can be screened according to the business scenario, and the test can be performed through the pre-release environment and the test environment according to the screened test requests, so as to optimize the test environment according to the business scenario and improve the efficiency of the test environment optimization.

[0050] Step S103: Compare the pre-release environment test results with the test environment test results to obtain uncovered code.

[0051] In one embodiment, comparing the pre-launch environment test results with the test environment test results to obtain uncovered code may include: comparing the pre-launch environment test results with the test environment test results; and treating the code that is covered in the pre-launch environment test results and not covered in the test environment test results as uncovered code.

[0052] Specifically, the pre-release environment test results and the test environment test results can be compared through the diff (same-layer comparison) algorithm to determine the code that is covered in the pre-release environment test results but not covered in the test environment test results, and use it as uncovered code. Therefore, based on the uncovered code, it is possible to determine the test cases that need to be supplemented in the test environment compared with the online production environment.

[0053] Step S104: construct test cases according to the uncovered code to optimize the test environment, and perform testing through the optimized test environment.

[0054] In one embodiment, constructing test cases according to uncovered code to optimize the test environment may include: constructing corresponding test cases according to the uncovered code, and adding the test cases to the test environment to optimize the test environment.

[0055] Specifically, the uncovered code can be screened based on the business scenario to obtain the uncovered code corresponding to the business scenario, construct test cases according to the uncovered code corresponding to the business scenario, and add the constructed test cases to the test environment.

[0056] In one embodiment, after constructing test cases based on uncovered code to optimize the test environment, it can also include: based on the test request, re-testing the optimized test environment to generate test results for the optimized test environment; and verifying the test cases based on the test results of the optimized test environment and the uncovered code.

[0057] Specifically, it is determined whether the uncovered code is covered in the test results of the optimized test environment. If the uncovered code is covered in the test results of the optimized test environment, the test case verification passes, indicating that the test environment optimization is successful.

[0058] Figure 2 It is a flowchart of a testing method according to an embodiment of the present invention.

[0059] like Figure 2 As shown, in one embodiment, a corresponding offline environment is constructed according to the production environment as a pre-release environment, online requests are obtained from the production environment, the online requests are copied, and test requests are generated. The test requests are used to perform tests through the pre-release environment and the test environment, and the pre-release environment test results and the test environment test results are obtained. The uncovered code is obtained, and test cases are constructed according to the uncovered code to optimize the test environment.

[0060] The embodiment of the present invention forwards real online requests to a pre-release environment and a test environment, relies on coverage results for comparison, improves automated test cases, increases the coverage of core applications, and optimizes the test environment.

[0061] Figure 3 4 is a schematic diagram of main modules of a testing device according to an embodiment of the present invention.

[0062] like Figure 3 As shown, a testing device 300 according to an embodiment of the present invention mainly includes: a test request generating module 301 , a test result generating module 302 , an uncovered code generating module 303 , and a test environment optimizing module 304 .

[0063] The test request generation module 301 is used to obtain online requests from the production environment, and copy the online requests to generate test requests.

[0064] The test result generating module 302 is used to perform tests in the pre-release environment and the test environment respectively according to the test request, and obtain the pre-release environment test result and the test environment test result.

[0065] The uncovered code generating module 303 is used to compare the pre-release environment test results with the test environment test results to obtain the uncovered code.

[0066] The test environment optimization module 304 is used to construct test cases according to uncovered codes to optimize the test environment, and perform testing through the optimized test environment.

[0067] In one embodiment, the test request generating module 301 is specifically used to generate a test request by using a proxy recording device to record requests in a production environment in real time.

[0068] In one embodiment, a pre-launch environment generation module (not shown in the figure) may also be included, which is used to: construct an offline environment corresponding to the production environment according to the production environment, and use the offline environment as the pre-launch environment.

[0069] In one embodiment, the test result generation module 302 is specifically used to: perform code coverage testing on the pre-release environment through a code coverage tool according to a test request, and use the code coverage test results of the pre-release environment as the pre-release environment test results; perform code coverage testing on the test environment through a code coverage tool according to a test request, and use the code coverage test results of the test environment as the test environment test results.

[0070] In one embodiment, the uncovered code generation module 303 is specifically used to: compare the pre-release environment test results and the test environment test results; and treat the code that is covered in the pre-release environment test results and not covered in the test environment test results as uncovered code.

[0071] In one embodiment, the test environment optimization module 304 is specifically used to construct corresponding test cases according to the uncovered code, and add the test cases to the test environment to optimize the test environment.

[0072] In one embodiment, the test environment optimization module 304 is specifically used to: retest the optimized test environment based on the test request to generate the test results of the optimized test environment; and verify the test cases according to the test results of the optimized test environment and the uncovered code.

[0073] In addition, the specific implementation content of the testing device in the embodiment of the present invention has been described in detail in the above testing method, so the repeated content will not be described again here.

[0074] Figure 4 An exemplary system architecture 400 is shown to which a testing method or a testing device according to an embodiment of the present invention can be applied.

[0075] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0076] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as test applications, test case applications, test environment applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0077] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0078] Server 405 may be a server that provides various services, such as a background management server (only an example) that provides support for test websites browsed by users using terminal devices 401, 402, and 403. The background management server may obtain online requests from the production environment for the received test requests and other data, and copy the online requests to generate test requests; according to the test requests, respectively test through the pre-release environment and the test environment to obtain the pre-release environment test results and the test environment test results; compare the pre-release environment test results and the test environment test results to obtain uncovered code; construct test cases based on the uncovered code to optimize the test environment, and perform testing and other processing through the optimized test environment, and feed back the processing results (such as test results - only an example) to the terminal device.

[0079] It should be noted that the testing method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the testing device is generally disposed in the server 405 .

[0080] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0081] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0082] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0083] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0084] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

[0085] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0086] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0087] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, they may be described as: a processor including a test request generation module, a test result generation module, an uncovered code generation module, and a test environment optimization module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the test request generation module may also be described as "a module for obtaining online requests from a production environment, copying the online requests, and generating test requests."

[0088] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining online requests from the production environment, and copying the online requests to generate test requests; according to the test requests, testing is performed through the pre-release environment and the test environment respectively to obtain the pre-release environment test results and the test environment test results; the pre-release environment test results and the test environment test results are compared to obtain uncovered code; test cases are constructed according to the uncovered code to optimize the test environment, and the optimized test environment is used for testing.

[0089] According to the technical solution of the embodiment of the present invention, an online request is obtained from a production environment, and the online request is copied to generate a test request; according to the test request, the pre-launch environment and the test environment are tested respectively to obtain the pre-launch environment test result and the test environment test result; the pre-launch environment test result and the test environment test result are compared to obtain uncovered code; a test case is constructed based on the uncovered code to optimize the test environment, and the test is conducted through the optimized test environment. Testing is conducted through the pre-launch environment and the test environment, and the pre-launch environment test result and the test environment test result are compared to obtain uncovered code, and test cases are constructed based on the uncovered code to optimize the test environment, which can improve the comprehensiveness of the test cases in the test environment, improve code coverage, avoid a large amount of manual verification during testing, and improve test efficiency and test accuracy.

[0090] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A testing method, characterized in that: include: Obtain online requests from the production environment, and copy the online requests to generate test requests; According to the test request, testing is performed in a pre-release environment and a test environment respectively to obtain a pre-release environment test result and a test environment test result; Compare the pre-release environment test result with the test environment test result to obtain uncovered code; Test cases are constructed according to the uncovered code to optimize the test environment, and testing is performed using the optimized test environment.

2. The method according to claim 1, characterized in that The step of obtaining an online request from a production environment and duplicating the online request to generate a test request includes: The test request is generated by using a proxy recording device by recording the request in the production environment in real time.

3. The method according to claim 1, characterized in that The pre-release environment is generated in the following way: According to the production environment, an offline environment corresponding to the production environment is constructed, and the offline environment is used as the pre-release environment.

4. The method according to claim 1, characterized in that: The step of performing the test in the pre-release environment and the test environment respectively according to the test request to obtain the pre-release environment test result and the test environment test result includes: According to the test request, a code coverage test is performed on the pre-release environment by using a code coverage tool, and a code coverage test result of the pre-release environment is used as a test result of the pre-release environment; According to the test request, a code coverage test is performed on the test environment by using a code coverage tool, and a code coverage test result of the test environment is used as the test environment test result.

5. The method according to claim 4, characterized in that The comparing the pre-release environment test result with the test environment test result to obtain uncovered code includes: Comparing the pre-release environment test result with the test environment test result; The code that is covered in the pre-release environment test result and not covered in the test environment test result is referred to as the uncovered code.

6. The method according to claim 1, characterized in that The step of constructing a test case according to the uncovered code to optimize the test environment includes: According to the uncovered code, corresponding test cases are constructed, and the test cases are added to the test environment to optimize the test environment.

7. The method according to claim 6, characterized in that After constructing the test cases according to the uncovered code to optimize the test environment, the method further includes: Based on the test request, retest the optimized test environment to generate a test result of the optimized test environment; The test case is verified according to the test results of the optimized test environment and the uncovered code.

8. A testing device, characterized in that: include: A test request generation module is used to obtain online requests from the production environment, and copy the online requests to generate test requests; A test result generating module, used to perform tests in a pre-release environment and a test environment respectively according to the test request, and obtain a pre-release environment test result and a test environment test result; An uncovered code generation module, used for comparing the pre-release environment test result with the test environment test result to obtain uncovered code; The test environment optimization module is used to construct test cases according to the uncovered code to optimize the test environment, and perform testing through the optimized test environment.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.