Test method and system and readable storage medium
By using shallow copy technology to share memory addresses on the recording and playback ends in software iterative testing, the problem of different test results caused by different data dependence between different machines is solved, and the reliability and accuracy of test results are improved.
Patent Information
- Application Number
- CN202411052853.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-12-10
AI Technical Summary
During the software iterative testing process, due to the different dependency data loaded on different machines, the output results of the software code before iteration and the software code after iteration are different, which in turn affects the reliability and accuracy of the test results.
By using shallow copy technology on the recording side to create the test instance and sharing the memory address with the playback side, we ensure real-time sharing of dependent data, so that the dependent data loaded at the same moment remains consistent, and avoid differences in test results due to different dependent data.
It improves the reliability and accuracy of the test results, ensures that the output results of the software functions before and after iteration are consistent, and avoids misjudgment of problems with software functions.
Smart Images

Figure CN119105954A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of testing technology, and in particular to a testing method, system and readable storage medium. Background Art
[0002] Testing is an important part of the software development process. Its purpose is to find problems with the software as quickly and early as possible. Since the software is continuously iterating, once the software is iterated, it needs to be tested to find problems and fix them.
[0003] The usual testing method is to run the software code before iteration and the software code after iteration respectively under the same input, and analyze and compare the output results of the corresponding functions (services) before and after iteration. Among them, during the testing process, the software code needs to load the dependency data into the local memory, and obtain the output results of the corresponding functions based on the loaded dependency data and input. The inventor found that the software code before iteration and the software code after iteration testing process are run separately on different machines. If the dependency data loaded locally on different machines is different, even if the software function corresponding to the dependency data is the same before and after iteration (no change), the software code before iteration and the software code after iteration will have different results due to different dependency data. The software code outputs the function before and after iteration, which ultimately leads to the test result that the corresponding part of the function in the software code after iteration has problems. To this end, it is necessary to provide a new testing method that can improve the reliability and accuracy of the test results. Summary of the invention
[0004] In order to solve the problems in the related art, the embodiments of the present disclosure provide a testing method, a system and a readable storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a testing method, wherein the method is applied to a recording end, including: Receive service test requests and direct the service test requests to the playback end; When creating at least one instance under test in response to a service test request, shallowly copying the instance under test; When receiving an instance call request from the playback end to call the instance under test, the instance under test obtained by shallow copy is called to obtain the call return value; Send the call return value to the playback end so that the playback end can test according to the call return value.
[0006] In one implementation of the present disclosure, when at least one instance under test is created in response to a service test request, shallowly copying the instance under test includes: When at least one instance under test is created in the target container in response to the service test request, the instance under test is shallowly copied to the test container.
[0007] In one implementation of the present disclosure, before shallowly copying the instance under test to the test container, the method further includes: Determine whether the pre-generated target instance list includes the instance under test. If so, execute the step of shallowly copying the instance under test to the test container.
[0008] In one implementation of the present disclosure, the method further includes: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
[0009] In an implementation of the present disclosure, when an instance call request is received from the playback end to call the instance under test, the instance under test obtained by shallow copy is called to obtain a call return value, specifically including: When receiving an instance call request from the playback end, parsing the instance call request to obtain the instance identifier of the requested call; When it is determined that the instance identifier of the shallowly copied instance under test includes the instance identifier requested to be called, the instance obtained by the shallow copy is called to obtain the call return value.
[0010] In a second aspect, an embodiment of the present disclosure provides a testing method, wherein the method is applied to a playback end, including: Get the service test request directed from the recording end; When it is determined that the service test request is used to create at least one instance under test, sending an instance call request for calling the instance under test to the recording end; Receive the call return value sent by the recording end and perform tests based on the call return value.
[0011] In one implementation of the present disclosure, before sending an instance call request for calling the instance under test to the recording end, the method further includes: It is determined whether the pre-generated target instance list includes the instance under test. If so, a step of sending an instance call request for calling the instance under test to the recording end is executed.
[0012] In one implementation of the present disclosure, the method further includes: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
[0013] In a third aspect, an embodiment of the present disclosure provides a test system, including a recording end and a playback end, wherein: The recording end is configured to: receive a service test request and direct the service test request to the playback end; when creating at least one instance under test in response to the service test request, shallowly copy the instance under test; when receiving an instance call request from the playback end requesting to call the instance under test, call the instance under test obtained by the shallow copy to obtain a call return value; send the call return value to the playback end so that the playback end can perform testing based on the call return value.
[0014] The playback end is configured to: obtain a service test request directed from the recording end; when it is determined that the service test request is used to create at least one instance under test, send an instance call request for calling the instance under test to the recording end; receive a call return value sent by the recording end, and perform a test based on the call return value.
[0015] In a fourth aspect, an embodiment of the present disclosure provides a testing device, including: A request diversion module is configured to receive a service test request and divert the service test request to a playback end; A shallow copy module, configured to shallowly copy the instance under test when creating at least one instance under test in response to the service test request; A request calling module, configured to, when receiving an instance calling request from the playback end to call the instance under test, call the instance under test obtained by shallow copying to obtain a call return value; The call return module is configured to send the call return value to the playback end, so that the playback end can perform a test according to the call return value.
[0016] In a fifth aspect, an embodiment of the present disclosure provides a testing device, including: A request acquisition module is configured to acquire a service test request directed from a recording end; A request sending module, configured to send an instance calling request for calling the instance under test to the recording end when it is determined that the service test request is used to create at least one instance under test; The return test module is configured to receive the call return value sent by the recording end and perform tests based on the call return value.
[0017] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer instructions, and wherein the one or more computer instructions are executed by the processor to implement a method as described in any one of the first aspect or the second aspect.
[0018] In a sixth aspect, a computer-readable storage medium is provided in an embodiment of the present disclosure, on which computer instructions are stored. When the computer instructions are executed by a processor, a method as described in any one of the first aspect or the second aspect is implemented.
[0019] In the technical solution provided by the embodiment of the present disclosure, since the instance under test obtained by the recording end through shallow copy will not respond to the call request initiated by the recording end for the instance under test, the instance under test obtained through shallow copy will not be occupied by the recording end, and can immediately respond to the instance call request sent by the playback end to call the instance under test, so that the playback end can immediately obtain the call return value. At the same time, since the instance under test created by the recording end in response to the service test request and the instance under test obtained by shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When receiving an instance call request from the playback end to call the instance under test, the instance under test obtained by shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end tests according to the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained by shallow copy, that is, it will not be considered that there is a problem with the corresponding part of the software function corresponding to the instance under test in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0020] In the technical solution provided by the embodiment of the present disclosure, since the instance under test obtained by the recording end through shallow copy will not respond to the call request for the instance under test initiated by the recording end, the instance under test obtained through shallow copy will not be occupied by the recording end, and can immediately respond to the instance call request for calling the instance under test sent by the playback end. When the playback end determines that the service test request diverted from the recording end is used to create at least one instance under test, the recording end sends an instance call request for calling the instance under test to the recording end, so that the recording end calls the instance under test obtained through shallow copy in response to the instance call request, obtains the call return value and sends it, so that the playback end can obtain the call return value immediately. Among them, since the instance under test on the recording end and the instance under test obtained through shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When the recording end receives an instance call request from the playback end to call the instance under test, the instance under test obtained by shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end performs testing based on the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained by shallow copy, that is, it will not be considered that the software function corresponding to the instance under test has problems in the corresponding part in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Other features, objectives and advantages of the present disclosure will become more apparent through the following detailed description of non-limiting embodiments in conjunction with the accompanying drawings. In the accompanying drawings:
[0023] FIG1 shows a schematic structural diagram of a test system according to an embodiment of the present disclosure.
[0024] FIG. 2 shows a flow chart of a testing method according to an embodiment of the present disclosure.
[0025] FIG. 3 shows a flow chart of a testing method according to an embodiment of the present disclosure.
[0026] FIG. 4 shows a structural block diagram of a testing device according to an embodiment of the present disclosure.
[0027] FIG5 shows a structural block diagram of a testing device according to an embodiment of the present disclosure.
[0028] FIG6 shows a structural block diagram of an electronic device according to an embodiment of the present disclosure.
[0029] Figure 7 A schematic diagram showing the structure of a computer system suitable for implementing the method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0030] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, parts not related to the description of the exemplary embodiments are omitted in the accompanying drawings.
[0031] In the present disclosure, it should be understood that terms such as "include" or "have" are intended to indicate the presence of features, numbers, steps, behaviors, components, parts, or a combination thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, behaviors, components, parts, or a combination thereof exist or are added.
[0032] It should also be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0033] In the present disclosure, if it involves operations of obtaining user information or user data or displaying user information or user data to others, the operations are all authorized and confirmed by the user, or actively selected by the user.
[0034] In the related art, when testing software, the software code before and after iteration is run separately under the same input, and the output results of the corresponding functions (services) before and after iteration are analyzed and compared to obtain the test results.
[0035] The inventor discovered that the testing process of the software code before iteration and the software code after iteration are run separately on different machines. If the dependency data loaded locally on different machines is different, even if the software function corresponding to the dependency data is the same (no change) before and after iteration, the different dependency data will cause differences in the results of the function output by the software code before iteration and the software code after iteration, ultimately leading to the test result believing that there is a problem with the corresponding part of the function in the software code after iteration.
[0036] To this end, a new test method is required to improve the reliability and accuracy of the test results. In order to solve the above problems, the embodiment of the present disclosure provides a technical solution, in which, since the tested instance obtained by the recording end through shallow copy will not respond to the call request for the tested instance initiated by the recording end, the tested instance obtained through shallow copy will not be occupied by the recording end, and can immediately respond to the instance call request sent by the playback end to call the tested instance, so that the playback end can immediately obtain the call return value. At the same time, since the instance under test created by the recording end in response to the service test request and the instance under test obtained through shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When an instance call request is received from the playback end to call the instance under test, the instance under test obtained through shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end tests according to the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained through shallow copy, that is, it will not be considered that there is a problem with the corresponding part of the software function corresponding to the instance under test in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0037] Figure 1 shows a schematic diagram of the structure of a test system according to an embodiment of the present disclosure, wherein the test system includes a recording terminal 101 and a playback terminal 102, the recording terminal 101 and the playback terminal 102 can be understood as a virtual server, a cloud server, or a server provided by a test service provider, the recording terminal 101 and the playback terminal 102 can also be understood as various electronic devices with network access functions, including but not limited to mobile communication terminals, desktop computers, tablet computers, laptops, wearable devices, etc.
[0038] The recording end 101 may be understood as an end running a first version of the software, and the playback end 102 may be understood as an end running a second version of the software, where the second version is an upgrade or iteration of the first version.
[0039] FIG2 is a flow chart of a test method according to an embodiment of the present disclosure. The test method is applied to the recording end shown in FIG1 , and as shown in FIG2 , the test method includes the following steps S101 - S104:
[0040] In step S101, a service test request is received and directed to a playback end; In step S102, when at least one instance under test is created in response to a service test request, a shallow copy of the instance under test is made; In step S103, when an instance call request is received from the playback end to call the instance under test, the instance under test obtained by shallow copy is called to obtain a call return value; In step S104, the call return value is sent to the playback end, so that the playback end can perform a test based on the call return value.
[0041] In one implementation of the present disclosure, receiving a service test request can be understood as receiving a service test request sent by a playback terminal, or can be understood as receiving a service test request forwarded by other devices or systems. The service test request can be understood as requesting to create at least one instance under test.
[0042] In one implementation of the present disclosure, directing the service test request to the playback end can be understood as enabling the playback end to obtain a service test request with the same input parameters as the service test request received by the recording end. Directing the service test request to the playback end can be achieved through tools such as TCPCopy, GoReplay, and HAProxy.
[0043] In one implementation of the present disclosure, the instance under test can be understood as the instance that is of interest when performing software testing. Exemplarily, when a modified code is subjected to consistency testing, the instance under test can be understood as corresponding to the unmodified portion of the code. In one implementation of the present disclosure, when determining whether to create at least one instance under test in response to a service test request, it can be understood as detecting a specific container on the playback end, and determining based on the detection result, wherein the instance created in the specific container can be understood as the instance under test created in response to the service test request.
[0044] In one implementation of the present disclosure, shallow copying the instance under test can be understood as bit-by-bit copying of the instance under test, that is, copying the pointer of the instance under test so that the pointer of the instance obtained by the shallow copy and the pointer of the instance under test point to the same memory space, so as to achieve the purpose of sharing a memory between the instance under test and the instance obtained by the shallow copy.
[0045] In one implementation of the present disclosure, receiving an instance call request from a playback end to call an instance under test can be understood as receiving an instance call request sent by the playback end, and can also be understood as receiving an instance call request forwarded by other devices or systems and sent by the playback end. For example, at the recording end, a corresponding tool can be used to expose a corresponding interface (for example, using a Jetty tool to expose a Hypertext Transfer Protocol (HTTP) interface), and an instance call request sent by the playback end to call an instance under test can be received through the interface.
[0046] In the technical solution provided by the embodiment of the present disclosure, since the instance under test obtained by the recording end through shallow copy will not respond to the call request initiated by the recording end for the instance under test, the instance under test obtained through shallow copy will not be occupied by the recording end, and can immediately respond to the instance call request sent by the playback end to call the instance under test, so that the playback end can immediately obtain the call return value. At the same time, since the instance under test created by the recording end in response to the service test request and the instance under test obtained through shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When an instance call request is received from the playback end to call the instance under test, the instance under test obtained through shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end tests according to the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained through shallow copy, that is, it will not be considered that there is a problem with the corresponding part of the software function corresponding to the instance under test in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0047] In one implementation of the present disclosure, when at least one instance under test is created in response to a service test request, shallowly copying the instance under test includes: When at least one instance under test is created in the target container in response to the service test request, the instance under test is shallowly copied to the test container.
[0048] In an implementation of the present disclosure, the target container can be understood as a container for managing the tested instance, and the tested instance can be stored in the instance created in the target container. Exemplarily, the target container can be understood as a spring container on the recording end.
[0049] In an implementation of the present disclosure, the test container may be understood as a container used only to manage the tested instance obtained by shallow copying, and the test container may be a container obtained by customization.
[0050] In this technical solution, when at least one tested instance is created in the target container in response to a service test request, the tested instance is shallowly copied to the test container. The tested instance in the target container and the tested instance obtained by the shallow copy can be stored separately, thereby reducing the difficulty of managing the tested instance obtained by the shallow copy and avoiding confusion between the tested instance obtained by the shallow copy and the tested instance in the target container when calling.
[0051] In one implementation of the present disclosure, before shallowly copying the instance under test to the test container, the method further includes: Determine whether the pre-generated target instance list includes the instance under test. If so, execute the step of shallowly copying the instance under test to the test container.
[0052] In an implementation of the present disclosure, the target instance list may be understood as indicating predetermined tested instances to be tested, wherein the target instance list stored in advance may be read, or a target instance list sent by other devices or systems may be received.
[0053] In one implementation of the present disclosure, to determine whether a pre-generated list of target instances includes a tested instance, the instance identifier of the tested instance created in response to a service test request may be obtained, and a query may be performed in the list of tested instances based on the instance identifier. If the list of target instances includes the instance identifier, it is determined that the pre-generated list of target instances includes the tested instance. The instance identifier corresponding to the tested instance may be understood as information that can uniquely identify the corresponding tested instance. Exemplarily, the instance identifier corresponding to the tested instance may be composed of a class name corresponding to the tested instance and a method name corresponding to the tested instance.
[0054] Exemplarily, the JavaAgent framework JVM-SANDBOX on the recording end can perform aspect detection on the spring container on the recording end when the premain function is executed to obtain the instance identifier of the tested instance created in the spring container in response to the service test request. If the target instance list includes the instance identifier, it is determined that the pre-generated target instance list includes the tested instance.
[0055] In this technical solution, before shallowly copying the tested instance to the test container, it is determined whether the pre-generated target instance list includes the tested instance. If so, the step of shallowly copying the tested instance to the test container is executed. This ensures that the tested instance shallowly copied to the test container is a predetermined tested instance that needs to be tested, avoids shallow copying of tested instances that do not need to be tested, and improves testing efficiency.
[0056] In one implementation of the present disclosure, the method further includes: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
[0057] In one implementation of the present disclosure, the request time corresponding to the service test request can be obtained by parsing the service test request, or by receiving request time indication information sent by other devices or systems, and obtaining the request time corresponding to the service test request based on the information.
[0058] In an implementation of the present disclosure, the instance list configuration information stored in advance may be read, or the instance list configuration information sent by other devices or systems may be received.
[0059] In one implementation of the present disclosure, based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information. This can be understood as matching the request time with the trigger time corresponding to each instance list in the instance list configuration information, and determining the instance list corresponding to the matched trigger time as the target instance list corresponding to the request time.
[0060] In one implementation of the present disclosure, determining a list of tested instances corresponding to a service publishing action in at least one instance list can be understood as matching the service identifier corresponding to each instance list in at least one instance list with the service identifier of the service published through the service publishing action, and determining the matching instance list as the list of tested instances.
[0061] In the technical solution provided by the embodiment of the present disclosure, by searching for the target instance list corresponding to the request time in the pre-generated instance list and instance list configuration information based on the request time corresponding to the service test request, different instance lists can be configured according to different test time periods, which makes it possible to test different instances under test in different test time periods by setting the instance list configuration information, thereby improving the test efficiency.
[0062] In an implementation of the present disclosure, when an instance call request is received from the playback end to call the instance under test, the instance under test obtained by shallow copy is called to obtain a call return value, specifically including: When receiving an instance call request from the playback end, parsing the instance call request to obtain the instance identifier of the requested call; When it is determined that the instance identifier of the shallowly copied instance under test includes the instance identifier requested to be called, the instance obtained by the shallow copy is called to obtain the call return value.
[0063] In one implementation of the present disclosure, whether the instance identifier of the shallow copy of the tested instance includes the instance identifier requested to be called can be determined by querying the tested instance that has been created on the recording end according to the instance identifier requested to be called, and determining based on the query result.
[0064] In the technical solution provided by the embodiment of the present disclosure, when an instance call request is received from the playback end, the instance call request is parsed to obtain the instance identifier of the requested call. When it is determined that the instance identifier of the shallowly copied instance under test includes the instance identifier requested to be called, the instance obtained by the shallow copy is called to obtain the call return value. This ensures that the obtained call return value is returned by the instance under test requested to be called, which helps to improve the reliability of the test results.
[0065] FIG3 is a flow chart of a test method according to an embodiment of the present disclosure. The test method is applied to a playback end, as shown in FIG3 , and the test method includes the following steps S201 - S203:
[0066] In step S201, a service test request directed from the recording end is obtained; In step S202, when it is determined that the service test request is used to create at least one instance under test, an instance call request for calling the instance under test is sent to the recording end; In step S203, the call return value sent by the recording end is received, and a test is performed according to the call return value.
[0067] In one implementation of the present disclosure, obtaining a service test request directed from the recording end can be understood as obtaining a service test request with the same input parameters as the service test request received by the recording end. Directing the service test request from the recording end to the playback end can be achieved through tools such as TCPCopy, GoReplay, and HAProxy.
[0068] In one implementation of the present disclosure, the tested instance can be understood as the instance of interest when performing software testing. Exemplarily, when performing consistency testing on modified code, the tested instance can be understood as corresponding to the unmodified portion of the code.
[0069] In one implementation of the present disclosure, sending an instance call request for calling the instance under test to the recording end can be understood as sending the instance call request to the recording end, and can also be understood as sending the instance call request to other devices or systems, and the other devices or systems forward the instance call request to the recording end. For example, at the recording end, a corresponding tool can be used to expose a corresponding interface for receiving the instance call request sent by the playback end (for example, using the Jetty tool to expose the Hypertext Transfer Protocol (HTTP) interface), and the playback end can send the instance call request to the interface.
[0070] In the technical solution provided by the embodiment of the present disclosure, since the instance under test obtained by the recording end through shallow copy will not respond to the call request for the instance under test initiated by the recording end, the instance under test obtained through shallow copy will not be occupied by the recording end, and can immediately respond to the instance call request for calling the instance under test sent by the playback end. When the playback end determines that the service test request diverted from the recording end is used to create at least one instance under test, the recording end sends an instance call request for calling the instance under test to the recording end, so that the recording end calls the instance under test obtained through shallow copy in response to the instance call request, obtains the call return value and sends it, so that the playback end can obtain the call return value immediately. Among them, since the instance under test on the recording end and the instance under test obtained through shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When the recording end receives an instance call request from the playback end to call the instance under test, the instance under test obtained by shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end performs testing based on the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained by shallow copy, that is, it will not be considered that the software function corresponding to the instance under test has problems in the corresponding part in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0071] In one implementation of the present disclosure, before sending an instance call request for calling the instance under test to the recording end, the method further includes: It is determined whether the pre-generated target instance list includes the instance under test. If so, a step of sending an instance call request for calling the instance under test to the recording end is executed.
[0072] In an implementation of the present disclosure, the target instance list may be understood as indicating predetermined tested instances to be tested, wherein the target instance list stored in advance may be read, or a target instance list sent by other devices or systems may be received.
[0073] In one implementation of the present disclosure, to determine whether a pre-generated list of target instances includes a tested instance, the instance identifier of the tested instance created in response to a service request may be obtained, and a query may be performed in the list of tested instances based on the instance identifier. If the list of target instances includes the instance identifier, it is determined that the pre-generated list of target instances includes the tested instance. The instance identifier corresponding to the tested instance may be understood as information that can uniquely identify the corresponding tested instance. Exemplarily, the instance identifier corresponding to the tested instance may be composed of a class name corresponding to the tested instance and a method name corresponding to the tested instance.
[0074] Exemplarily, the JavaAgent framework JVM-SANDBOX on the playback end can perform aspect detection on the spring container on the playback end when the premain function is executed to obtain the instance identifier of the tested instance created in the spring container in response to the service request. If the target instance list includes the instance identifier, it is determined that the pre-generated target instance list includes the tested instance.
[0075] In this technical solution, before sending an instance call request for calling the instance under test to the recording end, it is determined whether the pre-generated target instance list includes the instance under test. If it is included, the step of sending the instance call request for calling the instance under test to the recording end is executed. This ensures that the instance call request sent is used to call a predetermined instance under test that needs to be tested, avoids calling an instance under test that does not need to be tested, and improves testing efficiency.
[0076] In one implementation of the present disclosure, the method further includes: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
[0077] In one implementation of the present disclosure, the request time corresponding to the service request can be obtained by parsing the service request, or by receiving request time indication information sent by other devices or systems, and obtaining the request time corresponding to the service request based on the information.
[0078] In an implementation of the present disclosure, the instance list configuration information stored in advance may be read, or the instance list configuration information sent by other devices or systems may be received.
[0079] In one implementation of the present disclosure, based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information. This can be understood as matching the request time with the trigger time corresponding to each instance list in the instance list configuration information, and determining the instance list corresponding to the matched trigger time as the target instance list corresponding to the request time.
[0080] In one implementation of the present disclosure, determining a list of tested instances corresponding to a service publishing action in at least one instance list can be understood as matching the service identifier corresponding to each instance list in at least one instance list with the service identifier of the service published through the service publishing action, and determining the matching instance list as the list of tested instances.
[0081] In the technical solution provided by the embodiment of the present disclosure, by searching the target instance list corresponding to the request time in the pre-generated instance list and instance list configuration information based on the request time corresponding to the service test request, different instance lists can be configured according to different test time periods, so as to achieve the purpose of testing different tested instances in different test time periods by setting the instance list configuration information, thereby improving the test efficiency. In one embodiment of the present disclosure, testing is performed according to the call return value, including:
[0082] Perform consistency test based on the call return value; The method also includes: Obtain at least one of the code coverage, the new coverage, and the scenario coverage, where the code coverage is used to indicate the ratio between the amount of code called in response to the service test request and the total amount of code in the application, the new coverage is used to indicate the ratio between the amount of new code in the application and the total amount of code in the application, and the scenario coverage is used to indicate the ratio between the number of scenarios corresponding to the code called in response to the service test request and the total number of scenarios in the application; Obtain application evaluation results based on at least one of code coverage, new coverage, scenario coverage, and consistency test results.
[0083] In one implementation of the present disclosure, the weights of code coverage, new coverage, scenario coverage and consistency test results can be obtained, and the application evaluation results can be obtained based on at least one of the code coverage, new coverage, scenario coverage and consistency test results, combined with their respective weights.
[0084] In the technical solution provided in the embodiments of the present disclosure, by obtaining at least one of the code coverage, the new coverage, and the scenario coverage, and obtaining the application evaluation results based on at least one of the code coverage, the new coverage, the scenario coverage, and the consistency test results, it is convenient for testers to measure the reliability of the test results based on the application evaluation results.
[0085] The present disclosure provides a test system, as shown in FIG1 , which includes a recording end 101 and a playback end 102 , wherein: The recording end 101 is configured to: receive a service test request and direct the service test request to the playback end 102; when creating at least one instance under test in response to the service test request, shallowly copy the instance under test; when receiving an instance call request from the playback end 102 requesting to call the instance under test, call the instance under test obtained by the shallow copy to obtain a call return value; send the call return value to the playback end 102, so that the playback end 102 can perform a test based on the call return value.
[0086] The playback end 102 is configured to: obtain a service test request directed from the recording end 101; when it is determined that the service test request is used to create at least one instance under test, send an instance call request for calling the instance under test to the recording end 101; receive a call return value sent by the recording end 101, and perform a test based on the call return value.
[0087] Fig. 4 shows a structural block diagram of a test device according to an embodiment of the present disclosure, wherein the device can be implemented as part or all of an electronic device through software, hardware, or a combination of both.
[0088] As shown in FIG4 , the testing device 200 includes: The request diversion module 201 is configured to receive a service test request and divert the service test request to the playback end; A shallow copy module 202, configured to shallowly copy the instance under test when creating at least one instance under test in response to the service test request; The request calling module 203 is configured to call the instance under test obtained by shallow copying to obtain a call return value when receiving an instance calling request from the playback end requesting to call the instance under test; The call return module 204 is configured to send the call return value to the playback end, so that the playback end can perform a test according to the call return value.
[0089] In the technical solution provided by the embodiment of the present disclosure, since the instance under test obtained by the recording end through shallow copy will not respond to the call request initiated by the recording end for the instance under test, the instance under test obtained through shallow copy will not be occupied by the recording end, and can immediately respond to the instance call request sent by the playback end to call the instance under test, so that the playback end can immediately obtain the call return value. At the same time, since the instance under test created by the recording end in response to the service test request and the instance under test obtained through shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When an instance call request is received from the playback end to call the instance under test, the instance under test obtained through shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end tests according to the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained through shallow copy, that is, it will not be considered that there is a problem with the corresponding part of the software function corresponding to the instance under test in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0090] Fig. 5 shows a structural block diagram of a test device according to an embodiment of the present disclosure, wherein the device can be implemented as part or all of an electronic device through software, hardware, or a combination of both.
[0091] As shown in FIG5 , the testing device 300 includes: The request acquisition module 301 is configured to acquire a service test request directed from the recording end; The request sending module 302 is configured to send an instance calling request for calling the instance under test to the recording end when it is determined that the service test request is used to create at least one instance under test; The return test module 303 is configured to receive the call return value sent by the recording end and perform a test according to the call return value.
[0092] In the technical solution provided by the embodiments of the present disclosure, since the tested instance obtained through shallow copy on the recording end does not respond to the calling request of the tested instance, the tested instance obtained through shallow copy on the recording end will not be occupied by the recording end, and can immediately respond to the instance calling request for calling the tested instance sent by the playback end. Therefore, when the playback end determines that the service test request diverted from the recording end is used to create at least one tested instance, the playback end sends an instance calling request for calling the tested instance to the recording end, so that the recording end responds to the instance calling request to call the tested instance obtained through shallow copy to obtain the calling return value, and sends the calling return value to the playback end, so that the playback end can immediately obtain the calling return value. Among them, since the instance under test created by the recording end in response to the service test request and the instance under test obtained through shallow copy share a memory address, the two can realize real-time sharing of dependent data, thereby ensuring that the dependent data loaded by the two at the same time can be consistent. When an instance call request is received from the playback end to call the instance under test, the instance under test obtained through shallow copy is called, and the call return value obtained is consistent with the call return value of the instance under test created by the recording end. Therefore, when the playback end tests according to the call return value, if the software function corresponding to the instance under test on the recording end is the same as the software function corresponding to the instance under test on the playback end, then there will be no difference between the call return value obtained by calling the instance under test and the call return value obtained by calling the instance under test obtained through shallow copy, that is, it will not be considered that there is a problem with the corresponding part of the software function corresponding to the instance under test in the recording end or the playback end, thereby improving the reliability and accuracy of the test results obtained by testing based on the call return value.
[0093] The present disclosure also discloses an electronic device. FIG6 shows a structural block diagram of the electronic device according to an embodiment of the present disclosure.
[0094] As shown in FIG. 6 , the electronic device includes a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to an embodiment of the present disclosure.
[0095] In a first aspect, an embodiment of the present disclosure provides a testing method, wherein the method is applied to a recording end, including: Receive service test requests and direct the service test requests to the playback end; When creating at least one instance under test in response to a service test request, shallowly copying the instance under test; When receiving an instance call request from the playback end to call the instance under test, the instance under test obtained by shallow copy is called to obtain the call return value; Send the call return value to the playback end so that the playback end can test according to the call return value.
[0096] In one implementation of the present disclosure, when at least one instance under test is created in response to a service test request, shallowly copying the instance under test includes: When at least one instance under test is created in the target container in response to the service test request, the instance under test is shallowly copied to the test container.
[0097] In one implementation of the present disclosure, before shallowly copying the instance under test to the test container, the method further includes: Determine whether the pre-generated target instance list includes the instance under test. If so, execute the step of shallowly copying the instance under test to the test container.
[0098] In one implementation of the present disclosure, the method further includes: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
[0099] In an implementation of the present disclosure, when an instance call request is received from the playback end to call the instance under test, the instance under test obtained by shallow copy is called to obtain a call return value, specifically including: When receiving an instance call request from the playback end, parsing the instance call request to obtain the instance identifier of the requested call; When it is determined that the instance identifier of the shallowly copied instance under test includes the instance identifier requested to be called, the instance obtained by the shallow copy is called to obtain the call return value.
[0100] In a second aspect, an embodiment of the present disclosure provides a testing method, wherein the method is applied to a playback end, including: Get the service test request directed from the recording end; When it is determined that the service test request is used to create at least one instance under test, sending an instance call request for calling the instance under test to the recording end; Receive the call return value sent by the recording end and perform tests based on the call return value.
[0101] In one implementation of the present disclosure, before sending an instance call request for calling the instance under test to the recording end, the method further includes: It is determined whether the pre-generated target instance list includes the instance under test. If so, a step of sending an instance call request for calling the instance under test to the recording end is executed.
[0102] In one implementation of the present disclosure, the method further includes: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
[0103] Figure 7 A schematic diagram showing the structure of a computer system suitable for implementing the method according to an embodiment of the present disclosure is shown.
[0104] like Figure 7 As shown, the computer system includes a processing unit, which can execute various methods in the above-mentioned embodiments according to a program stored in a read-only memory (ROM) or a program loaded from a storage part into a random access memory (RAM). In the RAM, various programs and data required for the operation of the computer system are also stored. The processing unit, ROM and RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus.
[0105] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN card, a modem, etc. The communication part performs a communication process via a network such as the Internet. The drive is also connected to the I / O interface as needed. Removable media, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive as needed so that the computer program read therefrom can be installed into the storage part as needed. Among them, the processing unit can be implemented as a processing unit such as a CPU, a GPU, a TPU, an FPGA, an NPU, etc.
[0106] In particular, according to an embodiment of the present disclosure, the method described above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program tangibly contained on a machine-readable medium, and the computer program includes a program code for executing the above method. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium.
[0107] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the 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 and / or flowchart, and the combination of boxes in the block diagram and / or flowchart 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.
[0108] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or programmable hardware. The units or modules described may also be set in a processor, and the names of these units or modules do not constitute limitations on the units or modules themselves in some cases.
[0109] As another aspect, the present disclosure further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or computer system in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into a device. The computer-readable storage medium stores one or more programs, and the programs are used by one or more processors to execute the method described in the present disclosure.
[0110] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other.
Claims
1. A test method, wherein: The method is applied to the recording end, and includes: receiving a service test request, and directing the service test request to a playback end; When creating at least one instance under test in response to the service test request, shallowly copying the instance under test; When receiving an instance call request from the playback end to call the instance under test, calling the instance under test obtained by shallow copying to obtain a call return value; The call return value is sent to the playback end, so that the playback end can perform a test according to the call return value.
2. The testing method according to claim 1, wherein: When creating at least one instance under test in response to the service test request, shallowly copying the instance under test includes: When at least one instance under test is created in the target container in response to the service test request, the instance under test is shallowly copied to the test container.
3. The testing method according to claim 2, wherein: Before shallowly copying the instance under test to the test container, the method further includes: It is determined whether the pre-generated target instance list includes the instance under test. If so, a step of shallowly copying the instance under test to a test container is performed.
4. The testing method according to claim 3, wherein: The method further comprises: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
5. The testing method according to any one of claims 1 to 4, wherein: When receiving the instance call request from the playback end to call the instance under test, calling the instance under test obtained by shallow copy to obtain the call return value specifically includes: When receiving the instance call request from the playback end, parsing the instance call request to obtain the instance identifier of the request call; When it is determined that the instance identifier of the shallowly copied instance under test includes the instance identifier requested to be called, the instance obtained by the shallow copy is called to obtain the call return value.
6. A test method, wherein: The method is applied to a playback end, comprising: Get the service test request directed from the recording end; When it is determined that the service test request is used to create at least one instance under test, sending an instance call request for calling the instance under test to the recording end; Receive the call return value sent by the recording end, and perform testing according to the call return value.
7. The testing method according to claim 6, wherein: Before sending the instance calling request for calling the instance under test to the recording end, the method further includes: It is determined whether the pre-generated target instance list includes the instance under test. If so, a step of sending an instance calling request for calling the instance under test to the recording end is executed.
8. The testing method according to claim 7, wherein: The method further comprises: Based on the request time corresponding to the service test request, the target instance list corresponding to the request time is searched in the pre-generated instance list and instance list configuration information, wherein the instance list configuration information is used to indicate the correspondence between the instance list and the request time.
9. A test system, comprising a recording end and a playback end, wherein: The recording end is configured to: receive a service test request and direct the service test request to the playback end; When at least one instance under test is created in response to the service test request, a shallow copy of the instance under test is made; when an instance call request is received from the playback end requesting to call the instance under test, the instance under test obtained by the shallow copy is called to obtain a call return value; the call return value is sent to the playback end, so that the playback end can perform a test according to the call return value; The playback end is configured to: obtain a service test request directed from the recording end; When it is determined that the service test request is used to create at least one instance under test, sending an instance call request for calling the instance under test to the recording end; Receive the call return value sent by the recording end, and perform testing according to the call return value.
10. A computer-readable storage medium having computer instructions stored thereon, wherein: When the computer instructions are executed by a processor, the method steps of any one of claims 1 to 8 are implemented.
