Method for generating test cases, computer device, and computer-readable storage medium
By filtering production traffic files related to the target business system and associated business system, and matching test cases to generate files based on test keywords, the problem of excessively long generation of test cases in the existing technology is solved, and the testing efficiency is improved.
Patent Information
- Application Number
- CN202210870370.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2042-07-22
AI Technical Summary
The prior art usually uses all production traffic when generating test cases, resulting in too long testing and too low efficiency.
By obtaining the target business system and associated business system to which the function to be tested belongs, the production traffic files related to the target business system and associated business system are filtered out from multiple production traffic files, and specific test case generation files are matched based on the test keywords.
Shorten the time for test case generation, improve test efficiency, and avoid inefficiency problems caused by using all production flows.
Smart Images

Figure CN115221062B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of test cases, and specifically relates to a method for generating test cases, a computer device, and a computer-readable storage medium. Background Art
[0002] During the actual use of multiple business systems of a bank, a large amount of production traffic will be generated. This production traffic is often used to generate test cases for testing new functions of banking services.
[0003] Currently, in order to ensure the reliability of functional testing, all production traffic is often used to generate test cases. This method will make the testing take too long and result in too low testing efficiency. Summary of the Invention
[0004] Embodiments of this application provide a method for generating test cases, a computer device, and a computer-readable storage medium, aiming to shorten the time spent on testing and improve testing efficiency.
[0005] On the one hand, this application provides a method for generating test cases, including:
[0006] Obtain the target business system to which the function to be tested belongs;
[0007] Determine the associated business system corresponding to the target business system;
[0008] Among multiple preset production traffic files, determine the first production traffic file corresponding to the target business system and the associated business system;
[0009] Obtain the test keyword corresponding to the function to be tested;
[0010] Among multiple first production traffic files, determine the second production traffic file corresponding to the test keyword;
[0011] Generate test cases corresponding to the function to be tested according to the second production traffic file.
[0012] In some embodiments, the step of determining the second production traffic file corresponding to the test keyword among multiple first production traffic files includes:
[0013] Obtain the attribute information of multiple first production traffic files;
[0014] Divide multiple first production traffic files into multiple traffic file sets according to the attribute information;
[0015] Determine the business keywords corresponding to each traffic file set;
[0016] Determine the degree of association between the test keyword and each of the business keywords;
[0017] According to the degree of association, determine the target business keyword among the multiple business keywords;
[0018] Use the first production traffic file in the traffic file set corresponding to the target business keyword as the second production traffic file.
[0019] In some embodiments, the step of determining the degree of association between the test keyword and each of the business keywords includes:
[0020] Obtain a preset topological relationship graph including the preset topological relationship between multiple preset test keywords and multiple preset business keywords;
[0021] In the preset topological relationship graph, determine the node distance between the test keyword and the business keyword;
[0022] According to the node distance, determine the degree of association between the test keyword and the business keyword.
[0023] In some embodiments, the step of generating test cases corresponding to the function to be tested according to the second production traffic file includes:
[0024] Obtain the expected test duration corresponding to the function to be tested and the resource configuration information corresponding to the target business system;
[0025] According to the expected test duration and the resource configuration information, determine the corresponding expected number of traffic files;
[0026] Among the multiple second production traffic files, determine the third production traffic file that matches the expected number of traffic files;
[0027] Generate test cases corresponding to the function to be tested according to the third production traffic file.
[0028] In some embodiments, the step of determining the third production traffic file that matches the expected number of traffic files among the multiple second production traffic files includes:
[0029] Determine the second business system to which each of the second production traffic files belongs;
[0030] Determine the degree of association between the second business system and the target business system;
[0031] According to the degree of association, determine the traffic file ratio corresponding to the second business system;
[0032] Determine the number of third production traffic files that the second service system should include according to the traffic file ratio corresponding to the second service system and the expected number of traffic files;
[0033] Among the multiple second production traffic files corresponding to the second service system, determine the third production traffic files that match the number of third production traffic files that the second service system should include.
[0034] In some embodiments, the step of determining the association degree between the second service system and the target service system includes:
[0035] Determine the data interaction link corresponding to the function to be tested;
[0036] According to the data interaction link, determine the routing table distance between the second service system and the target service system;
[0037] According to the routing table distance, determine the association degree between the second service system and the target service system.
[0038] In some embodiments, the step of determining the associated service system corresponding to the target service system includes:
[0039] Determine the data interaction link corresponding to the function to be tested;
[0040] According to the service systems passed by the data interaction link, determine the associated service system corresponding to the target service system.
[0041] In some embodiments, the step of determining the test keywords corresponding to the function to be tested includes:
[0042] Obtain the test service scenario and test environment corresponding to the function to be tested;
[0043] Input the test service scenario and the test environment into a preset keyword generation model;
[0044] Obtain the test keywords output by the preset keyword generation model.
[0045] On the other hand, an embodiment of the present application provides a test case generation device, and the test case generation device includes:
[0046] An acquisition module, configured to acquire the target service system to which the function to be tested belongs;
[0047] A determination module, configured to determine an associated business system corresponding to the target business system; in multiple preset production traffic files, determine a first production traffic file corresponding to the target business system and the associated business system; obtain a test keyword corresponding to the function to be tested;
[0048] A screening module, configured to determine a second production traffic file corresponding to the test keyword in multiple first production traffic files;
[0049] A generation module, configured to generate a test case corresponding to the function to be tested according to the second production traffic file.
[0050] In some embodiments, the screening module is specifically configured to:
[0051] Obtain attribute information of multiple first production traffic files;
[0052] Divide multiple first production traffic files into multiple traffic file sets according to the attribute information;
[0053] Determine business keywords corresponding to each traffic file set;
[0054] Determine the association degree between the test keyword and each business keyword;
[0055] According to the association degree, determine a target business keyword among multiple business keywords;
[0056] Use the first production traffic file in the traffic file set corresponding to the target business keyword as the second production traffic file.
[0057] In some embodiments, the screening module is further configured to:
[0058] Obtain a preset topology relationship graph including multiple preset test keywords and multiple preset business keywords;
[0059] In the preset topology relationship graph, determine the node distance between the test keyword and the business keyword;
[0060] According to the node distance, determine the association degree between the test keyword and the business keyword.
[0061] In some embodiments, the generation module is specifically configured to:
[0062] Obtain the expected test duration corresponding to the function to be tested and the resource configuration information corresponding to the target business system;
[0063] According to the expected test duration and the resource configuration information, determine the corresponding expected number of traffic files;
[0064] Among the multiple second production traffic files, determine a third production traffic file that matches the expected number of traffic files;
[0065] Generate test cases corresponding to the function to be tested according to the third production traffic file.
[0066] In some embodiments, the generation module is further configured to:
[0067] Determine the second business systems to which each of the second production traffic files belongs;
[0068] Determine the degree of association between the second business system and the target business system;
[0069] Determine the traffic file ratio corresponding to the second business system according to the degree of association;
[0070] Determine the number of third production traffic files that the second business system should include according to the traffic file ratio corresponding to the second business system and the expected number of traffic files;
[0071] Among the multiple second production traffic files corresponding to the second business system, determine a third production traffic file that matches the number of third production traffic files that the second business system should include.
[0072] In some embodiments, the generation module is further configured to:
[0073] Determine the data interaction link corresponding to the function to be tested;
[0074] Determine the routing table distance between the second business system and the target business system according to the data interaction link;
[0075] Determine the degree of association between the second business system and the target business system according to the routing table distance.
[0076] In some embodiments, the generation module is further configured to:
[0077] Determine the data interaction link corresponding to the function to be tested;
[0078] Determine the associated business system corresponding to the target business system according to the business systems passed by the data interaction link.
[0079] In some embodiments, the determination module is specifically configured to:
[0080] Obtain the test business scenario and test environment corresponding to the function to be tested;
[0081] Input the test business scenario and the test environment into a preset keyword generation model;
[0082] Obtain the test keywords output by the preset keyword generation model.
[0083] On the other hand, the present application also provides a computer device, which includes:
[0084] One or more processors;
[0085] A memory; and
[0086] One or more applications, where the one or more applications are stored in the memory and are configured to be executed by the processor to implement the steps in the generation method of any one of the test cases.
[0087] On the other hand, the present application also provides a computer-readable storage medium, on which a computer program is stored, and the computer program is loaded by a processor to execute the steps in the generation method of any one of the test cases.
[0088] The test case generation method, computer device, and computer-readable storage medium provided by the embodiments of the present application. The method includes: obtaining the target business system to which the function to be tested belongs; determining the associated business system corresponding to the target business system; determining the first production traffic file corresponding to the target business system and the associated business system among multiple preset production traffic files; obtaining the test keywords corresponding to the function to be tested; determining the second production traffic file corresponding to the test keywords among multiple first production traffic files; generating a test case corresponding to the function to be tested according to the second production traffic file. The embodiments of the present application screen out the first production traffic file from a large amount of production traffic through the business systems related to the function to be tested, and then match to obtain the second production traffic file based on the test keywords, avoiding generating test cases through all production traffic, thereby shortening the test time and improving the test efficiency. Description of the Drawings
[0089] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0090] Figure 1 It is a schematic flowchart of an embodiment of the test case generation method provided in the embodiments of the present application;
[0091] Figure 2 It is a schematic flowchart of another embodiment of the test case generation method provided in the embodiments of the present application;
[0092] Figure 3 It is another schematic flowchart of the method for generating test cases provided in the embodiments of the present application;
[0093] Figure 4 It is another schematic flowchart of the method for generating test cases provided in the embodiments of the present application;
[0094] Figure 5 It is a schematic structural diagram of an embodiment of the test case generation device provided in the embodiments of the present application;
[0095] Figure 6 It is a schematic terminal structure diagram of an embodiment of the computer device provided in the embodiments of the present application. Detailed implementation manners
[0096] 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.
[0097] In the description of the present application, it should be understood that the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus cannot be understood as a limitation to the present application. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more unless otherwise specifically defined.
[0098] In this application, the term "exemplary" is used to mean "serving as an example, illustration, or instance". Any embodiment described as "exemplary" in this application is not necessarily to be construed as more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use this application. In the following description, details are set forth for the purpose of explanation. It should be understood that those of ordinary skill in the art can recognize that this application can be implemented without these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid obscuring the description of this application with unnecessary details. Therefore, this application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
[0099] It should be noted that since the method of the embodiment of this application is executed in a computer device, the processing objects of each computer device exist in the form of data or information. For example, time, which is actually time information. It can be understood that in subsequent embodiments, if dimensions, quantities, positions, etc. are mentioned, they are all corresponding data existences for the computer device to process, and specific details are not elaborated here.
[0100] The embodiment of this application provides a method for generating test cases, a computer device, and a computer-readable storage medium, which will be described in detail below respectively.
[0101] Refer to Figure 1 , in one embodiment, the method for generating test cases includes:
[0102] 101. Obtain the target business system to which the function to be tested belongs;
[0103] In this embodiment, in order to meet new business requirements, it is often necessary to improve existing functions or add new functions to the business system. At this time, these functions can be used as the functions to be tested, and their functions, performance, stability, etc. can be tested through test cases. After successful testing, the function to be tested can be launched. In the financial industry such as banks, there are often multiple different business systems, such as a cashier business system, a transaction business system, an accounting business system, etc. Through the mutual cooperation between multiple different business systems, various financial business requirements of users can be realized. Therefore, it is necessary to determine the target business system to which the function to be tested belongs. For example, the cashier business system may include a user login function, the transaction business system may include a quick payment function, a transfer function, etc., and the accounting business system may include a cash withdrawal function. It can be seen that each function can belong to at least one business system. According to the business design logic of the function to be tested, at least one target business system to which the function to be tested belongs can be determined.
[0104] 102. Determine the associated business system corresponding to the target business system;
[0105] In this embodiment, after determining the target business system, an associated business system associated with the target business system can be determined. Among them, the associated business system can be other business systems that have a data call relationship with the target business system. When determining the associated business system, it can be determined according to the data call relationship between business systems.
[0106] In some embodiments, since the function to be tested is being tested, when determining the associated business system, the data interaction link corresponding to the function to be tested can also be determined first. It can be understood that the data interaction link is the network path that data needs to pass through when implementing the function to be tested. For example, when the function to be tested is a transfer function, the function to be tested can call the cashier business system to verify the account number of the user's login. After successful verification, it calls the transaction business system to trigger a transfer instruction, and then verifies whether the transfer action can be realized through the accounting business system, such as verifying whether the transfer amount is sufficient. When it is verified that the transfer action can be realized, a corresponding transfer record can be generated to complete the transfer process. The network path that data passes through during this process is the data interaction link. According to the data interaction link, it can be determined which business systems the data has passed through. Based on the business systems passed through by the data interaction link, the associated business system corresponding to the target business system can be determined. For example, all business systems passed through by the data interaction link can be used as the associated business system. In this way, through the data interaction link corresponding to the function to be tested, the associated business system can be determined more accurately.
[0107] 103. Among multiple preset production traffic files, determine a first production traffic file corresponding to the target business system and the associated business system;
[0108] In this embodiment, the preset production traffic file is the real traffic generated by multiple business systems of a bank during actual use. The production traffic can be adopted and saved as the corresponding preset production traffic file for generating test cases. Among a large number of preset production traffic files, multiple first production traffic files associated with the target business system and the associated business system are screened out. Among them, the first production traffic file associated with the target business system and the associated business system can include the production traffic sent to the target business system and the associated business system, the production traffic sent from the target business system and the associated business system, and the production traffic generated by the target business system and the associated business system.
[0109] In some embodiments, in the step of determining the first production traffic file associated with the target business system and the associated business system, the attribute information such as the interface number and channel number of the preset production traffic file can be analyzed to determine which business system the preset production traffic file is associated with.
[0110] 104. Obtain test keywords corresponding to the function to be tested;
[0111] In this embodiment, the corresponding test keywords can be determined according to the function description information or business content of the function to be tested. Of course, the test keywords can also be manually input, or according to the industry to which the function to be tested belongs, such as industries like banks, etc., multiple preset test keywords are set in advance for manual selection of at least one preset test keyword as the test keyword corresponding to the function to be tested. It can be understood that the test keywords corresponding to the function to be tested represent the function or business of the function to be tested. For example, the test keywords can be login, transfer, cash withdrawal, etc.
[0112] 105. Determine the second production traffic file corresponding to the test keyword among the multiple first production traffic files;
[0113] In this embodiment, the multiple first production traffic files are screened by the test keyword to determine the second production traffic file related to the test keyword. Specifically, the business attribute information of the second production traffic file can be analyzed, such as the business identification code, to determine the business keyword corresponding to the second production traffic file, and the corresponding second production traffic file is obtained by matching the similarity between the business keyword and the test keyword.
[0114] 106. Generate test cases corresponding to the function to be tested according to the second production traffic file.
[0115] In this embodiment, after determining the second production traffic file, test cases for testing the function to be tested can be generated based on the second production traffic file. Specifically, the second production traffic file can be recorded for traffic to obtain a traffic recording file, and the traffic recording file can be used as a test case for execution for subsequent playback testing.
[0116] In the technical solution disclosed in this embodiment, through the business system related to the function to be tested, the first production traffic file is screened out from a large amount of production traffic, and then the second production traffic file is obtained by matching based on the test keyword, avoiding generating test cases through all production traffic, thereby shortening the test time and improving the test efficiency.
[0117] In another embodiment, as Figure 2 shown, on the basis of the embodiment shown in Figure 1 the step 105 includes:
[0118] 201. Obtain the attribute information of the multiple first production traffic files;
[0119] In this embodiment, each first production traffic file has attribute information, which may include technical attributes such as interface numbers and channel numbers, and may also include business attributes such as scenario identification codes and enumerated values.
[0120] 202. Divide the multiple first production traffic files into multiple traffic file sets according to the attribute information;
[0121] In this embodiment, according to the differences in attribute information, the multiple generated first production traffic files are segmented to obtain multiple production traffic file blocks, and each production traffic file block is a traffic file set. Among them, the first production traffic files in the same traffic file set have at least the same attribute information. For example, according to the differences in scenario identification codes, the multiple generated first production traffic files can be divided for the first time, and then for the multiple traffic file sets obtained from the first division, according to the differences in channel numbers, each traffic file set is divided for the second time, and then for the multiple traffic file sets obtained from the second division, according to the differences in interface numbers, each traffic file set is divided for the third time. Through the three divisions, the multiple first production traffic files in the same traffic file set correspond to similar business contents.
[0122] 203. Determine the business keywords corresponding to each of the traffic file sets;
[0123] In this embodiment, the same attribute information of the first production traffic files in the traffic file set can be analyzed to determine the business keywords corresponding to the traffic file set. Among them, the business keywords represent the business contents associated with the traffic files. For example, the business keywords can be user names, login passwords, amounts, bank card numbers, transaction passwords, etc.
[0124] 204. Determine the correlation degree between the test keywords and each of the business keywords;
[0125] In this embodiment, the correlation degree between the test keywords and each business keyword can be calculated according to the similarity between texts or the relevance between contents. Generally speaking, when the similarity between texts or the relevance between contents is greater, the corresponding correlation degree is also greater. For example, when the test keyword is "login" and the business keyword is "login password", the text similarity between the two is relatively high. When the test keyword is "cash withdrawal" and the business keyword is "transaction password", the content relevance between the two is relatively high.
[0126] In some embodiments, the text similarity can be determined by means such as the Naive Bayes classifier and Euclidean distance.
[0127] In some embodiments, the relevance between contents can be determined according to a preset topological relationship diagram set in advance. Specifically, according to the domain knowledge of the industry to which the function to be tested belongs, professional vocabulary in the industry can be accumulated, and some of the vocabulary can be manually selected as preset test keywords and preset business keywords. According to the business design logic, the relationship between the preset test keywords and the preset business keywords can be determined. For example, there is a business association between preset test keyword A and preset business keyword B, preset test keyword A includes preset test keyword C, preset business keyword B includes preset test keyword D, etc., and a corresponding preset topological relationship diagram can be generated. Among them, both the preset test keywords and the preset business keywords are nodes in the preset topological relationship diagram. When determining the degree of association between the test keywords and the business keywords, the node positions of the test keywords and the business keywords in the preset topological relationship diagram can be determined respectively, and the number of nodes between the node positions can be used as the node distance. The node distance represents the relevance between contents, so the degree of association between the test keywords and the business keywords can be determined according to the node distance. Generally speaking, when the node distance is smaller, the degree of association between the test keywords and the business keywords is greater.
[0128] 205. Determine a target business keyword among the multiple business keywords according to the degree of association;
[0129] 206. Use the first production traffic file in the traffic file set corresponding to the target business keyword as the second production traffic file.
[0130] In this embodiment, after determining the degree of association between each business keyword and the test keyword, the target business keyword among the multiple business keywords can be screened according to the magnitude of the degree of association. Specifically, the sum of the degrees of association between the multiple business keywords corresponding to the traffic file set and the multiple test keywords can be calculated, and the business keywords corresponding to the multiple traffic file sets can be sorted from largest to smallest according to the sum of the degrees of association, and the business keywords corresponding to the top preset number of traffic file sets can be used as the target business keywords. The first production traffic files in the traffic file sets corresponding to the target business keywords are all used as the second production traffic files, realizing the screening of the production traffic files.
[0131] In the technical solution disclosed in this embodiment, the multiple first production traffic files are divided according to the attribute information, and the second production traffic files are screened according to the degree of association between the business keywords corresponding to the traffic file set and the test keywords, realizing the accurate screening of the production traffic related to the function to be tested and improving the test efficiency.
[0132] In yet another embodiment, as Figure 3 shown, in Figures 1 to 2Based on any of the embodiments, step 106 includes:
[0133] 301. Obtain the expected test duration corresponding to the function to be tested, and the resource configuration information corresponding to the target business system;
[0134] 302. Determine the corresponding expected number of traffic files according to the expected test duration and the resource configuration information;
[0135] In this embodiment, in order to better control the test of the function to be tested, the expected test duration can also be set manually. Since the higher the resource configuration of the business system, the faster the data processing speed and instruction response speed of the business system, therefore, the corresponding expected number of traffic files can be comprehensively determined according to the expected test duration and the resource configuration information corresponding to the target business system. Among them, the resource configuration information may include the number of processor cores and threads, bandwidth, data transfer rate of the memory, capacity of the operating memory, etc. of the target business system. The expected number of traffic files represents how many production traffic files should be used to generate the test cases corresponding to the function to be tested so that the actual test duration of the function to be tested can reach the expected test duration.
[0136] In some embodiments, the mapping relationship between the test duration, resource configuration information, and the number of traffic files can be summarized based on the historical test data of the historical functions to be tested. Based on this mapping relationship, the expected number of traffic files corresponding to the expected test duration and the resource configuration information is determined.
[0137] 303. Among the multiple second production traffic files, determine the third production traffic file that matches the expected number of traffic files;
[0138] 304. Generate the test cases corresponding to the function to be tested according to the third production traffic file.
[0139] In this embodiment, the third production traffic file with the expected number of traffic files is screened out from the multiple second production traffic files, and the test cases are generated according to the screened third production traffic file. In this way, the actual test duration of the function to be tested can be closer to the expected test duration, realizing the test control of the function to be tested.
[0140] In some embodiments, in the step of screening out the third production traffic files with the expected number of traffic files from multiple second production traffic files, the business system to which each second production traffic file belongs, i.e., the second business system, can be determined first. Determine the degree of association between the second business system and the target business system. According to the degree of association, determine how many production traffic files need to be screened out from the second production traffic files of the second business system as the third production traffic files. Specifically, the traffic file ratio corresponding to the second business system can be determined according to the degree of association. According to the traffic file ratio corresponding to the second business system and the expected number of traffic files, determine the number of third production traffic files that the second business system should contain, and in the multiple second production traffic files corresponding to the second business system, determine the third production traffic files that match the number of third production traffic files that the second business system should contain. Among them, the product of the traffic file ratio corresponding to the second business system and the expected number of traffic files can be used as the number of third production traffic files that the second business system should contain. In this way, more or fewer production traffic files can be screened out according to the degree of association between business systems, making the screening of production traffic files more reasonable, and the test results of the functions to be tested can also be more accurate.
[0141] In some embodiments, when determining the traffic file ratio corresponding to the second business system according to the degree of association, the sum of the degrees of association between all second business systems and the target business system can be calculated first, and the ratio of the degree of association between the second business system and the target business system to the sum of the degrees of association is used as the traffic file ratio corresponding to the second business system.
[0142] In some embodiments, in the step of determining the degree of association between the second business system and the target business system, the data interaction link corresponding to the function to be tested can be determined first. According to the data interaction link, determine the routing table distance between the second business system and the target business system. According to the routing table distance, determine the degree of association between the second business system and the target business system. Generally speaking, when the routing table distance is smaller, the degree of association between the second business system and the target business system is larger. Among them, according to the data interaction link, it can be determined which business systems the data passes through. According to the sequence of the business systems passed by the data, the routing table distance between the business systems passed by the data can be determined, so as to determine the routing table distance between the second business system and the target business system.
[0143] In the technical solution disclosed in this embodiment, according to the expected test duration and the resource configuration information corresponding to the target business system, the corresponding expected number of traffic files is determined. Among multiple second production traffic files, the third production traffic files that match the expected number of traffic files are screened out, realizing the screening of a specified number of production traffic files, and the test duration of the function to be tested can be more conveniently controlled.
[0144] In yet another embodiment, as Figure 4 shown, based on any of the embodiments, step 104 includes: Figures 1 to 3 On the basis of any of the embodiments shown, step 104 includes:
[0145] 401. Obtain a test business scenario and a test environment corresponding to the function to be tested;
[0146] In this embodiment, in the step of determining the test keywords corresponding to the function to be tested, multiple different test business scenarios and test environments can be set in advance for manual selection of at least one test business scenario and at least one test environment. Among them, the test business scenario can include specific business contents, such as a login scenario, a transfer scenario, a cash withdrawal scenario, etc., and the test environment can include a situation where the business system has a high load, a network failure of the business system, a normal business system, etc.
[0147] 402. Input the test business scenario and the test environment into a preset keyword generation model;
[0148] 403. Obtain the test keywords output by the preset keyword generation model.
[0149] In this embodiment, a data model is trained according to the pre-set test business scenarios, test environments and corresponding test keywords to obtain a preset keyword generation model. By inputting the specified test business scenario and test environment into the preset keyword generation model, in this way, the preset keyword generation model can output the expected test keywords. Among them, the preset keyword generation model can be a deep learning model or a machine learning model, for example, a Convolutional Neural Networks (CNN), a De-Convolutional Networks (DN), etc. For example, when the test business scenario is a login scenario and the test environment is a situation where the business system has a high load, the test keywords output by the preset keyword generation model can be login timeout; when the test business scenario is a transfer scenario and the test environment is a network failure of the business system, the test keywords output by the preset keyword generation model can be transfer failure; when the test business scenario is a cash withdrawal scenario and the test environment is a normal business system, the test keywords output by the preset keyword generation model can be cash withdrawal successful.
[0150] In some embodiments, the test keywords output by the preset keyword generation model may further include synonyms of the input test business scenario and test environment and other words related to the content. Specifically, the synonyms and other words related to the content can be determined according to the knowledge graph of relevant industries such as banks.
[0151] In the technical solution disclosed in this embodiment, the test business scenario and test environment corresponding to the function to be tested are input into a preset keyword generation model, and the test keywords output by the preset keyword generation model are obtained, so that the generation of test keywords is more accurate and complete.
[0152] To better implement the test case generation method in the embodiments of the present application, on the basis of the test case generation method, the embodiments of the present application also provide a test case generation device, as Figure 5 shown. The test case generation device 500 includes an acquisition module 501, a determination module 502, a screening module 503, and a generation module 504, which are specifically as follows:
[0153] The acquisition module 501 is configured to acquire the target business system to which the function to be tested belongs;
[0154] The determination module 502 is configured to determine the associated business system corresponding to the target business system; in multiple preset production traffic files, determine the first production traffic file corresponding to the target business system and the associated business system; and acquire the test keywords corresponding to the function to be tested;
[0155] The screening module 503 is configured to determine the second production traffic file corresponding to the test keywords in multiple first production traffic files;
[0156] The generation module 504 is configured to generate test cases corresponding to the function to be tested according to the second production traffic file.
[0157] The embodiments of the present application also provide a computer device, which integrates any test case generation device provided in the embodiments of the present application. As Figure 6 shown, it shows the structural schematic diagram of the computer device involved in the embodiments of the present application. Specifically:
[0158] The computer device may include a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, a power supply 603, an input unit 604, and other components. Those skilled in the art can understand that Figure 6 the structural schematic diagram of the computer device shown in
[0159] The processor 601 is the control center of the computer device, connecting various parts of the entire computer device through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 602, and by invoking the data stored in the memory 602, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 601 may include one or more processing cores; preferably, the processor 601 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 601 either.
[0160] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and data processing by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.); the data storage area can store data created according to the use of the computer device. In addition, the memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage devices. Correspondingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.
[0161] The computer device also includes a power supply 603 that powers each component. Preferably, the power supply 603 can be logically connected to the processor 601 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 603 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0162] The computer device may also include an input unit 604, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0163] Although not shown, the computer device may also include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 601 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 601 will run the application programs stored in the memory 602 to realize various functions as follows:
[0164] Obtain the target business system to which the function to be tested belongs;
[0165] Determine the associated business system corresponding to the target business system;
[0166] Among multiple preset production traffic files, determine the first production traffic file corresponding to the target business system and the associated business system;
[0167] Obtain the test keyword corresponding to the function to be tested;
[0168] Among multiple first production traffic files, determine the second production traffic file corresponding to the test keyword;
[0169] Generate test cases corresponding to the function to be tested according to the second production traffic file.
[0170] 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 related hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0171] Therefore, an embodiment of the present application provides a computer-readable storage medium, which may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), a magnetic disk or an optical disc, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any of the test case generation methods provided by the embodiments of the present application. For example, when the computer program is loaded by a processor, the following steps may be executed:
[0172] Obtain the target business system to which the function to be tested belongs;
[0173] Determine the associated business system corresponding to the target business system;
[0174] Among multiple preset production traffic files, determine the first production traffic file corresponding to the target business system and the associated business system;
[0175] Obtain the test keyword corresponding to the function to be tested;
[0176] Among multiple first production traffic files, determine the second production traffic file corresponding to the test keyword;
[0177] Generate test cases corresponding to the function to be tested according to the second production traffic file.
[0178] In the above embodiments, the descriptions of the respective embodiments each have their own emphasis. For parts not detailed in a certain embodiment, reference may be made to the detailed descriptions of other embodiments above, and details will not be repeated here.
[0179] In specific implementation, the above units or structures can be implemented as independent entities, or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation of the above units or structures, reference may be made to the method embodiments above, and details will not be repeated here.
[0180] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, and details will not be repeated here.
[0181] The above has introduced in detail a method for generating test cases, a computer device, and a computer-readable storage medium provided by an embodiment 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 method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for generating test cases, characterized in that, Including: Obtain the target business system to which the function to be tested belongs; Determine the associated business system corresponding to the target business system; Among multiple preset production traffic files, determine the first production traffic file corresponding to the target business system and the associated business system; Obtain the test keyword corresponding to the function to be tested; Among multiple first production traffic files, determine the second production traffic file corresponding to the test keyword; Generate a test case corresponding to the function to be tested according to the second production traffic file; The step of determining the second production traffic file corresponding to the test keyword among multiple first production traffic files includes: obtaining the attribute information of multiple first production traffic files; dividing multiple first production traffic files into multiple traffic file sets according to the attribute information; determining the business keywords corresponding to each traffic file set; determining the association degree between the test keyword and each business keyword; according to the association degree, determining the target business keyword among multiple business keywords; using the first production traffic file in the traffic file set corresponding to the target business keyword as the second production traffic file; The step of generating a test case corresponding to the function to be tested according to the second production traffic file includes: obtaining the expected test duration corresponding to the function to be tested and the resource configuration information corresponding to the target business system; determining the corresponding expected number of traffic files according to the expected test duration and the resource configuration information; among multiple second production traffic files, determining the third production traffic file matching the expected number of traffic files; generating a test case corresponding to the function to be tested according to the third production traffic file.
2. The method for generating test cases according to claim 1, wherein, The step of determining the association degree between the test keyword and each business keyword includes: Obtain a preset topology relationship graph including the relationship between multiple preset test keywords and multiple preset business keywords; In the preset topology relationship graph, determine the node distance between the test keyword and the business keyword; Determine the association degree between the test keyword and the business keyword according to the node distance.
3. The method for generating test cases according to claim 1, wherein The step of determining the third production traffic file matching the expected number of traffic files among multiple second production traffic files includes: Determine the second business system to which each second production traffic file belongs; Determine the association degree between the second business system and the target business system; Determine the traffic file ratio corresponding to the second business system according to the association degree; Determine the number of third production traffic files that the second business system should include according to the traffic file ratio corresponding to the second business system and the expected number of traffic files; Among multiple second production traffic files corresponding to the second business system, determine the third production traffic file matching the number of third production traffic files that the second business system should include.
4. The method for generating test cases according to claim 3, wherein The step of determining the association degree between the second business system and the target business system includes: Determine the data interaction link corresponding to the function to be tested; Determine the routing table distance between the second service system and the target service system according to the data interaction link; Determine the association degree between the second service system and the target service system according to the routing table distance.
5. The method for generating test cases according to claim 4, wherein, The step of determining the associated service system corresponding to the target service system includes: Determine the data interaction link corresponding to the function to be tested; Determine the associated service system corresponding to the target service system according to the service systems passed by the data interaction link.
6. The method for generating test cases according to claim 1, wherein, The step of obtaining the test keyword corresponding to the function to be tested includes: Obtain the test service scenario and test environment corresponding to the function to be tested; Input the test service scenario and the test environment into a preset keyword generation model; Obtain the test keyword output by the preset keyword generation model.
7. A computer device, characterized in that, The computer device includes: One or more processors; A memory; and One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to implement the steps in the method for generating a test case according to any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program is loaded by the processor to execute the steps in the method for generating a test case according to any one of claims 1 to 6.
Citation Information
Patent Citations
Test case generation and test method and device, apparatus and system
CN110221965A
Method for generating automatic test case based on traffic recording
CN112749100A