Test Case Generation Method, Device, Electronic Device, and Storage Medium
By receiving test case generation requests, obtaining interface information and parameter transmission information of the target link, generating and filling test data, and automatically generating test cases, solving the problem of low test efficiency in the existing technology and achieving efficient test case generation.
Patent Information
- Application Number
- CN202211086271.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-09-06
AI Technical Summary
During the existing automated testing process, the testing efficiency is low, the labor cost is high, and the time is long, making it difficult to meet the testing work needs.
By receiving test case generation requests, obtaining interface information and parameter transmission information of the target link, generating initial test cases from the full link log, and filling target test data based on test demand information, automatically generating target test cases.
It reduces the labor and time cost of writing, greatly improves testing efficiency, and simplifies the generation process of test cases.
Smart Images

Figure CN115391219B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a test case generation method, apparatus, electronic device, and storage medium. Background Art
[0002] Automation is an important area in the field of testing. It can not only effectively identify program problems but also greatly improve the efficiency of testing work. Automated testing has consistency and repeatability, and can support the rapid development and iteration of business. How to do a good job in automation and how to quickly respond to code changes to achieve T+0 automation are the current focuses of automated research.
[0003] In traditional automated testing, testers need to manually write automated test cases and test data in the test cases. The labor cost is high, and it takes a long time. Moreover, when the relevant business is upgraded, it is necessary to analyze the automated test cases from beginning to end and then modify them. Therefore, the efficiency is low and it is difficult to meet the needs of testing work.
[0004] Therefore, there is a technical problem of low testing efficiency in the current automated testing process, which needs to be improved. Summary of the Invention
[0005] Embodiments of this application provide a test case generation method, apparatus, electronic device, and storage medium to alleviate the technical problem of low testing efficiency in the current automated testing process.
[0006] To solve the above technical problem, the embodiments of this application provide the following technical solutions:
[0007] This application provides a test case generation method, including:
[0008] Receiving a test case generation request, where the test case generation request carries a target link identifier and test requirement information;
[0009] According to the target link identifier and the test requirement information, obtaining interface information and interface parameter passing information of each target interface of the target link from the full-link log;
[0010] According to the interface information and the interface parameter passing information, calling each target interface to generate an initial test case;
[0011] According to the interface parameter passing information and the test requirement information, generating target test data corresponding to the initial test case;
[0012] Filling the target test data into the initial test case to obtain a target test case.
[0013] At the same time, embodiments of this application also provide a test case generation apparatus, including:
[0014] A receiving module, configured to receive a test case generation request, where the test case generation request carries a target link identifier and test requirement information;
[0015] An obtaining module, configured to obtain interface information and interface parameter information of each target interface of the target link from the full-link log according to the target link identifier and the test requirement information;
[0016] An invocation module, configured to invoke each target interface to generate an initial test case according to the interface information and the interface parameter information;
[0017] A generation module, configured to generate target test data corresponding to the initial test case according to the interface parameter information and the test requirement information;
[0018] A obtaining module, configured to fill the target test data into the initial test case to obtain a target test case.
[0019] The present application further provides an electronic device, including a memory and a processor; the memory stores an application program, and the processor is configured to run the application program in the memory to execute the steps in the test case generation method described in any one of the above.
[0020] The embodiments of the present application provide a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the above test case generation method.
[0021] Beneficial effects: The present application provides a test case generation method, device, electronic device and storage medium. The method first receives a test case generation request, which carries a target link identifier and test requirement information, and then obtains interface information and interface parameter information of each target interface of the target link from the full-link log according to the target link identifier and the test requirement information, and then invokes each target interface to generate an initial test case according to the interface information and the interface parameter information, generates target test data corresponding to the initial test case according to the interface parameter information and the test requirement information, and finally fills the target test data into the initial test case to obtain a target test case. The present application only needs to issue a test case generation request to automatically generate a target test case containing target test data based on the full-link log, so it reduces the manual and time costs of writing and greatly improves the test efficiency. Description of the Drawings
[0022] The following will make the technical solutions and other beneficial effects of the present application obvious by describing the specific embodiments of the present application in detail in conjunction with the drawings.
[0023] Figure 1It is a schematic diagram of the application scenario of the test case generation method provided by the embodiments of the present application.
[0024] Figure 2 It is a schematic flowchart of the test case generation method provided by the embodiments of the present application.
[0025] Figure 3 It is an architecture diagram of the test case generation method provided by the embodiments of the present application.
[0026] Figure 4 It is a schematic structural diagram of the test case generation device provided by the embodiments of the present application.
[0027] Figure 5 It is a schematic structural diagram of the electronic device provided by the embodiments of the present application. Detailed implementation manners
[0028] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.
[0029] The embodiments of the present application provide a test case generation method, device, electronic device, and computer-readable storage medium. Among them, the test case generation device can be integrated in the electronic device, and the electronic device can be a server or a terminal device, etc.
[0030] Please refer to Figure 1 , Figure 1 It is a schematic diagram of the application scenario to which the test case generation method provided by the embodiments of the present application is applied. This scenario may include terminals and servers. Terminals, servers, and between terminals and servers are connected and communicate through the Internet composed of various gateways. This application scenario includes user terminal 11 and server 12; among them, user terminal 11 can be a device with a human-computer interaction function; server 12 includes a local server and / or a remote server, etc.
[0031] User terminal 11 and server 12 are located in a wireless network or a wired network to achieve data interaction between the two, where:
[0032] The tester performs a configuration operation on the interface of the user terminal 11 to generate a test case generation request, which carries the target link identifier and test requirement information. The server 12 receives the test case generation request, searches for the full-link log of the business system according to the target link identifier and test requirement information carried by it, obtains the interface information and interface parameter information of each target interface of the target link from the full-link log, then calls each target interface according to the interface information and interface parameter information to generate an initial test case, generates the target test data corresponding to the initial test case according to the interface parameter information and test requirement information, and finally fills the target test data into the initial test case to obtain the target test case and returns it to the user terminal 11. After obtaining the target test case from the user terminal 11, the tester can use it for automated testing.
[0033] It should be noted that Figure 1 The system scenario schematic diagram shown is only an example. The server and scenario described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those of ordinary skill in the art know that with the evolution of the system and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems. The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0034] Please refer to Figure 2 , Figure 2 which is a flowchart of the test case generation method provided by the embodiments of the present application. The method specifically includes:
[0035] S1: Receive a test case generation request, which carries the target link identifier and test requirement information.
[0036] A test case refers to data consisting of preconditions, test inputs, execution conditions, and expected results, etc., which is used to complete the testing of a specific requirement or objective, and is a document reflecting the testing plan, methods, technologies, and strategies. A test case usually includes multiple elements, such as test case number, belonging project, preconditions, test inputs, expected outputs, execution conditions, summary, level, etc. Specifically, the test case number is a string composed of characters and numbers, and the test case number is unique and easy to identify; the belonging project is used to indicate which project, module, unit, etc. this test case belongs to; the preconditions refer to the prerequisite conditions required to execute the current test case. If the prerequisite conditions are not met, the subsequent test steps cannot be carried out or the expected results cannot be achieved; the test inputs refer to the data that needs to be input during the execution of the test case; the expected outputs refer to the expected output results of the test case, including return value content, interface response results, etc.; the execution conditions include which interfaces need to be passed through to execute the current test case, the order of each interface, and the operation steps of the services corresponding to each interface, and the descriptions of each step need to be clearly given; the summary is to describe the test points of this test case in a general language; the level refers to the test importance level of the current test case, such as high level, medium level, low level, etc.
[0037] In the embodiments of the present application, when a test case needs to be generated, first receive a test case generation request. This request can be initiated by a tester after performing relevant configuration operations on the test case generation interface of the client and received by the server. During the process of completing a business, all the services passed through and the call relationships between the services from the start of a request to the final business completion response form a link. The links corresponding to different businesses are not exactly the same. For example, for a relatively complex business, more services are involved, while for a simple business, fewer services are involved.
[0038] In the embodiments of the present application, the test case generation request carries a target link identifier and test requirement information. The test case is generated based on the test requirements. The test requirement information is used to indicate what business the required generated test case is for testing, and the target link identifier is used to indicate which link needs to be called to complete this business.
[0039] In the process of completing a certain business, when the business request is processed by all services in sequence, the first service to be called generates an identifier, namely trace_id, and then passes it to the downstream services in sequence until the final business response. This identifier can be used to represent all the services that need to be called by the current business. Each service forms a target link, so this identifier can be used as the target link identifier. It should be noted that a complex business can include multiple links, some of which can form a small business separately. For a business request of a complex business of the business system, after completing a small business and generating a business response, the following small business can be completed. Then the above trace_id can continue to be passed, so these small businesses can correspond to the same target link identifier, and the test requirement information is used to determine whether it is a complex large business or one or several small businesses that need to be completed.
[0040] S2: According to the target link identifier and the test requirement information, the interface information and interface parameter information of each target interface of the target link are obtained from the full link log.
[0041] For a business system, it includes multiple services, each of which provides its own logical functions and can call each other. According to the type, quantity, and calling relationship of the services involved in a certain business, the business system can form multiple different links to complete different businesses. In the processing of each business, each link will generate logs. All logs of the business system form a full-link log, which records the process details of all requests received in the business system when they are processed by each service.
[0042] Each service has its own interface, and the interface information and interface parameter information of each interface are recorded in the full-link log, where the interface information may include the identifier of each interface, the protocol of the interface, the service or application corresponding to the interface, the time of the interface call, etc., and the interface parameter information includes the type, format, and value of the parameters passed in and out of the interface. After obtaining the target link identifier and test requirement information, the target link can be determined according to the target link identifier, and the target interface can be determined from all interfaces of the target link according to the test requirement information, and then the interface information and interface parameter information of these target interfaces can be obtained from the full-link log.
[0043] In one embodiment, S2 specifically includes: determining a target link from the full-link log according to the target link identifier, and determining all interfaces in the target link and the call order of each interface; determining the start interface and the end interface of the target link according to the test requirement information, and determining the target interface in the target link according to the start interface, the end interface and the call order; obtaining the interface information and interface parameter passing information of each target interface from the full-link log. First, determine the target link from the full-link log according to the target link identifier, then determine which services the target link corresponds to, and obtain the interfaces of all these services and the call order between each interface. Then, according to the test requirement information, determine what specific business the test case corresponds to, what the initial link and the end link of this business are respectively, and further determine the start service and the end service in the target link, and determine the corresponding start interface and end interface. Then, according to the call order between each interface obtained above, determine the other interfaces located between the start interface and the end interface, and jointly determine the start interface, the end interface and these intermediate interfaces as the target interfaces. Finally, obtain the interface information and interface parameter passing information of all target interfaces.
[0044] In one embodiment, the target link includes at least one sub-link, and the sub-link includes at least two interfaces. The step of determining the target interface in the target link according to the test requirement information, the start interface and the end interface of the target link, and the call order includes: determining the target sub-link in the target link according to the test requirement information, and determining the start interface and the end interface of the target sub-link; determining the target interface in the target sub-link according to the start interface, the end interface and the call order.
[0045] As mentioned in the above embodiments, a complex large service in the system corresponds to a long link, and the large service can be a combination of several small services. Each small service corresponds to a small segment in the link, that is, a sub-link. For example, for a loan service, it can be divided into multiple sub-services such as loan request, loan approval, and loan disbursement. The entire loan service corresponds to a complete loan link, and this loan link includes multiple sub-links such as a loan request sub-link, a loan approval sub-link, and a loan disbursement sub-link. The completion of each sub-service also requires multiple steps, so each sub-link includes at least two interfaces. In this embodiment, first determine the sub-service according to the test requirement information, and then determine the target sub-link in the target link. The target sub-link has a start interface and an end interface, and then determine all the target interfaces in the target sub-link according to the call order between the interfaces. For example, when the test requirement information indicates that the entire loan service needs to be completed, all the sub-links in the entire loan link are target sub-links, and all the interfaces are target interfaces; when the test requirement information indicates that only the loan approval service needs to be completed, only the loan approval sub-link is used as the target sub-link, and all the interfaces it contains are used as target interfaces. Through the above process, the test case generation requirements in different scenarios are realized.
[0046] In one embodiment, the test requirement information includes a first link length. According to the test requirement information, the steps of determining the target sub-link in the target link include: obtaining the second link length of each sub-link; matching the first link length and each second link length to obtain a first matching result; and determining the target sub-link in the target link according to the first matching result.
[0047] In some cases, when a certain target link is selected and test cases are to be constructed for the services corresponding to one or more of its sub-links, but the tester is not clear about how the sub-services in the current link are divided, or knows the division of the sub-services but wants to generate test cases corresponding to multiple sub-links at once through relatively simple operations, the test requirement information can include the first link length at this time, that is, it means wanting to obtain all sub-links in the target link with the same length as this. Then, the server will obtain the second link lengths of each sub-link from the full-link log and match each second link length with the first link length. If there is a second link length equal to the first link length, the corresponding sub-link will be used as the target sub-link. If not, a response indicating non-existence will be returned. If there are multiple second link lengths equal to the first link length, the corresponding multiple sub-links will all be used as target sub-links. For example, if the first link length in the test requirement information is 10 and the second link lengths of each sub-link are 8, 10, 6, and 10 respectively, the two sub-links with a second link length of 10 will be used as target sub-links. Through the above operations, only by performing the configuration operation of the first link length on the corresponding test case generation interface, test cases corresponding to all eligible sub-links in the target link can be generated, achieving batch generation and thus improving the efficiency.
[0048] In one embodiment, the test requirement information includes the first service function. According to the test requirement information, the steps to determine the target sub-link in the target link include: obtaining the second service function of each sub-link; matching the first service function and each second service function to obtain a second matching result; and determining the target sub-link in the target link according to the second matching result.
[0049] In some cases, if the tester knows which sub - services exist in the business corresponding to the target link, the test requirement information directly includes the first service function, where the first service function is used to indicate which sub - service needs to be requested. The server will obtain the second service functions of each sub - link from the full - link log and match each second service function with the first service function. If there is a second service function that is the same as the first service function, the corresponding sub - link is used as the target sub - link; if not, a response indicating non - existence is returned. When multiple test cases corresponding to sub - services need to be generated, the test requirement information can include multiple independent first service functions or a set of multiple first service functions. For example, when the test requirement information includes independent sub - services of loan approval and loan disbursement, the target sub - links corresponding to these two sub - services can be obtained respectively, and the test cases corresponding to these two sub - services can be generated separately in the follow - up. If the test requirement information includes a set of the loan approval sub - service plus the loan disbursement sub - service, the target sub - links corresponding to these two sub - services are combined to form a larger target sub - link, and a test case including both of these two links is generated in the follow - up.
[0050] S3: According to the interface information and interface parameter information, call each target interface to generate initial test cases.
[0051] The interface information includes the identifier of each interface, the protocol of the interface, the service or application corresponding to the interface, the time of interface call, etc. The interface parameter information includes the parameter types, formats, values, etc. passed in and out of the interface. After obtaining the interface information and interface parameter information of each target interface, call each target interface to generate initial test cases. Specifically, call the target interface according to the interface information to obtain the execution logic of the service corresponding to each target interface. According to the order of each target interface and the execution logic of each service, the execution conditions of the test cases can be generated. According to the interface parameter information, the test input, expected output, etc. of the test cases can be determined. Obtain the environment where each target interface is located during each call, such as the network environment, system environment, etc. from the full - link log, and the pre - set conditions of the test cases can be determined. Finally, combine the pre - set conditions, test input, expected output, execution conditions, etc., and add elements such as case number, belonging project, summary, level, etc. to form the initial test cases.
[0052] S4: According to the interface parameter information and test requirement information, generate the target test data corresponding to the initial test cases.
[0053] The test requirement information is used not only to indicate what business is to be tested when generating test cases, but also to indicate under what scenarios the tests need to be carried out. Specifically, the test scenarios can include normal scenarios and abnormal scenarios. Each scenario can include various situations such as single tests and batch tests. For example, the scenario where a users request simultaneously within a certain xx time period, the scenario where b users request sequentially within a certain xx time period, etc. Under different scenarios, the required test data is different. The test data includes test inputs and expected outputs. For a test scenario with a single request, the amount of test data required is small, while for a test scenario with batch requests, the amount of test data required is large. In the initial test cases obtained in the above steps, the amount of data in the interface parameter passing information is limited. Therefore, it is also necessary to determine how much test data is needed according to the test requirement information, determine what each test data is like according to the interface parameter passing information, and then generate test inputs and expected output data that match the quantity of the test requirements and are similar to the interface parameter passing information as the target test data corresponding to the initial test cases.
[0054] In one embodiment, S4 specifically includes: determining the test scenarios required for the initial test cases according to the test requirement information; obtaining the first interface parameter passing information under each test scenario within a historical time period from the full-link log; generating the target test data corresponding to the initial test cases according to the first interface parameter passing information.
[0055] In this embodiment, first determine the test scenarios required for the initial test cases according to the test requirement information. Suppose the test scenarios include 3, namely scenario 1 where multiple users request simultaneously and all are successful, scenario 2 where each user requests sequentially and all are successful, and scenario 3 where multiple users request simultaneously and only some are successful. After determining the test scenarios, obtain the first interface parameter passing information of all target interfaces under the 3 types of test scenarios from the full-link log. Since the required amount of data involves multiple users, data within a certain historical time period can be obtained, and the duration and time of the historical time period can be selected according to the test needs. For scenario 1, the first interface parameter passing information includes the request data and successful response data when m users request simultaneously. For scenario 2, the first interface parameter passing information includes the request data and successful response data when n users request sequentially. For scenario 3, the first interface parameter passing information includes the request data when s users request simultaneously, as well as a part of successful response data and a part of failed response data.
[0056] After obtaining the parameter information passed by the first interface, the request data in these first-interface parameter information is processed into test inputs required for the initial test cases, and the response data is processed into expected outputs required for the initial test cases, obtaining the target test data corresponding to the initial test cases. That is, after obtaining the test requirement information, all required target test data can be obtained from the full-link log. This method ensures that the test data is sourced from the real data of customers, resulting in higher test accuracy.
[0057] In one embodiment, S4 specifically includes: determining the test scenarios required for the initial test cases according to the test requirement information; obtaining the parameter information passed by the second interface in each test scenario within a historical time period from the full-link log, and generating the target test data corresponding to the initial test cases according to the parameter information passed by the second interface and a preset data generation model.
[0058] In this embodiment, first determine the test scenarios required for the initial test cases according to the test requirement information. Suppose the test scenarios include 3 types, namely scenario 1 where multiple users send requests simultaneously and all are successful, scenario 2 where each user sends requests in sequence and all are successful, and scenario 3 where multiple users send requests simultaneously and only some are successful. Each type of scenario needs to be tested 10 times. After determining the test scenarios, obtain the parameter information passed by the second interface of all target interfaces in the 3 types of test scenarios from the full-link log. Since the required data volume involves multiple users, data within a certain historical time period can be obtained. The duration and time of the historical time period can be selected according to test needs. For scenario 1, the parameter information passed by the second interface includes the request data and successful response data when m users send requests simultaneously. For scenario 2, the parameter information passed by the second interface includes the request data and successful response data when n users send requests in sequence. For scenario 3, the parameter information passed by the second interface includes the request data when s users send requests simultaneously, as well as a part of successful response data and a part of failed response data.
[0059] After obtaining the parameter information passed by the second interface, due to the large data volume of the test data required in some scenarios, the data volume of real users recorded in the full-link log may not be sufficient to support this test requirement. For example, if you want to test the data when 100 users access simultaneously, but the full-link log only records the data when 30 users access simultaneously, then the required data cannot be directly obtained from the full-link log. At this time, the real test inputs and expected outputs can be analyzed according to the parameter information passed by the second interface, and then the preset data generation model can be called to generate the data of the remaining 70 users, or generate the data of new 100 users. These data are used as the target test data. That is, this application can be combined with the preset data generation model. When wanting to generate test cases, the preset data generation model is called to analyze the parameter information passed by the interface to generate the required test data, thus efficiently meeting the needs of large-scale testing.
[0060] S5: Fill the target test data into the initial test case to obtain the target test case.
[0061] After obtaining the target test data, fill the target test data into the initial test case in a specific format, and then the target test case required for the final test can be obtained.
[0062] As can be seen from the above embodiments, for the test case generation method of the present application, first, a test case generation request is received. The test case generation request carries a target link identifier and test requirement information. Then, according to the target link identifier and test requirement information, interface information and interface parameter passing information of each target interface of the target link are obtained from the full-link log. Next, according to the interface information and interface parameter passing information, each target interface is called to generate an initial test case. According to the interface parameter passing information and test requirement information, target test data corresponding to the initial test case is generated. Finally, the target test data is filled into the initial test case to obtain the target test case. The present application only needs to send a test case generation request to automatically generate a target test case containing target test data based on the full-link log, thus reducing the manual and time costs of writing and greatly improving the test efficiency.
[0063] The following Figure 3 is used to further illustrate the above method. In Figure 3 , it is assumed that the business system includes Service 1, Service 2, Service 3, and Service 4. Interface 1 of Service 1 calls Interface 2 of Service 2, Interface 3 of Service 2 calls Interface 4 of Service 3, Interface 5 of Service 2 calls Interface 6 of Service 4, and Interface 7 of Service 4 calls Interface 8 of Service 3. According to the above call relationships, Service 1, Service 2, and Service 3 can form Link 1, and Service 1, Service 2, Service 4, and Service 3 can form Link 2. When each service makes mutual calls, various generated data are recorded in the log, and the logs of the entire system form the full-link log.
[0064] When test cases need to be generated, testers configure the test requirement information on the interface and select the required link, such as Link 1. Then the generated test case generation request carries the target link identifier and test requirement information. The server obtains the interface information and interface parameter passing information of each target interface of Link 1 from the full-link log. The target interfaces include Interface 1, Interface 2, Interface 3, and Interface 4. Then it calls each target interface to generate an initial test case and generates target test data corresponding to the initial test case. Finally, the target test data is filled into the initial test case to obtain the target test case.
[0065] Throughout the process, testers only need to perform some configuration operations on the front-end interface and initiate requests, and the server can automatically execute subsequent steps to obtain relevant information about the target interface of the target link and call the interface to generate test cases with one click. The operation is simple, reducing the requirements for testers' skills. And when the business changes, there is no need to modify the test cases. Just execute the above steps again to obtain the latest test cases. Therefore, the construction cost and maintenance cost of test cases are greatly reduced.
[0066] Based on the method described in the above embodiments, this embodiment will be further described from the perspective of a test case generation device. Please refer to Figure 4 , the test case generation device may include:
[0067] A receiving module 110, configured to receive a test case generation request, where the test case generation request carries a target link identifier and test requirement information;
[0068] An obtaining module 120, configured to obtain interface information and interface parameter information of each target interface of the target link from the full-link log according to the target link identifier and the test requirement information;
[0069] A calling module 130, configured to call each target interface to generate an initial test case according to the interface information and the interface parameter information;
[0070] A generating module 140, configured to generate target test data corresponding to the initial test case according to the interface parameter information and the test requirement information;
[0071] A obtaining module 150, configured to fill the target test data into the initial test case to obtain a target test case.
[0072] In one embodiment, the obtaining module 120 includes:
[0073] A first determination module, configured to determine the target link from the full-link log according to the target link identifier, and determine all interfaces in the target link and the call order of each interface;
[0074] A second determination module, configured to determine the start interface and end interface of the target link according to the test requirement information, and determine the target interfaces in the target link according to the start interface, the end interface and the call order;
[0075] A first obtaining module, configured to obtain interface information and interface parameter information of each target interface from the full-link log.
[0076] In one embodiment, the target link includes at least one sub-link, the sub-link includes at least two interfaces, and the second determination module includes:
[0077] A first determination sub-module, configured to determine a target sub-link in the target link according to the test requirement information, and determine a start interface and an end interface of the target sub-link;
[0078] A second determination sub-module, configured to determine a target interface in the target sub-link according to the start interface, the end interface, and the call order.
[0079] In one embodiment, the test requirement information includes a first link length, and the first determination sub-module includes:
[0080] A first acquisition unit, configured to acquire a second link length of each sub-link;
[0081] A first matching unit, configured to match the first link length and each second link length to obtain a first matching result;
[0082] A first determination unit, configured to determine a target sub-link in the target link according to the first matching result.
[0083] In one embodiment, the test requirement information includes a first service function, and the first determination sub-module includes:
[0084] A second acquisition unit, configured to acquire a second service function of each sub-link;
[0085] A second matching unit, configured to match the first service function and each second service function to obtain a second matching result;
[0086] A third determination unit, configured to determine a target sub-link in the target link according to the second matching result.
[0087] In one embodiment, the generation module 140 includes:
[0088] A third determination sub-module, configured to determine a test scenario required for the initial test case according to the test requirement information;
[0089] A second acquisition sub-module, configured to acquire first interface parameter passing information in each test scenario within a historical time period from the full-link log;
[0090] A first generation sub-module, configured to generate target test data corresponding to the initial test case according to the first interface parameter passing information.
[0091] In one embodiment, the generation module 140 includes:
[0092] The fourth determination sub-module is configured to determine the test scenarios required for the initial test case according to the test requirement information;
[0093] The third acquisition sub-module is configured to acquire the second interface parameter passing information in each test scenario within a historical time period from the full-link log;
[0094] The second generation sub-module is configured to generate the target test data corresponding to the initial test case according to the second interface parameter passing information and a preset data generation model.
[0095] Different from the prior art, the test case generation device provided by the present application first receives a test case generation request, where the test case generation request carries a target link identifier and test requirement information, and then according to the target link identifier and test requirement information, acquires the interface information and interface parameter passing information of each target interface of the target link from the full-link log, and then according to the interface information and interface parameter passing information, calls each target interface to generate an initial test case, generates the target test data corresponding to the initial test case according to the interface parameter passing information and test requirement information, and finally fills the target test data into the initial test case to obtain the target test case. The present application only needs to issue a test case generation request to automatically generate a target test case containing target test data based on the full-link log, thereby reducing the manual and time costs of writing and greatly improving the test efficiency.
[0096] Correspondingly, an embodiment of the present application further provides an electronic device, as Figure 5 shown. The electronic device may include a radio frequency (RF) circuit 501, a memory 502 including one or more computer-readable storage media, an input unit 503, a display unit 504, a sensor 505, an audio circuit 506, a WiFi module 507, a processor 508 including one or more processing cores, and a power supply 509, etc. Those skilled in the art can understand that Figure 5 the structure of the electronic device shown in
[0097] The radio frequency circuit 501 can be used for receiving and sending information during information reception and call processes. Specifically, after receiving the downlink information from the base station, it is handed over to one or more processors 508 for processing. Additionally, data related to the uplink is sent to the base station. The memory 502 can be used to store software programs and modules. The processor 508 executes various functional applications and test case generations by running the software programs and modules stored in the memory 502. The input unit 503 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical, or trackball signal inputs related to customer settings and function controls.
[0098] The display unit 504 can be used to display information input by the customer or information provided to the customer, as well as various graphical user interfaces of the server. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof.
[0099] The electronic device may further include at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. The audio circuit 506 includes a speaker, and the speaker can provide an audio interface between the customer and the electronic device.
[0100] WiFi belongs to short - range wireless transmission technology. The electronic device can help the customer send and receive emails, browse the web, and follow up on streaming media through the WiFi module 507. It provides the customer with wireless broadband Internet follow - up. Although Figure 5 the WiFi module 507 is shown, it can be understood that it does not belong to an essential component of the electronic device and can be omitted entirely within the scope of not changing the essence of the application as needed.
[0101] The processor 508 is the control center of the electronic device. It connects various parts of the entire mobile phone using various interfaces and lines. By running or executing the software programs and / or modules stored in the memory 502, and by calling the data stored in the memory 502, it executes various functions of the electronic device and processes data, thereby monitoring the mobile phone as a whole.
[0102] The electronic device further includes a power supply 509 (such as a battery) that powers each component. Preferably, the power supply can be logically connected to the processor 508 through a power management system, thereby implementing functions such as management of charging, discharging, and power consumption management through the power management system.
[0103] Although not shown, the electronic device may further include a camera, a Bluetooth module, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 508 in the server will, according to the following instructions, load the executable files corresponding to the processes of one or more application programs into the memory 502, and the processor 508 will run the application programs stored in the memory 502 to achieve the following functions:
[0104] Receive a test case generation request, where the test case generation request carries a target link identifier and test requirement information;
[0105] According to the target link identifier and the test requirement information, obtain the interface information and interface parameter information of each target interface of the target link from the full-link log;
[0106] According to the interface information and the interface parameter information, call each target interface to generate an initial test case;
[0107] According to the interface parameter information and the test requirement information, generate target test data corresponding to the initial test case;
[0108] Fill the target test data into the initial test case to obtain a target test case.
[0109] In the above embodiments, the descriptions of the various embodiments have their own emphases. For parts not detailed in a certain embodiment, reference may be made to the detailed description above, and details will not be repeated here.
[0110] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0111] Therefore, an embodiment of the present application provides a computer-readable storage medium, in which multiple instructions are stored, and the instructions can be loaded by a processor to implement the following functions:
[0112] Receive a test case generation request, where the test case generation request carries a target link identifier and test requirement information;
[0113] According to the target link identifier and the test requirement information, obtain the interface information and interface parameter information of each target interface of the target link from the full-link log;
[0114] According to the interface information and the interface parameter information, call each target interface to generate an initial test case;
[0115] According to the interface parameter information and the test requirement information, generate target test data corresponding to the initial test case;
[0116] Fill the target test data into the initial test case to obtain a target test case.
[0117] The above has introduced in detail a test case generation method, device, electronic device, and computer-readable storage medium provided by the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the technical solution and its core idea of the present application; those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A test case generation method, characterized in that, Including: Receiving a test case generation request, where the test case generation request carries a target link identifier and test requirement information; Determining a target link from the full-link log according to the target link identifier, and determining all interfaces in the target link and the call order of each interface. The target link includes at least one sub-link, and the sub-link includes at least two interfaces; Determining a target sub-link in the target link according to the test requirement information, and determining a start interface and an end interface of the target sub-link; Determining a target interface in the target sub-link according to the start interface, the end interface, and the call order; Obtaining interface information and interface parameter passing information of each target interface from the full-link log; Invoking each target interface according to the interface information and the interface parameter passing information to generate an initial test case; Generating target test data corresponding to the initial test case according to the interface parameter passing information and the test requirement information; Filling the target test data into the initial test case to obtain a target test case.
2. The test case generation method according to claim 1, wherein The test requirement information includes a first link length. The step of determining a target sub-link in the target link according to the test requirement information includes: Obtaining the second link length of each sub-link; Matching the first link length with each second link length to obtain a first matching result; Determining a target sub-link in the target link according to the first matching result.
3. The test case generation method according to claim 1, characterized in that The test requirement information includes a first service function. The step of determining a target sub-link in the target link according to the test requirement information includes: Obtaining the second service function of each sub-link; Matching the first service function with each second service function to obtain a second matching result; Determining a target sub-link in the target link according to the second matching result.
4. The test case generation method according to claim 1, wherein The step of generating target test data corresponding to the initial test case according to the interface parameter passing information and the test requirement information includes: Determining a test scenario required for the initial test case according to the test requirement information; Obtaining first interface parameter passing information in each test scenario within a historical time period from the full-link log; Generating target test data corresponding to the initial test case according to the first interface parameter passing information.
5. The test case generation method according to claim 1, wherein The step of generating target test data corresponding to the initial test case according to the interface parameter passing information and the test requirement information includes: Determining a test scenario required for the initial test case according to the test requirement information; Obtaining second interface parameter passing information in each test scenario within a historical time period from the full-link log; Generating target test data corresponding to the initial test case according to the second interface parameter passing information and a preset data generation model.
6. A test case generation device, characterized in that Including: A receiving module, configured to receive a test case generation request, where the test case generation request carries a target link identifier and test requirement information; An acquisition module, configured to determine a target link from full-link logs according to the target link identifier, and determine all interfaces in the target link and the call order of each interface. The target link includes at least one sub-link, and the sub-link includes at least two interfaces. According to the test requirement information, determine the target sub-link in the target link, and determine the start interface and end interface of the target sub-link. According to the start interface, the end interface and the call order, determine the target interface in the target sub-link, and obtain the interface information and interface parameter information of each target interface from the full-link logs; A call module, configured to call each target interface according to the interface information and the interface parameter information to generate an initial test case; A generation module, configured to generate target test data corresponding to the initial test case according to the interface parameter information and the test requirement information; An obtaining module, configured to fill the target test data into the initial test case to obtain a target test case.
7. An electronic device, characterized in that, It includes a memory and a processor; the memory stores an application program, and the processor is configured to run the application program in the memory to execute the steps in the test case generation method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and the computer program is executed by the processor to implement the steps in the test case generation method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Online test case generation method, device and electronic device
CN109062809A
Functional interface calling verification method and device, electronic device and storage medium
CN110334007A