Software testing method and device, computer equipment, storage medium and program product
By using the mapping diagnostic context structure and the ASM framework for non-invasive time adjustment during software testing, the database confusion problem caused by directly modifying the server time is solved, efficient and accurate dynamic time adjustment is achieved, and testing efficiency and server stability are improved.
Patent Information
- Application Number
- CN202510869053.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-10-28
AI Technical Summary
The existing technology simulates different time scenarios by directly modifying the server system time, which leads to database transaction timestamp confusion and data consistency issues. Frequent time modification and recovery operations are time-consuming and labor-intensive, and cannot meet the requirements for flexible and rapid time adjustment during the testing process.
A non-intrusive approach is adopted to store time adjustment parameters by mapping the diagnostic context structure (MDC). These parameters and the current time are called during the test execution phase to determine the target test time. The ASM framework is used to perform bytecode insertion on the time acquisition method to dynamically adjust the test time.
It achieves non-intrusive time adjustment, avoids the impact on the normal business of the server, improves test efficiency and accuracy, and ensures the stability of the server and the accuracy of the data.
Smart Images

Figure CN120849271A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and in particular to a software testing method, apparatus, computer equipment, storage medium, and program product. Background Technology
[0002] In the field of software testing, testing time-related functions is a crucial step in ensuring the accuracy and reliability of a system. In the testing of accounting platforms, time is a key element that permeates all stages, including fund transactions, account settlement, and report generation. Directly modifying the time has multi-dimensional and complex impacts on testing, posing significant challenges to the accuracy and stability of the tests.
[0003] Currently, directly modifying the server system time is a common method to simulate different time scenarios. From a system stability perspective, directly modifying the server system time is an intrusive operation. The server runs many complex business processes, and directly modifying the time may cause database transaction timestamps to become disordered, leading to data consistency issues. It may also cause anomalies in services that depend on time order, such as message queue processing order disorder, scheduled task execution errors, and in severe cases, even cause the entire service to crash. Summary of the Invention
[0004] Therefore, it is necessary to provide a non-intrusive, efficient software testing method, apparatus, computer equipment, storage medium, and program product that can dynamically modify the current time acquisition method to address the above-mentioned technical problems.
[0005] Firstly, this application provides a software testing method, including:
[0006] Read time adjustment parameters from the software test request and store the time adjustment parameters in the mapping diagnostic context structure;
[0007] During the test execution phase, the time adjustment parameters are invoked from the mapping diagnostic context structure, and a target test time is determined based on the time adjustment parameters and the current time. Relevant tests are then executed according to the target test time.
[0008] In one embodiment, reading time adjustment parameters from a software test request and storing the time adjustment parameters in a mapping diagnostic context structure includes:
[0009] Intercept software testing requests;
[0010] Extract the time adjustment parameters from the preset byte region of the software test request;
[0011] If the format of the time adjustment parameter passes the validation, the time adjustment parameter is stored in the mapping diagnostic context structure.
[0012] In one embodiment, during the test execution phase, the method further includes:
[0013] Determine the type of operation to be performed;
[0014] When the operation to be executed is to obtain the test time, the operation to be executed is subjected to preset interpolation processing. The preset interpolation processing is used to enable the operation to be executed to call the time adjustment parameter from the mapping diagnostic context structure during the execution process, and to determine the target test time based on the time adjustment parameter and the current time.
[0015] In one embodiment, the time adjustment parameters include an adjustment method, an adjustment amount, and an adjustment unit; determining the target test time based on the time adjustment parameters and the current time includes:
[0016] The portion of the current time to be adjusted is determined based on the adjustment unit.
[0017] The portion to be adjusted is corrected according to the adjustment method and the adjustment amount to obtain the target test time.
[0018] In one embodiment, the time adjustment parameter further includes an adjustment time type, wherein the adjustment time type includes at least one of current time, historical time, and predicted time;
[0019] Determining the target test time based on the time adjustment parameters and the current time includes:
[0020] The time to be adjusted is determined according to the adjustment time type.
[0021] The portion of the time to be adjusted is determined based on the adjustment unit.
[0022] The portion to be adjusted is corrected according to the adjustment method and the adjustment amount to obtain the target test time.
[0023] In one embodiment, the method further comprises:
[0024] If it is determined that the software test request is in an execution completed state, the time adjustment parameter stored in the mapping diagnostic context structure is deleted.
[0025] Secondly, this application also provides a software testing apparatus, comprising:
[0026] A parameter storage module is used to read time adjustment parameters from software test requests and store the time adjustment parameters in a mapping diagnostic context structure;
[0027] The test execution module is used to, during the test execution phase, call the time adjustment parameters from the mapping diagnostic context structure, determine the target test time based on the time adjustment parameters and the current time, and execute relevant tests according to the target test time.
[0028] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the software testing method described in the first aspect.
[0029] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the software testing method described in the first aspect.
[0030] Fifthly, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the software testing method described in the first aspect.
[0031] In summary, this application proposes a software testing method, apparatus, computer device, storage medium, and program product, comprising: reading time adjustment parameters from a software test request and storing the time adjustment parameters in a mapping diagnostic context structure; during the test execution phase, calling the time adjustment parameters from the mapping diagnostic context structure, determining a target test time based on the time adjustment parameters and the current time, and executing relevant tests according to the target test time. The software testing method provided in this embodiment adopts a non-intrusive method to modify the way the target test time is obtained during software testing. It achieves dynamic time adjustment through a mapping diagnostic context structure, without needing to modify the server system time, avoiding business anomalies caused by intrusive operations, effectively improving testing efficiency and accuracy, and ensuring stable server operation. Attached Figure Description
[0032] Figure 1 This is a diagram illustrating the application environment of a software testing method in one embodiment;
[0033] Figure 2 This is a flowchart illustrating a software testing method in one embodiment;
[0034] Figure 3 This is a flowchart illustrating the steps for obtaining time adjustment parameters in one embodiment;
[0035] Figure 4 This is a flowchart illustrating a software testing method in another embodiment;
[0036] Figure 5 This is a flowchart illustrating the steps for determining the target test time in one embodiment;
[0037] Figure 6 This is a flowchart illustrating the steps for determining the target test time in another embodiment;
[0038] Figure 7 This is a structural block diagram of a software testing apparatus in one embodiment;
[0039] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0041] In related technologies, software testing related to the current time is a crucial step in ensuring the system functions correctly under different time scenarios. For example, software testing of a financial system related to the current time includes time zone testing, cross-date testing, time accuracy testing, and time format compatibility testing. Obtaining the test time is a critical step affecting the accuracy and reliability of the software testing process.
[0042] In related technologies, directly modifying the server time to simulate different time scenarios can easily lead to database transaction timestamp errors, causing a series of data consistency issues. In practice, each server time modification must strictly follow a specific process, and the time must be accurately restored after testing; otherwise, online business will be affected. When multiple test scenarios are involved, frequent time modification and restoration operations are not only time-consuming and labor-intensive, but also highly susceptible to time inconsistencies due to human error. Therefore, in related technologies, the methods used to obtain test time in software testing solutions cannot meet the need for flexible and rapid time adjustments during testing.
[0043] The software testing method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0044] In one embodiment, Figure 2 As shown, a software testing method is provided, which is applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps:
[0045] S201, reads the time adjustment parameters from the software test request and stores the time adjustment parameters in the mapping diagnostic context structure.
[0046] S202, during the test execution phase, the time adjustment parameter is called from the mapping diagnostic context structure, and the target test time is determined based on the time adjustment parameter and the current time. The relevant tests are then executed according to the target test time.
[0047] In this embodiment, a software test request refers to a request for a series of test cases for the system under test. It should be noted that this embodiment does not limit the specific content of the software test request; the type of software test request can be configured according to the needs of the actual application scenario. In this embodiment, the software test request includes operations to be executed related to obtaining the target test time.
[0048] In this embodiment, the target test time refers to the time value set to execute the current software test request. For example, the target test time is the current time value set by the user, which is not the same as the actual current time. If the actual current time is 12:00 and the target test time is 12:30, then when executing the software test request, the current time in the pending operation corresponding to that software test request is 12:30.
[0049] In this embodiment, the time adjustment parameter refers to the parameter used to adjust the current time. The current time in this embodiment defaults to the actual current time, which refers to the standard time at the current location of the terminal. In this embodiment, the time adjustment parameter can be added to various software test requests according to a preset format, so that the test end (e.g., server or web page) can extract it from the software test request when executing it.
[0050] In this embodiment, the Mapping Diagnostic Context (MDC) structure is a thread-local mapping table structure. In this embodiment, the MDC structure can be understood as an "information relay station" in the dynamic time adjustment method of software testing, responsible for storing and transmitting time adjustment parameters. When the server receives a test request from the front end carrying time adjustment parameters, it stores these parameters in the MDC structure. Because the MDC structure is closely associated with threads, different modules and methods can quickly and safely retrieve time adjustment parameters from the MDC structure at any time during the entire request processing process.
[0051] In this embodiment, the test execution phase refers to the process of completing the relevant pending operations indicated by the software test request. During the test execution phase, it is ensured that after bytecode interpolation of the time acquisition method, when the program calls the relevant methods, the current time can be accurately adjusted according to the time adjustment parameters stored in the MDC. This ensures the continuity and accuracy of the dynamic time adjustment process throughout the entire test execution phase, achieving non-intrusive time adjustment. During each pending operation of the software test request, the target test time is determined based on the time adjustment parameters and the current time, as indicated in step S202, and the relevant tests are executed according to the target test time.
[0052] In this embodiment, bytecode insertion operations can be implemented using the ASM framework. For example, first, a custom `ClassFileTransformer` implementation class is created, which implements the `java.lang.instrument.ClassFileTransformer` interface and overrides the `transform` method. Within the `transform` method, the bytecode data of the target class is read using ASM's `ClassReader`, and then new bytecode data is created using `ClassWriter`. Here, the target class's bytecode data refers to the timing parameters, and the newly created bytecode data refers to the target test time.
[0053] Based on the above steps, the software testing method provided in this embodiment does not require direct modification of the server's system time, avoiding impact on the server's normal business operations. It is a non-intrusive time adjustment operation that will not interfere with the normal operation of other services on the server, ensuring server stability and data accuracy. This embodiment utilizes the ASM method, which offers good implementability and maintainability. The ASM method is based on a mature bytecode manipulation framework, making it easy for developers to understand and operate, and has lower maintenance costs and better scalability.
[0054] In one embodiment, Figure 3As shown, time adjustment parameters are read from the software test request and stored in the mapping diagnostic context structure, including:
[0055] S301, intercepts software test requests.
[0056] S302, extract time adjustment parameters from the preset byte region of the software test request.
[0057] S303, if the format verification of the time adjustment parameters passes, the time adjustment parameters are stored in the mapping diagnostic context structure.
[0058] In this embodiment, the testing end intercepts software testing requests and extracts time adjustment parameters from the fields of the software testing requests. For example, the browser intercepts the software testing requests as a plugin, where the software testing requests can add custom fields to the HTTP request header to carry time adjustment parameters. It should be noted that the preset byte area in this embodiment can be determined based on the actual structure of the software testing request and the location where the custom fields are added in the actual application scenario. This embodiment does not specifically limit the preset byte area; the setting of the preset byte area can be customized according to the needs of the actual application.
[0059] In practical applications, the field naming of time adjustment parameters stored in the preset byte area follows RFC specifications. For example, the X-Test-Time-Adjust field is defined to indicate the time adjustment parameter. The parameter values of the time adjustment parameter are identified using a uniform format. For example, the symbol "+" indicates an increase in time, and "-" indicates a decrease in time. The number follows the symbol, and the unit uses the international standard time unit abbreviation, such as "d" for day, "h" for hour, "m" for minute, and "s" for second. In an exemplary embodiment, "+2h" means adding 2 hours to the current time, and "-1d" means subtracting 1 day from the current time.
[0060] In this embodiment, steps S301-S303 can be executed by constructing a Web filter using a third-party library. In the filter, when the server receives a test request, it extracts the value of the X-Test-Time-Adjust field from the request header. The valid time is stored in the MDC (Multi-Card Controller). To avoid key name conflicts, a key name with business meaning, "testTimeAdjust," is used. Furthermore, the parameter's format is validated before storage to ensure the correct execution of subsequent time adjustment logic.
[0061] Based on the above steps, by defining the time adjustment parameters in a standardized format, we can ensure that the server can accurately parse the time adjustment intent and avoid parsing errors caused by inconsistent parameter formats.
[0062] In one embodiment, Figure 4 As shown, during the test execution phase, the method also includes:
[0063] S401, Determine the operation type to be performed.
[0064] S402, when the operation to be executed is to obtain the test time, the operation to be executed is subjected to preset code interpolation processing. The preset code interpolation processing is used to enable the operation to be executed to call the time adjustment parameter from the mapping diagnostic context structure during the execution process, and to determine the target test time based on the time adjustment parameter and the current time.
[0065] In this embodiment, determining the operation type of the operation to be executed is mainly used to determine whether the operation to be executed is an operation to obtain the current time. The operation type of the operation to be executed includes the purpose type and parameter type of the operation. The purpose type refers to the intended use of the operation, and the parameter type refers to the parameters involved in the operation.
[0066] In this embodiment, when the operation to be performed is to obtain test time, it is necessary to perform preset code insertion processing on the operation to be performed. The specific execution method of preset code insertion processing can refer to the method of manipulating bytecode using the ASM framework in the previous embodiment.
[0067] In one embodiment, the logic for the preset interpolation code processing is as follows:
[0068] First, determine whether the method that needs to be interpolated is a method for obtaining the current time, such as the parameterless constructor of java / util / Date, or the static method now of the java / time / LocalDateTime class.
[0069] Second, insert the following code before the method for obtaining the current time returns: 1. The static class MDC obtains the time parameter to be adjusted through "testTimeAdjust"; 2. The current time (created by the now method or the Date parameterless constructor) and the time parameter to be adjusted are passed as method parameters to the time adjustment utility class TimeAdjustUtils; 3. Time adjustments are performed in the utility class, and the adjusted target test time is returned to the method that inserted the code.
[0070] Based on the above steps, this embodiment can modify the time adjustment parameters in the software test request, enabling dynamic modification of the current time during the execution of the software test request without modifying the current system time. This achieves non-intrusive time modification, greatly improving the system's testing efficiency, and ensuring the accuracy of the time modification while guaranteeing the stability and reliability of the system data.
[0071] In one embodiment, Figure 5 As shown, the time adjustment parameters include the adjustment method, adjustment amount, and adjustment unit; the target test time is determined based on the time adjustment parameters and the current time, including:
[0072] S501, determine the portion of the current time to be adjusted based on the adjustment unit.
[0073] S502, adjust the part to be adjusted according to the adjustment method and adjustment amount to obtain the target test time.
[0074] In this embodiment, the adjustment methods include increasing and decreasing the time. The adjustment amount includes the specific numerical value of the time adjustment. The adjustment unit includes the scenario of time adjustment, such as year, week, day, hour, minute, second, etc.
[0075] In this embodiment, when modifying the current time according to the time adjustment parameters, the time unit of the current time that needs to be adjusted is first determined, i.e., the part to be adjusted. After determining the time unit, the time value under that time unit is increased or decreased by an actual adjustment value to obtain the target test time.
[0076] Through the above steps, we were able to insert code into the time acquisition method based on the ASM framework without modifying the original business code. The parameters were adjusted according to the time passed from the front end, and the current date and time were dynamically modified, thus meeting the need for flexible time adjustment during software testing.
[0077] In one embodiment, Figure 6 As shown, the time adjustment parameters also include the time type, which includes current time, historical time, and predicted time. In this embodiment, the target test time can be adjusted based on the current time, historical time, or predicted time.
[0078] The target test time is determined based on the time adjustment parameters and the current time, including:
[0079] S601, determine the time to be adjusted according to the adjustment time type.
[0080] S602, determine the portion of the time to be adjusted based on the adjustment unit.
[0081] S603, adjust the part to be adjusted according to the adjustment method and adjustment amount to obtain the target test time.
[0082] In this embodiment, during the process of determining the target test time, time adjustment can be performed based on the system time values of different time types, that is, the specific time type of the time to be adjusted is determined.
[0083] In this embodiment, after determining the time to be adjusted, the implementation method for adjusting the time parameter of the time to be adjusted can refer to the adjustment of the current time in the previous embodiment, and will not be repeated here.
[0084] For example, when the program calls the inserted `LocalDateTime.now()` or `new Date()` method, the inserted code first retrieves the time adjustment parameters from the MDC (Mean Disk Directory). After obtaining the parameters, it passes them to the `TimeAdjustUtils` utility class. The `TimeAdjustUtils` class determines the target time type (`LocalDateTime` or `Date`) based on the time unit and value in the parameters, and then executes the corresponding time calculation logic. For example, for adjusting the time of type `LocalDateTime`, `LocalDateTime.now()` retrieves the current local time, while `new Date()` retrieves the new preset time.
[0085] Based on the above steps, time adjustment parameters can be flexibly set through the front-end interface header according to different testing needs, enabling dynamic modification of the current date and time. This meets the requirements of various complex testing scenarios, improving the flexibility and adaptability of testing. It eliminates the need for tedious manual modification of the server time and allows for quick and convenient time adjustment, significantly improving testing efficiency, shortening the testing cycle, and reducing testing costs.
[0086] In related technologies, from an operational efficiency perspective, each modification to the server time must strictly follow a specific process, and the time must be accurately restored after testing; otherwise, it will affect online business. If multiple test scenarios are involved, frequent time modification and restoration operations are not only time-consuming and labor-intensive, but also highly susceptible to errors due to human negligence, and simply cannot meet the needs for flexible and rapid time adjustment during testing.
[0087] To address the above problems, the software testing method provided in this embodiment further includes:
[0088] Once it is determined that the software test request is in the execution completed state, delete the time adjustment parameters stored in the mapping diagnostic context structure.
[0089] Based on the above steps, this embodiment can delete the time adjustment parameters stored in the mapping diagnostic context structure corresponding to each software test request after completion. This allows for the storage of new time adjustment parameters when receiving other software test requests, ensuring the accuracy and flexibility of software test request execution. Timely deletion of time adjustment parameters stored in the mapping diagnostic context structure when processing software test requests across multiple test scenarios effectively avoids human error, improves efficiency, and reduces manpower consumption.
[0090] In summary, this embodiment provides a software testing method, offering a non-intrusive and dynamically modifiable approach to obtaining the current date and time. This method employs a non-intrusive approach, enabling flexible and precise dynamic adjustment of the obtained current date and time during software testing, based on different testing requirements. Compared to the traditional method of directly modifying the server system time, the software testing method provided in this embodiment effectively avoids problems such as system instability and data corruption caused by intrusive operations, while also solving the drawbacks of cumbersome operations and low efficiency. This method can significantly improve software testing efficiency, ensure the accuracy of test results, and provide a more reliable and efficient time control solution for software testing.
[0091] In a more detailed embodiment, this embodiment provides a time adjustment method for software testing based on a non-intrusive approach, achieving dynamic time modification through collaborative operations between the front-end and the server. When the front-end initiates a test request, it includes time adjustment parameters such as "add one day" in the interface header; after receiving the request, the server stores the parameters in the MDC (Multi-Card Memory). Subsequently, the ASM (Automatic Time Management) framework is used to insert bytecode into the Java critical time acquisition method. When the program calls the inserted time acquisition method, the inserted code reads the parameters from the MDC, accurately adjusts the original time, and returns it. The software testing method provided in this embodiment does not require modification of the server system time, avoiding business anomalies and other problems caused by intrusive operations, effectively improving testing efficiency and accuracy, and ensuring server stability.
[0092] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0093] Based on the same inventive concept, this application also provides a software testing apparatus for implementing the software testing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more software testing apparatus embodiments provided below can be found in the limitations of the software testing method described above, and will not be repeated here.
[0094] In one embodiment, Figure 7 As shown, a software testing apparatus 700 is provided, including: a parameter storage module 710 and a test execution module 720, wherein:
[0095] The parameter storage module 710 is used to read time adjustment parameters from software test requests and store the time adjustment parameters in a mapping diagnostic context structure;
[0096] The test execution module 720 is used to, during the test execution phase, call the time adjustment parameter from the mapping diagnostic context structure, determine the target test time based on the time adjustment parameter and the current time, and execute relevant tests according to the target test time.
[0097] In one embodiment, the parameter storage module 710 is specifically used to intercept software test requests and extract the time adjustment parameters from a preset byte region of the software test request.
[0098] In one embodiment, the test execution module 720 is specifically used to determine the operation type of the operation to be executed; if the operation to be executed is an operation to obtain test time, the operation to be executed is subjected to preset interpolation processing, wherein the preset interpolation processing is used to enable the operation to be executed to call the time adjustment parameter from the mapping diagnostic context structure during the execution process, and to determine the target test time based on the time adjustment parameter and the current time.
[0099] In one embodiment, the test execution module 720 is specifically used to determine the portion of the current time to be adjusted according to the adjustment unit; and to correct the portion to be adjusted according to the adjustment method and the adjustment amount to obtain the target test time.
[0100] In one embodiment, the test execution module 720 is specifically used to determine the time to be adjusted according to the adjustment time type; determine the portion to be adjusted of the time to be adjusted according to the adjustment unit; and correct the portion to be adjusted according to the adjustment method and the adjustment amount to obtain the target test time.
[0101] In one embodiment, the test execution module 720 is specifically configured to delete the time adjustment parameters stored in the mapping diagnostic context structure when it is determined that the software test request is in an execution completion state.
[0102] In summary, this embodiment provides a software testing device that eliminates the need to modify the server system time, avoids business anomalies caused by intrusive operations, effectively improves testing efficiency and accuracy, and ensures stable server operation.
[0103] Each module in the aforementioned software testing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0104] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores software testing-related data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a software testing method.
[0105] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0106] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0107] Read the time adjustment parameters from the software test request and store the time adjustment parameters in the mapping diagnostic context structure;
[0108] During the test execution phase, the time adjustment parameters are invoked from the mapping diagnostic context structure, and the target test time is determined based on the time adjustment parameters and the current time. The relevant tests are then executed according to the target test time.
[0109] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0110] Read the time adjustment parameters from the software test request and store the time adjustment parameters in the mapping diagnostic context structure;
[0111] During the test execution phase, the time adjustment parameters are invoked from the mapping diagnostic context structure, and the target test time is determined based on the time adjustment parameters and the current time. The relevant tests are then executed according to the target test time.
[0112] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0113] Read the time adjustment parameters from the software test request and store the time adjustment parameters in the mapping diagnostic context structure;
[0114] During the test execution phase, the time adjustment parameters are invoked from the mapping diagnostic context structure, and the target test time is determined based on the time adjustment parameters and the current time. The relevant tests are then executed according to the target test time.
[0115] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), data processing logic devices based on quantum computing, and the like.
[0116] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0117] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A software testing method, characterized in that, The method includes: Read time adjustment parameters from the software test request and store the time adjustment parameters in the mapping diagnostic context structure; During the test execution phase, the time adjustment parameters are invoked from the mapping diagnostic context structure, and a target test time is determined based on the time adjustment parameters and the current time. Relevant tests are then executed according to the target test time.
2. The method according to claim 1, characterized in that, The step of reading time adjustment parameters from a software test request and storing the time adjustment parameters in a mapping diagnostic context structure includes: Intercept software testing requests; Extract the time adjustment parameters from the preset byte region of the software test request; If the format of the time adjustment parameter passes the validation, the time adjustment parameter is stored in the mapping diagnostic context structure.
3. The method according to claim 1, characterized in that, During the test execution phase, the method further includes: Determine the type of operation to be performed; When the operation to be executed is to obtain the test time, the operation to be executed is subjected to preset interpolation processing. The preset interpolation processing is used to enable the operation to be executed to call the time adjustment parameter from the mapping diagnostic context structure during the execution process, and to determine the target test time based on the time adjustment parameter and the current time.
4. The method according to claim 1, characterized in that, The time adjustment parameters include the adjustment method, adjustment amount, and adjustment unit; determining the target test time based on the time adjustment parameters and the current time includes: The portion of the current time to be adjusted is determined based on the adjustment unit. The portion to be adjusted is corrected according to the adjustment method and the adjustment amount to obtain the target test time.
5. The method according to claim 4, characterized in that, The time adjustment parameters also include the time adjustment type, wherein the time adjustment type includes at least one of current time, historical time, and predicted time; Determining the target test time based on the time adjustment parameters and the current time includes: The time to be adjusted is determined according to the adjustment time type. The portion of the time to be adjusted is determined based on the adjustment unit. The portion to be adjusted is corrected according to the adjustment method and the adjustment amount to obtain the target test time.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: If it is determined that the software test request is in an execution completed state, the time adjustment parameter stored in the mapping diagnostic context structure is deleted.
7. A software testing device, characterized in that, The device includes: A parameter storage module is used to read time adjustment parameters from software test requests and store the time adjustment parameters in a mapping diagnostic context structure; The test execution module is used to, during the test execution phase, call the time adjustment parameters from the mapping diagnostic context structure, determine the target test time based on the time adjustment parameters and the current time, and execute relevant tests according to the target test time.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the software testing method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the software testing method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the software testing method according to any one of claims 1 to 6.