Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an aspect of an embodiment of the present invention, there is provided a method for testing a system, as shown in fig. 1, the method including:
s102, receiving a test request sent by a test system, wherein the test request is used for requesting to test a target code in the tested system;
s104, responding to the test request to acquire a target operation log corresponding to the target code from the operation log of the tested system, wherein the operation log is a log generated in the operation process of the tested system, and the target operation log is a log generated when the tested system operates the target code;
and S106, sending a target operation log to the test system, wherein the target operation log is used for the test system to test the target code.
Optionally, in this embodiment, the testing method of the system may be applied to a hardware environment formed by the log query service system 202, the testing system 204, and the system under test 206 shown in fig. 2. As shown in FIG. 2, log query service system 202 receives a test request sent by test system 204, where the test request is used to request that target code in system under test 206 be tested. The log query service system 202 responds to the test request to obtain a target running log corresponding to the target code from the running log of the system under test 206, where the running log is a log generated in the running process of the system under test 206, and the target running log is a log generated when the system under test 206 runs the target code. The log query service system 202 sends a target operation log to the test system 204, wherein the target operation log is used for the test system 204 to test the target code.
Optionally, in this embodiment, the testing method of the system may be applied, but not limited to, in a scenario where the testing system performs an automated test on the system under test, so as to improve the testing accuracy and the testing efficiency of an automated testing scheme for the system. The above is only an example, and this is not limited in this embodiment.
It can be seen that through the above steps, a log corresponding to the running code is generated for the running code when the tested system runs, when the code needs to be tested, a target running log corresponding to the target code requested by the received test request is obtained, and the target running log is sent to the test system to instruct the test system to test the target code, so that the test on the specified code is realized, the technical effects of improving the test accuracy and the test efficiency of the automatic test scheme of the system are realized, and the technical problems of lower test accuracy and test efficiency of the automatic test scheme of the system in the related art are solved.
Optionally, the running log of the system under test is stored by using the identification information and the running log having the corresponding relationship, that is, the identification information may be allocated to the running log generated for the running code, and the identification information and the running log may be stored in a key-value key value pair form in which the running log is a value, and when a test request is received, the identification information of the target code requested by the test request is obtained, so that the target running log corresponding to the target code is obtained according to the identification information. For example: in the step S104, target identification information for identifying a target operation log is acquired from the test request in response to the test request; and searching the running log corresponding to the target identification information from the identification information and the running log which have the corresponding relation.
Optionally, during the test of the system under test, an operation log of the system under test is generated along with the operation of the system under test. For example: before the step S104, sending a call request to the system under test, where the call request is used to request to call the system under test; and under the condition of receiving confirmation information sent by the tested system, operating the tested system and storing an operation log generated by the tested system in the operation process, wherein the confirmation information is used for indicating that the tested system is successfully called.
Optionally, but not limited to, the operation log generated by the system under test during the operation process may be stored by one of the following methods:
in the first mode, the code identifier of the program code is used as the identifier information of the operation log, the corresponding relation between the program code and the operation log is established, and the code identifier and the operation log with the corresponding relation are stored. For example: acquiring an operation log generated in the operation process of a tested system and a code identifier of a program code operated by the tested system when the operation log is generated, and determining the code identifier as the identification information of the operation log; establishing a corresponding relation between the running log and the code identifier; and storing the running log and the code identification with the corresponding relation.
And secondly, distributing log identification for the running log, establishing a corresponding relation between the log identification and the running log, and storing the log identification and the running log with the corresponding relation. For example: acquiring an operation log generated in the operation process of a tested system; distributing a log identifier for the running log, and determining the log identifier as the identifier information of the running log; establishing a corresponding relation between the running log and the log identifier; and storing the running log and the log identification with the corresponding relation.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
According to another aspect of the embodiments of the present invention, there is also provided a testing apparatus of a system for implementing the testing method of the above system, as shown in fig. 3, the apparatus including:
1) a receiving module 32, configured to receive a test request sent by a test system, where the test request is used to request to test a target code in a system under test;
2) the obtaining module 34 is configured to obtain a target operation log corresponding to the target code from an operation log of the system under test in response to the test request, where the operation log is a log generated in an operation process of the system under test, and the target operation log is a log generated when the system under test operates the target code;
3) the first sending module 36 is configured to send a target operation log to the test system, where the target operation log is used for the test system to test the target code.
Optionally, in this embodiment, the testing apparatus of the system described above may be applied to a hardware environment formed by the log query service system 202, the testing system 204, and the system under test 206 shown in fig. 2. As shown in FIG. 2, log query service system 202 receives a test request sent by test system 204, where the test request is used to request that target code in system under test 206 be tested. The log query service system 202 responds to the test request to obtain a target running log corresponding to the target code from the running log of the system under test 206, where the running log is a log generated in the running process of the system under test 206, and the target running log is a log generated when the system under test 206 runs the target code. The log query service system 202 sends a target operation log to the test system 204, wherein the target operation log is used for the test system 204 to test the target code.
Optionally, in this embodiment, the testing apparatus of the system may be, but is not limited to, applied in a scenario where a testing system performs an automated test on a system under test, so as to improve the testing accuracy and the testing efficiency of an automated testing scheme for the system. The above is only an example, and this is not limited in this embodiment.
Therefore, by the device, the corresponding log is generated for the running code when the tested system runs, when the code needs to be tested, the target running log corresponding to the target code requested by the received test request is obtained, and the target running log is sent to the test system to indicate the test system to test the target code, so that the test on the specified code is realized, the technical effects of improving the test accuracy and the test efficiency of the automatic test scheme of the system are realized, and the technical problems of lower test accuracy and test efficiency of the automatic test scheme of the system in the related technology are solved.
As an alternative, as shown in fig. 4, the obtaining module 34 includes:
1) an obtaining unit 42, configured to obtain, in response to the test request, target identification information for identifying the target operation log from the test request;
2) and the searching unit 44 is used for searching the running log corresponding to the target identification information from the identification information and the running log which have the corresponding relation.
Optionally, the running log of the system under test is stored by using the identification information and the running log having the corresponding relationship, that is, the identification information may be allocated to the running log generated for the running code, and the identification information and the running log may be stored in a key-value key value pair form in which the running log is a value, and when a test request is received, the identification information of the target code requested by the test request is obtained, so that the target running log corresponding to the target code is obtained according to the identification information.
As an alternative, as shown in fig. 5, the apparatus further includes:
1) the second sending module 52 is configured to send a call request to the system under test, where the call request is used to request to call the system under test;
2) and the processing module 54 is configured to, in a case that confirmation information sent by the system under test is received, run the system under test and store a running log generated by the system under test in a running process, where the confirmation information is used to indicate that the system under test is successfully called.
Optionally, during the test of the system under test, an operation log of the system under test is generated along with the operation of the system under test.
As an alternative, as shown in fig. 6, the processing module 54 includes:
1) the first processing unit 62 is configured to obtain an operation log generated by the system under test in an operation process and a code identifier of a program code that is executed by the system under test when the operation log is generated, and determine the code identifier as identifier information of the operation log; establishing a corresponding relation between the running log and the code identifier; storing the running log and the code identification with the corresponding relation; alternatively, the first and second electrodes may be,
2) the second processing unit 64 is configured to obtain an operation log generated in the operation process of the system under test; distributing a log identifier for the running log, and determining the log identifier as the identifier information of the running log; establishing a corresponding relation between the running log and the log identifier; and storing the running log and the log identification with the corresponding relation.
Optionally, an operation log generated by the system under test during the operation process may be stored in one of the processing units.
Optionally, the first processing unit uses the code identifier of the program code as the identification information of the operation log, establishes a corresponding relationship between the program code and the operation log, and stores the code identifier and the operation log having the corresponding relationship. And distributing a log identifier for the running log through the second processing unit, establishing a corresponding relation between the log identifier and the running log, and storing the log identifier and the running log with the corresponding relation.
The application environment of the embodiment of the present invention may refer to the application environment in the above embodiments, but is not described herein again. The embodiment of the invention provides an optional specific application example of the connection method for implementing the real-time communication.
As an alternative embodiment, the method for testing the system may be, but is not limited to, applied in a scenario where a system under test is tested by a testing system as shown in fig. 7. In this scenario, a log query service is provided. And in the implementation process of the code, writing a corresponding log in a key point log file of logic processing. In the process of automatic testing, information such as log files and log keywords which need to be asserted is transmitted by calling an interface of log query service, whether the log exists in the log files is queried, and whether the corresponding log content is found is returned by the interface. The return of the log query interface is asserted during the test.
As shown in fig. 8: from A to C, this can be achieved either through B1 or through B2. In the present scenario, a log may be logged for B1 when passing B1 and B2 when passing B2.
Optionally, in this scenario, it is desirable to uniquely determine the log corresponding to a request when asserted. The log may be identified by 2 methods:
mode 1, when a log related to B1 is logged, a unique key related to a request is incidentally logged, such as: the request number. The request numbers are different for different requests, so that the log corresponding to the request can be found when asserted, and is not interfered by other requests.
In mode 2, for requests without a unique key, before each request for writing the log, the previous log file is changed into another format, and the log file write log is newly created. Such as: log file is order.log, when a request comes in, the order.log is firstly renamed to order X.log (X is a random sequence), then an order.log file is newly created, and the log related to the request is written.
Alternatively, as shown in fig. 7, the system under test may be tested by:
step 1, the test system calls the tested system. (the tested system writes the corresponding log in the log file in the process of code implementation).
And 2, returning the tested system to be successfully called.
And 3, calling log query service by the test system.
Step 4, the log query service queries the system log under test (e.g., whether a log of B1 was generated during the test).
And step 5, obtaining a query result by the log query service.
And 6, returning the query result to the test system by the log query service.
And 7, the test system makes assertion on the return result.
According to the embodiment, the current test assertion scheme mainly asserts the interface return value and the database data, but the interface return is the same, the database data is the same, and the assertion cannot be realized in any way in different scenarios of the implementation scheme. And the execution track of the code in the test process can be accurately judged in the scene. In addition, the test method can be used independently, and can also be used as a supplementary test scheme of the existing test method.
According to still another aspect of an embodiment of the present invention, there is also provided an electronic device for performing a test of the above system, as shown in fig. 9, the electronic device including: one or more processors 902 (only one of which is shown in the figure), in which a computer program is stored, a memory 904, in which a sensor 906, an encoder 908 and a transmitting device 910 are arranged to carry out the steps of any of the above-described method embodiments by means of the computer program.
Optionally, in this embodiment, the electronic apparatus may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, receiving a test request sent by the test system, wherein the test request is used for requesting to test a target code in the tested system;
s2, responding to the test request to obtain a target operation log corresponding to the target code from the operation log of the tested system, wherein the operation log is a log generated in the operation process of the tested system, and the target operation log is a log generated when the tested system operates the target code;
and S3, sending the target operation log to the test system, wherein the target operation log is used for the test system to test the target code.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 7 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 9 is a diagram illustrating a structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 9, or have a different configuration than shown in FIG. 9.
The memory 902 may be used to store software programs and modules, such as program instructions/modules corresponding to the testing method and apparatus of the system in the embodiment of the present invention, and the processor 904 executes various functional applications and data processing by running the software programs and modules stored in the memory 902, that is, implementing the control method of the target component described above. The memory 902 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 902 may further include memory located remotely from the processor 904, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 910 is used for receiving or transmitting data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmission device 910 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices so as to communicate with the internet or a local area Network. In one example, the transmission device 910 is a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
Wherein the memory 902 is used for storing, inter alia, application programs.
Embodiments of the present invention also provide a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, receiving a test request sent by the test system, wherein the test request is used for requesting to test a target code in the tested system;
s2, responding to the test request to obtain a target operation log corresponding to the target code from the operation log of the tested system, wherein the operation log is a log generated in the operation process of the tested system, and the target operation log is a log generated when the tested system operates the target code;
and S3, sending the target operation log to the test system, wherein the target operation log is used for the test system to test the target code.
Optionally, the storage medium is further configured to store a computer program for executing the steps included in the method in the foregoing embodiment, which is not described in detail in this embodiment.
Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.