CN116204438A - Test case generation method, automatic test method and related device - Google Patents

Test case generation method, automatic test method and related device Download PDF

Info

Publication number
CN116204438A
CN116204438A CN202310249065.9A CN202310249065A CN116204438A CN 116204438 A CN116204438 A CN 116204438A CN 202310249065 A CN202310249065 A CN 202310249065A CN 116204438 A CN116204438 A CN 116204438A
Authority
CN
China
Prior art keywords
link
request
test
test case
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310249065.9A
Other languages
Chinese (zh)
Inventor
杜广龙
应潇潇
刘洋
黄华
程进
赵胜
王小恒
谢作枝
林刚
孙祥庆
孙泽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hundsun Technologies Inc
Original Assignee
Hundsun Technologies Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hundsun Technologies Inc filed Critical Hundsun Technologies Inc
Priority to CN202310249065.9A priority Critical patent/CN116204438A/en
Publication of CN116204438A publication Critical patent/CN116204438A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable

Abstract

The embodiment of the invention provides a test case generation method, an automatic test method and a related device, and relates to the technical field of computers. By receiving link data transmitted by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information and input parameters and output parameters of a request interface; storing each link data and generating an association relation according to the link tracking identification of each link data; according to the target link data corresponding to the link tracking identification with the association relation, the test case is obtained, the system level cross-service test case is automatically generated by extracting the business data of the full link from the actual production environment, and the workload of test personnel for writing the test case is reduced. And in the test stage, test cases generated based on all-link service data are used for testing, so that the simulation of the actual customer use scene is facilitated, and the problem of the production environment is conveniently reproduced.

Description

Test case generation method, automatic test method and related device
Technical Field
The invention relates to the technical field of computers, in particular to a test case generation method, an automatic test method and a related device.
Background
In conventional automated testing, test cases are typically written manually by a tester.
However, for a distributed system, a complete link request often involves the invocation of multiple subsystems (services), and the invocation relationship is complex, which makes it difficult to manually create a system-level cross-service test case. The tester only has clear service logic of the service responsible for the tester, does not know the service overview of the full-link cross-service, and in the integrated test stage, each tester can only ensure the service test of the service responsible for the tester and can not construct test cases of the system-level cross-service.
Disclosure of Invention
In view of the above, the present invention aims to provide a test case generating method, an automated test method and a related device, so as to solve the problem in the prior art that the difficulty of manually creating a system-level cross-service test case is greater.
In order to achieve the above object, the technical scheme adopted by the embodiment of the invention is as follows:
in a first aspect, the present invention provides a test case generating method, including:
receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface;
Storing each link data and generating an association relation according to the link tracking identification of each link data;
obtaining a test case according to target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface in the target link data.
In an optional implementation manner, the generating an association relationship according to the link tracking identifier of each link data includes:
if the link tracking identifier of the link data belongs to the child identifier, a parent identifier corresponding to the link tracking identifier is searched, and the link tracking identifier is associated with the corresponding parent identifier, so that an association relationship corresponding to the link tracking identifier of each link data is obtained.
In an alternative embodiment, the request header of the request includes a link processing parameter that characterizes whether the service that processed the request is the first invoked service; the service collecting link data, comprising:
after receiving a request, determining a link tracking identifier according to link processing parameters in the request head;
recording the link tracking identifier, the incoming parameters of the request interface carried in the request, the request interface information called when the request is processed and the outgoing parameters of the request interface obtained after the request processing is completed;
And generating link data according to the recorded link tracking identification, the request interface information and the input parameters and the output parameters of the request interface.
In an alternative embodiment, the determining the link tracking identifier according to the link processing parameter in the request header includes:
if the link processing parameter in the request header is null, generating a link tracking identifier and setting the link processing parameter not to be null;
if the link processing parameter in the request head is not null, generating a corresponding sub-link tracking identifier according to the link tracking identifier in the request head, and taking the sub-link tracking identifier as the link tracking identifier of the link data; wherein the link tracking identification in the request header is generated by the service that sent the request.
In an alternative embodiment, the link data further includes a request processing duration, and the service collects the link data further includes:
recording the processing starting time of a request after the request is received;
recording the processing completion time of the request after the request processing is completed;
calculating the request processing time according to the processing starting time and the processing finishing time;
Generating link data according to the recorded link tracking identifier, the request interface information, the input parameters and the output parameters of the request interface, including:
and generating link data according to the recorded link tracking identification, the request interface information, the input parameters and the output parameters of the request interface and the request processing time.
In a second aspect, the present invention provides an automated test method comprising:
acquiring a target test case to be executed; the target test case is generated according to the test case generation method according to any one of the previous embodiments;
sending a test request to a test server according to a pre-configured request address, token information and a participating in the target test case, and receiving all test data returned by the test server based on the test request;
and comparing the test data with link data corresponding to the same link tracking identifier in the target test case according to preset assertion to obtain a test result of the target test case.
In a third aspect, the present invention provides a test case generating apparatus, the apparatus comprising:
the link data receiving module is used for receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface;
The data association module is used for storing the link data and generating association relations according to the link tracking identifiers of the link data;
the test case generation module is used for obtaining the test case according to the target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface in the target link data.
In a fourth aspect, the present invention provides an automated testing apparatus, the apparatus comprising:
the test case acquisition module is used for acquiring a target test case to be executed; the target test case is generated according to the test case generation method according to any one of the previous embodiments;
the test request sending module is used for sending a test request to a test server according to a pre-configured request address, token information and the entering parameters in the target test case, and receiving all test data returned by the test server based on the test request;
and the test result generation module is used for comparing the test data with the link data corresponding to the same link tracking identifier in the target test case according to preset assertion to obtain the test result of the target test case.
In a fifth aspect, the present invention provides an electronic device, including a processor, a memory, and a computer program stored on the memory and executable on the processor, the computer program implementing the steps of the test case generation method according to any one of the preceding embodiments, or implementing the steps of the automated test method according to the preceding embodiments, when executed by the processor.
In a sixth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the steps of the test case generation method according to any one of the preceding embodiments, or implements the steps of the automated test method according to the preceding embodiments.
The embodiment of the invention provides a test case generation method, an automatic test method and a related device, wherein the test case generation method comprises the following steps: receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information and input parameters and output parameters of a request interface; storing each link data and generating an association relation according to the link tracking identification of each link data; obtaining a test case according to target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information and input and output parameters of a request interface in target link data. Because the link data collected by each service in the production environment comprises the link tracking identifier, the request interface information and the input and output parameters of the request interface, and the link data can be associated according to the association relation of the link tracking identifier, the system-level cross-service test cases can be automatically generated by extracting the business data of the whole link from the actual production environment, and the workload of test personnel for writing the test cases is reduced. In addition, the test case generated based on the full-link service data is used for testing in the testing stage, so that the dislocation of the test data and the actual service data is effectively avoided, the simulation of the actual customer use scene is facilitated, and the problem of the production environment is conveniently reproduced.
In order to make the above objects, features and advantages of the present invention more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 illustrates a schematic diagram of an application environment suitable for use with embodiments of the present invention;
FIG. 2 is a schematic flow chart of a test case generating method according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of an automated test method according to an embodiment of the present invention;
FIG. 4 is a functional block diagram of a test case generating device according to an embodiment of the present invention;
FIG. 5 shows a functional block diagram of an automated test equipment provided by an embodiment of the present invention;
fig. 6 shows a block schematic diagram of an electronic device according to an embodiment of the present invention.
Icon: 100-server; 200-user terminals; 400-test case generating device; 500-an automated testing device; 110-memory; a 120-processor; 130-a communication module; 410-a link data receiving module; 420-a data association module; 430-a test case generation module; 510-a test case acquisition module; 520-a test request sending module; 530-test result generation module.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present invention.
It is noted that relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the prior art, aiming at the full-link service, a tester only has clear service logic of the service responsible for the tester and does not know the service overview of the full-link cross-service, and in the integrated test stage, each tester only can ensure the service test of the service responsible for the tester and can not construct a test case of the system-level cross-service; and the test data is disjointed with the actual service data, so that the actual customer use scene is difficult to simulate.
In order to solve the problems, the embodiment of the invention provides a test case generation method, an automatic test method and a related device, which can extract business data of a full link from an actual production environment to automatically generate a system-level cross-service test case, and reduce the workload of test personnel for writing the test case. In addition, the test case generated based on the full-link service data is used for testing in the testing stage, so that the dislocation of the test data and the actual service data is effectively avoided, the simulation of the actual customer use scene is facilitated, and the problem of the production environment is conveniently reproduced.
Fig. 1 is a schematic view of an application environment suitable for an embodiment of the present invention. As shown in fig. 1, the server 100 is communicatively connected to the user terminal 200, and a user may send a service request to the server 100 through the user terminal 200, and the server 100 processes the service request and generates a corresponding test case.
Alternatively, the server 100 may be a device that operates independently, or a distributed device, or a device cluster that is composed of a plurality of devices, which is not limited in this embodiment.
Alternatively, the user terminal 200 may be a smart phone, a desktop computer, a tablet computer, a notebook computer, or the like, which is not limited in this embodiment.
Referring to fig. 2, a flow chart of a test case generating method according to an embodiment of the present invention is shown. It should be noted that, the test case generating method according to the embodiment of the present invention is not limited by fig. 2 and the specific sequence below, and it should be understood that, in other embodiments, the sequence of some steps in the test case generating method according to the embodiment of the present invention may be interchanged according to actual needs, or some steps may be omitted or deleted. The test case generating method may be performed by the server 100 shown in fig. 1, and a detailed description will be given below of a specific flow shown in fig. 2.
Step S201, receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data includes a link tracking identification, request interface information, request interface in-parameters and request interface out-parameters.
In this embodiment, the user accesses the service through the user terminal 200, sends a request to the service, and the service may call other services in the process of processing the request, and the other services continue to process the received request. In the process of completing a certain service, from the user to the final return of the result, all services passing in the middle and the calling relation among the services form a complete link (full link).
Each service collects link data in the process of processing the request, including a link tracking identifier, request interface information, input parameters and output parameters of the request interface, and the like. Each service, after the completion of the link data collection, will send the link data to the server 100 for storage.
Step S202, storing each link data, and generating an association relation according to the link tracking identification of each link data.
In this embodiment, the server 100 stores (for example, may store in a database) the received link data, generates an association relationship according to the link tracking identifier of each link data, and may associate the link data collected by each service with each other through the link tracking identifier, so as to implement comprehensive tracking of the user request processing process, thereby obtaining link data corresponding to a complete link.
Step S203, obtaining a test case according to the target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information and input and output parameters of a request interface in target link data.
In this embodiment, since the target link data corresponding to the link tracking identifier with the association relationship is the link data corresponding to the complete link, the generated test case includes the link tracking identifier, the request interface information, the input parameters and the output parameters of the request interface in the target link data, so that the test case is a system level cross-service test case, and provides support for subsequent system level test.
Therefore, in the test case generation method provided by the embodiment of the invention, because the link data collected by each service in the production environment comprises the link tracking identifier, the request interface information and the input and output parameters of the request interface, and the link data can be associated according to the association relation of the link tracking identifier, the test case of the system level cross-service can be automatically generated by extracting the business data of the whole link from the actual production environment, the workload of the test personnel for writing the test case is reduced, and the problem that the input and output parameters of the simulation test are difficult to manually construct by the test case is effectively solved.
In one embodiment, the link data collection function of the service can be implemented by modifying Class (Class) information by a Java agent (Java agent) when the service is started. Among them, java is a family of object-oriented programming languages, class is a prototype that defines variables and methods for certain types of objects.
The Java agent is executed in a JVM (Java Virtual Machine ), and loads a Class file through a Class Loader (Class Loader), and before the Class Loader loads the Class file to generate a corresponding Class object, the content of the Class file (byte code modification technique) can be modified. The specific flow of modifying the class information is as follows: 1. configuring a service start parameter, and adding an Agent configuration parameter (-java Agent:/Users/davydu/tools. Jar-Dback_url=http:// localhost: 8090); 2. after a program is started, an Agent loads a Class file; 3. modifying the content of a Class file, and adding a link processing code (the service performs link data acquisition according to the logic of the link processing code) in the Class file; 4. the JVM load class is complete.
Optionally, the request header of the request includes a link handling parameter that characterizes whether the service handling the request is the first invoked service. The service collecting link data may include: after receiving the request, determining a link tracking identifier according to the link processing parameters in the request head; recording a link tracking identifier, a request interface parameter carried in a request, request interface information called when the request is processed, and a request interface parameter obtained after the request processing is completed; and generating link data according to the recorded link tracking identification, the request interface information and the input parameters and the output parameters of the request interface.
In this embodiment, since the link processing parameter in the request header may represent whether the service that processes the request is the first invoked service, after the service receives the request, it may determine whether the service itself is the first invoked service according to the link processing parameter in the request header, so as to generate the corresponding link tracking identifier. The request interface information may include information of a name of the request interface, a request address, a request method, and the like.
In one embodiment, it may be determined whether the service that handled the request is the first invoked service based on whether the link handling parameters are null. The determining the link tracking identifier according to the link processing parameter in the request header may include: if the link processing parameter in the request head is null, generating a link tracking identifier and setting the link processing parameter not to be null; if the link processing parameter in the request head is not null, generating a corresponding sub-link tracking identifier according to the link tracking identifier in the request head, and taking the sub-link tracking identifier as the link tracking identifier of the link data; wherein the link tracking identification in the request header is generated by the service sending the request.
It can be understood that when the service for processing the request is the first invoked service, both the link processing parameter and the link tracking identifier carried in the request are null, and at this time, a new link tracking identifier needs to be generated, and the link processing parameter is set to be not null (i.e. a new link processing parameter is generated); when the service recalls other services, the generated link tracking identifier and link processing parameters are carried in the requests sent to the other services. After other services receive the request, because the link processing parameter in the request header is not null, the service is judged to be not the first called service, a corresponding sub-link tracking identifier is generated according to the link tracking identifier in the request header, and the sub-link tracking identifier is used as the link tracking identifier of the collected link data.
For example, service A is the first called service, the generated link tracking identifier is AAAA, and when service A calls service B, the generated sub-link tracking identifier of service B is AAAA-1; similarly, when the service B calls the service C, the sub-link tracking identifier generated by the service C is AAAA-1-1. It can be seen that the link tracking identifier of the link data collected by the service A, B, C has a parent-child relationship, that is, the sub identifier of the AAAA to which the AAAA-1 belongs and the sub identifier of the AAAA-1 to which the AAAA-1 belongs, and the parent-child relationship of the link tracking identifier can reflect the calling relationship between the services.
In practical application, in order to facilitate knowing the processing duration of any request, the service may also count and record the processing duration of the request when processing the request.
Based on this, the link data further includes a request processing time period, and the service collecting the link data may further include: recording the processing starting time of the request after the request is received; after the request processing is completed, recording the processing completion time of the request; and calculating the request processing time according to the processing starting time and the processing finishing time. The link data generation method specifically comprises the steps of: and generating link data according to the recorded link tracking identification, the request interface information, the input parameters and the output parameters of the request interface and the request processing time.
The processing start time of the request may be a time when the service receives the request, and the processing completion time of the request may be a time when the execution of the request method is completed.
It should be noted that, in this embodiment, the link data may include, in addition to the link tracking identifier, the request interface information, the incoming and outgoing parameters of the request interface, and the request processing duration, and may also include a link processing parameter, a request body, a return state, and the like, which may be set according to actual needs, and this embodiment is not limited. In one example, the format of the link data may be as shown in table 1:
TABLE 1
Figure BDA0004127124670000101
Figure BDA0004127124670000111
In one embodiment, the association between link tracking identifiers may be established according to whether the link tracking identifiers in the link data are child identifiers. That is, the generating the association relationship according to the link tracking identifier of each link data in the step S202 may include: if the link tracking identifier of the link data belongs to the child identifier, a father identifier corresponding to the link tracking identifier is searched out, and the link tracking identifier is associated with the corresponding father identifier, so that an association relationship corresponding to the link tracking identifier of each link data is obtained.
For example, the link tracking identifiers of the link data collected by the service A, B, C are respectively AAAA, AAAA-1 and AAAA-1-1, and by judging that the AAAA-1 belongs to the sub-identifier of the AAAA and the AAAA-1-1 belongs to the sub-identifier of the AAAA-1, the association relationship of the AAAA, AAAA-1 and AAAA-1-1 can be established, so that the link data collected by the service A, B, C can be associated.
Referring to fig. 3, a flow chart of an automated testing method according to an embodiment of the invention is shown. It should be noted that, the automatic test method provided in the embodiment of the present invention is not limited by fig. 3 and the following specific sequence, and it should be understood that, in other embodiments, the sequence of part of the steps in the automatic test method provided in the embodiment of the present invention may be interchanged according to actual needs, or part of the steps may be omitted or deleted. The automatic test method can be applied to terminal equipment such as a desktop computer, a tablet computer, a notebook computer and the like, and a specific flow shown in fig. 3 will be described in detail.
Step S301, obtaining a target test case to be executed.
The target test case can be generated according to the test case generation method provided by the embodiment of the invention. When the test is required, a tester can check the link data stored in the database through the terminal equipment to obtain the target test case.
Step S302, a test request is sent to a test server according to a pre-configured request address, token information and the participation in the target test case, and all test data returned by the test server based on the test request are received.
In this embodiment, the request address and the token information may be preconfigured by the tester. And the tester configures a request address (namely a request interface address corresponding to the call service in the test environment) according to the obtained target test case, and sets token and other information. After the configuration is completed, the terminal equipment sends a test request to the test server according to the request address, the token information and the entering parameters in the target test case configured by the tester, and the test server processes the test request and returns corresponding test data (namely, the entering parameters of the request interface under the test environment).
It can be understood that the target test case is a complete link test case generated by the test case generation method provided by the embodiment of the invention, and for a complete link test case, since the complete link test case comprises link tracking identifiers collected in an actual production environment, the sequence of execution steps of the test case can be determined according to the parent-child relationship of the link tracking identifiers, so that the test case is executed according to the sequence of service requests in the actual production environment. That is, as long as the test of the complete link is transmitted to the first called service, the subsequent automatic request transmission will be performed according to the execution sequence of the service requests in the actual production environment, the calling relationship between different services is not concerned, and the intermediate process is not interfered by personnel.
Step S303, comparing the test data with the link data corresponding to the same link tracking identifier in the target test case according to the preset assertion, and obtaining the test result of the target test case.
In this embodiment, the assertion may also be preset by the tester. For example, after a tester checks link data stored in a database through a terminal device and obtains a target test case, according to the obtained target test case, an assertion may be added, where the assertion type may include: whether the return contains an error; whether the returned time is less than or equal to the time consuming assertion of the request on production; nodes of the links return assertions of data versus production; assertion of any one or combination of link node data comparisons; assertion of execution duration of any intermediate request; the nodes of the link request an assertion of integrity. The terminal equipment stores all test data returned by the test server, compares the link tracking identification corresponding to the test data with the link tracking identification of the original link data (link data in the target test case), analyzes and judges the test data with the same link tracking identification and the original link data according to the assertion set by the tester, and obtains a test result and feeds the test result back to the tester.
It should be noted that, the request address, the token information, and the assertion may be configured in advance by a tester, or may be configured by running a script file written in advance, and in this embodiment, a specific configuration mode is not limited.
Therefore, the automatic test method provided by the embodiment of the invention can directly use the test case generated based on the full-link service data for testing, can use all service requests in a test environment as long as the request address and the token are simply configured, and can globally check whether the actual use scene of the customer is missed, thereby effectively avoiding the disconnection of the test data and the actual service data, being beneficial to simulating the actual customer use scene and being convenient for reproducing the problem of the production environment.
In order to execute the corresponding steps in the above embodiments and each possible manner, implementation manners of the test case generating device and the automated testing device are respectively given below. Referring to fig. 4, a functional block diagram of a test case generating apparatus 400 according to an embodiment of the present invention is shown. It should be noted that, the basic principle and the technical effects of the test case generating device 400 provided in this embodiment are the same as those of the above embodiment, and for brevity, reference should be made to the corresponding contents in the above embodiment. The test case generating apparatus 400 includes a link data receiving module 410, a data associating module 420, and a test case generating module 430.
A link data receiving module 410, configured to receive link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data includes a link tracking identification, request interface information, request interface in-parameters and request interface out-parameters.
It is understood that the link data receiving module 410 may perform the above step S201.
The data association module 420 is configured to store each link data, and generate an association relationship according to the link tracking identifier of each link data.
It is understood that the data association module 420 may perform the step S202 described above.
The test case generation module 430 is configured to obtain a test case according to target link data corresponding to the link tracking identifier with the association relationship; the test case comprises a link tracking identifier, request interface information and input and output parameters of a request interface in target link data.
It is understood that the test case generation module 430 may perform the above step S203.
Optionally, the data association module 420 is specifically configured to find a parent identifier corresponding to the link tracking identifier if the link tracking identifier of the link data belongs to the child identifier, and associate the link tracking identifier with the corresponding parent identifier, so as to obtain an association relationship corresponding to the link tracking identifier of each link data.
Optionally, the request header of the request includes a link handling parameter that characterizes whether the service handling the request is the first invoked service. After receiving the request, the service determines a link tracking identifier according to the link processing parameters in the request head; recording a link tracking identifier, a request interface parameter carried in a request, request interface information called when the request is processed, and a request interface parameter obtained after the request processing is completed; and generating link data according to the recorded link tracking identification, the request interface information and the input parameters and the output parameters of the request interface.
Optionally, if the link processing parameter in the request header is null, generating a link tracking identifier and setting the link processing parameter not to be null; if the link processing parameter in the request head is not null, generating a corresponding sub-link tracking identifier according to the link tracking identifier in the request head, and taking the sub-link tracking identifier as the link tracking identifier of the link data; wherein the link tracking identification in the request header is generated by the service sending the request.
Optionally, the link data further includes a request processing duration, and the service records a processing start time of the request after receiving the request; after the request processing is completed, recording the processing completion time of the request; calculating the request processing time according to the processing starting time and the processing finishing time; and generating link data according to the recorded link tracking identification, the request interface information, the input parameters and the output parameters of the request interface and the request processing time.
It can be seen that the test case generating device provided by the embodiment of the invention comprises a link data receiving module, a data association module and a data association module, wherein the link data receiving module is used for receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information and input parameters and output parameters of a request interface; the data association module is used for storing each link data and generating association relation according to the link tracking identification of each link data; the test case generation module is used for obtaining the test case according to the target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information and input and output parameters of a request interface in target link data. Because the link data collected by each service in the production environment comprises the link tracking identifier, the request interface information and the input and output parameters of the request interface, and the link data can be associated according to the association relation of the link tracking identifier, the system level cross-service test case can be automatically generated by extracting the business data of the whole link from the actual production environment, the workload of the test personnel for writing the test case is reduced, and the problem that the manual construction of the simulation test input and output parameters of the test case is difficult is effectively solved.
Referring to fig. 5, a functional block diagram of an automated test equipment 500 according to an embodiment of the present invention is shown. It should be noted that, the basic principle and the technical effects of the automated test apparatus 500 provided in this embodiment are the same as those of the above embodiment, and for brevity, reference should be made to the corresponding contents of the above embodiment. The automated test equipment 500 includes a test case acquisition module 510, a test request transmission module 520, and a test result generation module 530.
The test case acquisition module 510 is configured to acquire a target test case to be executed; the target test case can be generated according to the test case generation method provided by the embodiment of the invention.
It is understood that the test case acquisition module 510 may perform the step S301 described above.
The test request sending module 520 is configured to send a test request to the test server according to the pre-configured request address, the token information and the entry in the target test case, and receive all test data returned by the test server based on the test request.
It is understood that the test request transmitting module 520 may perform the above step S302.
The test result generating module 530 is configured to compare, according to a preset assertion, the test data with link data corresponding to the same link tracking identifier in the target test case, so as to obtain a test result of the target test case.
It is understood that the test result generation module 530 may perform the above step S303.
Referring to fig. 6, a block diagram of an electronic device capable of implementing the server 100 and the terminal device according to an embodiment of the present invention is shown. The electronic device includes a memory 110, a processor 120, and a communication module 130. The memory 110, the processor 120, and the communication module 130 are electrically connected directly or indirectly to each other to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
Wherein the memory 110 is used for storing programs or data. The Memory 110 may be, but is not limited to, random access Memory (Random Access Memory, RAM), read Only Memory (ROM), programmable Read Only Memory (Programmable Read-Only Memory, PROM), erasable Read Only Memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable Read Only Memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
The processor 120 is used to read/write data or programs stored in the memory 110 and perform corresponding functions. For example, the test case generating method or the automated test method disclosed in the above embodiments may be implemented when the computer program stored in the memory 110 is executed by the processor 120.
The communication module 130 is used for establishing a communication connection between the electronic device and other devices through a network, and for transceiving data through the network.
It should be understood that the configuration shown in fig. 6 is merely a schematic diagram of the electronic device, and the electronic device may also include more or fewer components than those shown in fig. 6, or have a different configuration than that shown in fig. 6. The components shown in fig. 6 may be implemented in hardware, software, or a combination thereof.
Embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program which, when executed by the processor 120, implements the test case generating method or the automated test method disclosed in the above embodiments.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners as well. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present invention may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for generating test cases, the method comprising:
receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface;
storing each link data and generating an association relation according to the link tracking identification of each link data;
obtaining a test case according to target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface in the target link data.
2. The method of claim 1, wherein generating the association according to the link tracking identifier of each link data comprises:
if the link tracking identifier of the link data belongs to the child identifier, a parent identifier corresponding to the link tracking identifier is searched, and the link tracking identifier is associated with the corresponding parent identifier, so that an association relationship corresponding to the link tracking identifier of each link data is obtained.
3. The method of claim 1, wherein the request header of the request includes a link processing parameter that characterizes whether the service that processed the request is the first invoked service; the service collecting link data, comprising:
After receiving a request, determining a link tracking identifier according to link processing parameters in the request head;
recording the link tracking identifier, the incoming parameters of the request interface carried in the request, the request interface information called when the request is processed and the outgoing parameters of the request interface obtained after the request processing is completed;
and generating link data according to the recorded link tracking identification, the request interface information and the input parameters and the output parameters of the request interface.
4. A method according to claim 3, wherein said determining a link tracking identity from link processing parameters in said request header comprises:
if the link processing parameter in the request header is null, generating a link tracking identifier and setting the link processing parameter not to be null;
if the link processing parameter in the request head is not null, generating a corresponding sub-link tracking identifier according to the link tracking identifier in the request head, and taking the sub-link tracking identifier as the link tracking identifier of the link data; wherein the link tracking identification in the request header is generated by the service that sent the request.
5. The method of claim 3, wherein the link data further comprises a request processing duration, and wherein the service gathers link data further comprises:
Recording the processing starting time of a request after the request is received;
recording the processing completion time of the request after the request processing is completed;
calculating the request processing time according to the processing starting time and the processing finishing time;
generating link data according to the recorded link tracking identifier, the request interface information, the input parameters and the output parameters of the request interface, including:
and generating link data according to the recorded link tracking identification, the request interface information, the input parameters and the output parameters of the request interface and the request processing time.
6. An automated testing method, the method comprising:
acquiring a target test case to be executed; the target test case is generated according to the test case generation method of any one of claims 1 to 5;
sending a test request to a test server according to a pre-configured request address, token information and a participating in the target test case, and receiving all test data returned by the test server based on the test request;
and comparing the test data with link data corresponding to the same link tracking identifier in the target test case according to preset assertion to obtain a test result of the target test case.
7. A test case generating device, the device comprising:
the link data receiving module is used for receiving link data sent by each service; the link data is collected by the service when processing the request in the production environment; the link data comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface;
the data association module is used for storing the link data and generating association relations according to the link tracking identifiers of the link data;
the test case generation module is used for obtaining the test case according to the target link data corresponding to the link tracking identification with the association relation; the test case comprises a link tracking identifier, request interface information, and input parameters and output parameters of a request interface in the target link data.
8. An automated test equipment, the equipment comprising:
the test case acquisition module is used for acquiring a target test case to be executed; the target test case is generated according to the test case generation method of any one of claims 1 to 5;
the test request sending module is used for sending a test request to a test server according to a pre-configured request address, token information and the entering parameters in the target test case, and receiving all test data returned by the test server based on the test request;
And the test result generation module is used for comparing the test data with the link data corresponding to the same link tracking identifier in the target test case according to preset assertion to obtain the test result of the target test case.
9. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program implementing the steps of the test case generation method according to any one of claims 1-5 or the automated test method according to claim 6 when executed by the processor.
10. A computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, which computer program, when being executed by a processor, implements the steps of the test case generation method according to any one of claims 1-5, or implements the steps of the automated test method according to claim 6.
CN202310249065.9A 2023-03-09 2023-03-09 Test case generation method, automatic test method and related device Pending CN116204438A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310249065.9A CN116204438A (en) 2023-03-09 2023-03-09 Test case generation method, automatic test method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310249065.9A CN116204438A (en) 2023-03-09 2023-03-09 Test case generation method, automatic test method and related device

Publications (1)

Publication Number Publication Date
CN116204438A true CN116204438A (en) 2023-06-02

Family

ID=86509441

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310249065.9A Pending CN116204438A (en) 2023-03-09 2023-03-09 Test case generation method, automatic test method and related device

Country Status (1)

Country Link
CN (1) CN116204438A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627849A (en) * 2023-07-24 2023-08-22 中邮消费金融有限公司 System test method, device, equipment and storage medium
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device
CN116756044A (en) * 2023-08-11 2023-09-15 杭州罗莱迪思科技股份有限公司 RPC remote debugging method, device and application based on data link tracking

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627849A (en) * 2023-07-24 2023-08-22 中邮消费金融有限公司 System test method, device, equipment and storage medium
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device
CN116627851B (en) * 2023-07-24 2023-10-20 恒生电子股份有限公司 Interface testing method and device
CN116627849B (en) * 2023-07-24 2024-01-26 中邮消费金融有限公司 System test method, device, equipment and storage medium
CN116756044A (en) * 2023-08-11 2023-09-15 杭州罗莱迪思科技股份有限公司 RPC remote debugging method, device and application based on data link tracking
CN116756044B (en) * 2023-08-11 2023-11-21 杭州罗莱迪思科技股份有限公司 RPC remote debugging method, device and application based on data link tracking

Similar Documents

Publication Publication Date Title
CN116204438A (en) Test case generation method, automatic test method and related device
CN108984389B (en) Application program testing method and terminal equipment
CN114077525A (en) Abnormal log processing method and device, terminal equipment, cloud server and system
CN107203464B (en) Method and device for positioning service problem
CN111694644A (en) Message processing method and device based on robot operating system and computer equipment
CN113360413A (en) Code testing method and device
CN111124883B (en) Test case library introduction method, system and equipment based on tree form
CN115098297B (en) Consistent snapshot generation method and system for cloud primary storage data volume
CN114895879B (en) Management system design scheme determining method, device, equipment and storage medium
CN114328180A (en) Interface automation test method, system, electronic equipment and storage medium
CN111225075A (en) Configuration method and device for Internet of things directional access service
CN113852919B (en) Method and device for generating early warning message, storage medium and electronic device
CN112596752B (en) Internet of things method and system for electronic evidence obtaining equipment
CN117130946B (en) Test scene generation method and device, electronic equipment and readable storage medium
CN111324846B (en) Information processing method, information processing device, electronic equipment and computer readable storage medium
CN111522783B (en) Data synchronization method, device, electronic equipment and computer readable storage medium
CN117950985A (en) Storage performance test method of search engine and related equipment
CN115904939A (en) Interface flow based Mock method, system, device and medium
CN116909680A (en) Method for entering Pod container in container arranging system cluster
CN114185907A (en) Method and device for synchronizing database to data warehouse and electronic device
CN115145830A (en) Interface test case generation method, device and equipment
CA3136021A1 (en) Log storage method and device and computer system
CN116400954A (en) Interface configuration method, device, computer equipment and computer readable storage medium
CN116029540A (en) Risk assessment method and device for front-end code development system
CN115600864A (en) Cause parameter calling method, electronic device and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination