Test case generation method, device, system, offline server and storage medium

By extracting the matching and adjustment of the use case characteristics of online test data and offline test cases, use cases suitable for offline tests are generated, which solves the problem of difficulty in using online test data, and achieves the reduction of data differences and code invasiveness. Reduce, improves the universality of test cases.

CN113297061BActive Publication Date: 2024-11-19ZHEJIANG TMALL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010473476.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-29
Publication Date
2024-11-19
Estimated Expiration
2040-05-29

Smart Images

  • Figure CN113297061B_ABST
    Figure CN113297061B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a test case generation method, device, system, server and storage medium, the method comprising: obtaining online test data; extracting the use case features of the online test data from the online test data; matching the use case features of the online test data with the use case features of the generated offline test cases; determining, based on the matching results, offline test cases similar to the online test data from the offline test cases as target offline test cases; and performing data adjustment on the online test data at least based on the target offline test cases to obtain offline test cases corresponding to the online test data. The test case generation method provided in the embodiments of the present application can generate offline test cases based on online test data, and has less code intrusion into the business system, and can have high versatility in engineering implementation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of testing technology, and specifically to a test case generation method, device, system, offline server and storage medium. Background Art

[0002] Before the business system and other tested objects go online, the functions that need to be launched by the tested objects need to be tested online in an online pre-release environment (such as an online test field). After the online test passes, the functions that need to be launched by the tested objects can be officially released for large-scale use by users. The online pre-release environment referred to here can be considered to be a low-traffic online environment based on real user data.

[0003] The online tests conducted in the online test field are mainly implemented based on the online test data of the online pre-release environment. In order to further utilize the online test data, the inventor of this application considers generating offline test cases based on the online test data, and then in the offline test environment, the offline test cases generated based on the online test data can be used to achieve further utilization of the online test data. Therefore, how to provide a solution for generating offline test cases based on online test data has become a problem that needs to be urgently solved by technical personnel in this field. Summary of the invention

[0004] In view of this, embodiments of the present application provide a test case generation method, device, system, offline server and storage medium to generate offline test cases based on online test data.

[0005] To achieve the above objectives, the present application provides the following technical solutions:

[0006] A test case generation method, comprising:

[0007] Get online test data;

[0008] Extracting use case features of the online test data from the online test data;

[0009] Matching the use case features of the online test data with the use case features of the generated offline test cases;

[0010] According to the matching result, determining offline test cases similar to the online test data from the offline test cases as target offline test cases;

[0011] The online test data is adjusted at least according to the target offline test case to obtain an offline test case corresponding to the online test data.

[0012] The present application also provides a test case generation device, including:

[0013] An online test data acquisition module is used to acquire online test data;

[0014] A feature extraction module, used to extract use case features of the online test data from the online test data;

[0015] A matching module, used to match the use case features of the online test data with the use case features of the generated offline test cases;

[0016] A target offline test case determination module, configured to determine, according to the matching result, an offline test case similar to the online test data from the offline test cases as a target offline test case;

[0017] The adjustment module is used to perform data adjustment on the online test data at least according to the target offline test case to obtain the offline test case corresponding to the online test data.

[0018] The embodiment of the present application also provides a test case generation system, including: an online test server, and an offline server;

[0019] The online test server is used to perform online testing on the business system, and when the test results meet the expected results, integrate the online test data and transmit the online test data to the offline server;

[0020] The offline server is used to obtain online test data transmitted by the online test server; extract use case features of the online test data from the online test data; match the use case features of the online test data with the use case features of the generated offline test cases; determine, based on the matching result, offline test cases similar to the online test data from the offline test cases as target offline test cases; and perform data adjustment on the online test data at least based on the target offline test cases to obtain offline test cases corresponding to the online test data.

[0021] The embodiment of the present application also provides an offline server, including:

[0022] at least one memory for storing one or more computer executable instructions;

[0023] At least one processor is used to call the one or more computer executable instructions to execute the test case generation method as described above.

[0024] An embodiment of the present application also provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the test case generation method as described above.

[0025] The test case generation method provided in the embodiment of the present application can obtain online test data and extract the use case features of the online test data from the online test data; thereby, on the basis of determining the use case features of the generated offline test cases, the embodiment of the present application can match the use case features of the online test data with the use case features of the generated offline test cases, and according to the matching results, determine the offline test cases similar to the online test data from the offline test cases as the target offline test cases; and then, perform data adjustment on the online test data at least according to the target offline test cases to obtain the offline test cases corresponding to the online test data, thereby achieving the purpose of generating offline test cases based on the online test data.

[0026] The embodiment of the present application determines the target offline test case similar to the online test data from the generated offline test case by matching the online test data with the use case features of the generated offline test case, thereby adjusting the online test data according to the target offline test case, so that the data difference between the offline test case obtained after the data adjustment and the target offline test case is smaller, and the data difference between the online test and the offline test can be reduced, so that the offline test case obtained after the data adjustment can be applicable to the offline test environment. It can be seen that the embodiment of the present application uses the method of use case feature matching to determine the target offline test case similar to the online test data from the generated offline test case, thereby adjusting the online test data using the target offline test case, so as to realize the generation of offline test cases based on the online test data. Therefore, the test case generation method provided by the embodiment of the present application has less code intrusion on the business system and can have high versatility in engineering implementation. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0028] Figure 1 A flowchart of a test case generation method provided in an embodiment of the present application;

[0029] Figure 2 An example diagram of the process of online testing provided in an embodiment of the present application;

[0030] Figure 3 Another flow chart of the test case generation method provided in the embodiment of the present application;

[0031] Figure 4 A block diagram of a test case generation system provided in an embodiment of the present application;

[0032] Figure 5 An example diagram of the process of generating offline test cases based on online test data provided in an embodiment of the present application;

[0033] Figure 6 A block diagram of a test case generation device provided in an embodiment of the present application;

[0034] Figure 7 A block diagram of an offline server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] The main difference between online testing and offline testing lies in the difference in data. Specifically, online testing is based on real user data with small traffic in the online pre-release environment, while the data for offline testing is often constructed. Therefore, in order to narrow the data difference between online and offline testing, the traditional way to generate offline test cases based on online test data is often to first identify the real user data for online testing, and then return the real user data to the offline to form offline test cases. This traditional method can obtain the real user data for online testing based on log tracking. Specifically, data nodes in the object under test (such as a business system) are tracked, so that during the online testing process, the data collected by the tracking is recorded in the log, and then the real user data related to the online test is obtained by parsing the log. The real user data is returned to the offline to form offline test cases based on real user data.

[0036] The above-mentioned method of generating offline test cases based on online test data requires tracking of the object under test, which is highly code-invasive to the object under test, resulting in poor versatility in its implementation in engineering. Based on this, the embodiment of the present application provides an improved test case generation scheme to generate offline test cases based on online test data, and can reduce the code invasiveness of the object under test and improve the versatility of the test case generation scheme in engineering implementation.

[0037] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0038] In an optional implementation, Figure 1An optional process of the test case generation method provided in an embodiment of the present application is shown, and the process may be optionally executed by an offline server. Optionally, the offline server may be an offline server for generating offline test cases; Figure 1 As shown, the process may include:

[0039] Step S100: Obtain online test data.

[0040] Optionally, after performing an online test on the object under test, if the test result of the object under test meets the expected result, the embodiment of the present application can obtain online test data related to the online test.

[0041] Optional, Figure 2 This example illustrates the process of online testing. Figure 2 The online testing process shown can be implemented based on an online domain (such as an online pre-release environment); specifically, after executing the test on the test request data input into the business system, the business system can output the test result data based on the online pre-release environment. If the test result data is consistent with the expected result, it can be determined that the online test has passed, so that the data related to the online test can be integrated to obtain the online test data, and the online test data can be returned to the offline and obtained by the offline server; if the test result data is inconsistent with the expected result, it can be determined that the online test has failed, and the online test can be performed again after debugging until the online test passes, and the data related to the online test is integrated to obtain the online test data, and the online test data is returned to the offline and obtained by the offline server.

[0042] It can be seen that the online test data obtained based on the integration of the online pre-release environment can flow back to the offline domain (ie, the offline environment), so that the online test data can be obtained by the offline server.

[0043] In an optional implementation, the online test data may include: test request data of the online test, test result data and service description data, etc.

[0044] Step S110: extracting use case features of the online test data from the online test data.

[0045] It should be noted that by extracting use case features from the use case content of the test case, the use case features of the test case can be obtained; for example, the test case has multi-dimensional use case content, and by extracting use case features from the multi-dimensional use case content of the test case respectively, the use case features of the test case in the multi-dimensional can be obtained, and the use case features of one dimension can represent the features of the use case content of the test case in that dimension.

[0046] With respect to the online test data acquired in step S100, the embodiment of the present application can extract use case features from the data content of each dimension of the online test data, thereby extracting use case features of the online test data from the online test data.

[0047] In an optional implementation, an embodiment of the present application may pre-set at least one use case feature type, and the use case feature of a use case feature type may represent the use case feature corresponding to the use case content of the test case in one dimension. Therefore, based on the preset at least one use case feature type, an embodiment of the present application may extract the use case features of each use case feature type from the online test data to realize the extraction of the use case features of the online test data from the online test data.

[0048] Step S120: Match the use case features of the online test data with the use case features of the generated offline test cases.

[0049] The embodiment of the present application can store the generated offline test cases, and the number of the generated offline test cases can be multiple. In an optional implementation, the embodiment of the present application can store the generated offline test cases in a case library of the offline domain.

[0050] For any generated offline test case, the embodiment of the present application can pre-extract the use case features of the generated offline test case. For example, based on at least one preset use case feature type, the embodiment of the present application can pre-extract the use case features of the generated offline test case in each use case feature type.

[0051] After obtaining the use case features of the online test data and the use case features of the generated offline test cases, the embodiment of the present application can match the use case features of the online test data with the use case features of the generated offline test cases to determine the similarity between the online test data and the generated offline test cases.

[0052] In an optional implementation, the embodiment of the present application can match the use case features of the same use case feature type of the online test data with the generated offline test cases, so as to obtain the similarity between the use case features of the online test data and the generated offline test cases in each use case feature type, and then according to the similarity between the use case features of each use case feature type, the similarity between the online test data and the generated offline test cases can be determined, and the similarity can be used as the result of the matching in step S120. The above-mentioned processing is performed for any generated offline test case, and the embodiment of the present application can obtain the similarity between the online test data and any generated offline test case.

[0053] Step S130: According to the matching result, an offline test case similar to the online test data is determined from the offline test cases as a target offline test case.

[0054] Based on step S120, the online test data is matched with the use case features of any generated offline test case, and after the matching result of the online test data with any generated offline test case is obtained, the embodiment of the present application can determine, based on the matching result, a target offline test case that is similar to the online test data from the generated offline test cases; for example, based on the matching result, the embodiment of the present application can determine, from the generated offline test cases, an offline test case with the highest similarity to the online test data as the target offline test case; for example, based on the matching result, the embodiment of the present application can determine, from the generated offline test cases, a preset number of offline test cases with the greatest similarity to the online test data, and then further select the target offline test case from the preset number of offline test cases.

[0055] Step S140: perform data adjustment on the online test data at least according to the target offline test case to obtain an offline test case corresponding to the online test data.

[0056] After determining the target offline test cases that are similar to the online test data from the generated offline test cases, the embodiment of the present application can adjust the online test data based on the target offline test cases, so that the offline test cases obtained after the data adjustment have smaller data differences with the target offline test cases, thereby narrowing the data differences between online and offline tests and making the offline test cases obtained after the data adjustment applicable to offline test scenarios.

[0057] In an optional implementation, data adjustment of online test data according to the target offline test case can be: replacing the data content of the use case features extracted from the online test data at least according to the use case content of the use case features extracted from the target offline test case; that is, replacing the data content of the use case features extracted from the online test data based on the use case content of the use case features extracted from the target offline test case.

[0058] The test case generation method provided in the embodiment of the present application can obtain online test data and extract the use case features of the online test data from the online test data; thereby, on the basis of determining the use case features of the generated offline test cases, the embodiment of the present application can match the use case features of the online test data with the use case features of the generated offline test cases, and according to the matching results, determine the offline test cases similar to the online test data from the offline test cases as the target offline test cases; and then, perform data adjustment on the online test data at least according to the target offline test cases to obtain the offline test cases corresponding to the online test data, thereby achieving the purpose of generating offline test cases based on the online test data.

[0059] The embodiment of the present application determines the target offline test case similar to the online test data from the generated offline test case by matching the online test data with the use case features of the generated offline test case, thereby adjusting the online test data according to the target offline test case, so that the data difference between the offline test case obtained after the data adjustment and the target offline test case is smaller, and the data difference between the online test and the offline test can be reduced, so that the offline test case obtained after the data adjustment can be applicable to the offline test environment. It can be seen that the embodiment of the present application uses the method of use case feature matching to determine the target offline test case similar to the online test data from the generated offline test case, thereby adjusting the online test data using the target offline test case, so as to realize the generation of offline test cases based on the online test data. Therefore, the test case generation method provided by the embodiment of the present application has less code intrusion on the business system and can have high versatility in engineering implementation.

[0060] In a further optional implementation, Figure 3 Another process of the test case generation method provided in the embodiment of the present application is shown, and the process can be executed by an offline server, such as Figure 3 As shown, the process may include:

[0061] Step S200: Obtain online test data.

[0062] Step S210: extracting use case features of each use case feature type from the online test data according to at least one preset use case feature type.

[0063] A test case is a description of a test task, and may include use case contents such as a use case request, a use case expectation, a use case label, and a use case description; accordingly, the use case features of a test case may include a use case request feature corresponding to the use case request, a use case expectation feature corresponding to the use case expectation, a use case label feature corresponding to the use case label, and a use case description feature corresponding to the use case description. On this basis, the preset at least one use case feature type may include: a use case request feature type, a use case expectation feature type, a use case label feature type, and a use case description feature type; wherein the use case request feature type corresponds to the use case request feature, the use case expectation feature type corresponds to the use case expectation feature, the use case label feature type corresponds to the use case label feature, and the use case description feature type corresponds to the use case description feature. That is, in an optional implementation, the embodiment of the present application may pre-set the use case request feature type, the use case expectation feature type, the use case label feature type, and the use case description feature type, so as to extract the use case request feature corresponding to the use case request feature type, the use case expectation feature corresponding to the use case expectation feature type, the use case label feature corresponding to the use case label feature type, and the use case description feature corresponding to the use case description feature type of the online test data based on the preset multiple use case feature types.

[0064] It should be noted that the use case request feature is the use case feature obtained after feature extraction of the test request of the test case, and the use case expectation feature is the use case feature obtained after feature extraction of the expected result of the test case or the test result that is consistent with the expected result; for the use case request feature and the use case expectation feature, if the data in the test request or the expected result is in the json (JavaScript Object Notation, JS object notation) structure, the use case feature of the test request or the expected result can be in the form of parameters and values, and if the data in the test request or the expected result is in the url (uniform resource locator) form, the form of the use case feature can also be the standard structure of the url;

[0065] Use case label features such as test case priority labels, business scenario labels, etc. can be customized by users;

[0066] The use case description feature is obtained after feature extraction of the business keywords of the test case; for example, corpus analysis is performed on the use case description of the test case, and then TF-IDF (term frequency-inverse document frequency) processing is performed on the analysis result to determine the business keywords in the use case description, and feature extraction is performed on the business keywords to obtain the use case description feature.

[0067] Of course, the use case feature types described above are merely examples. The embodiments of the present application may pre-set the use case feature types according to actual conditions. For example, one or more feature types among the use case request feature type, the use case expectation feature type, the use case label feature type, and the use case description feature type may be pre-set, and not necessarily all of the above four use case feature types may be used.

[0068] Step S220: Match the use case features of the same use case feature type of the online test data and the offline test cases respectively to obtain the similarity between the use case features of the online test data and the offline test cases in each use case feature type.

[0069] For the generated offline test cases, the embodiment of the present application can pre-extract the use case features of the offline test cases in each use case feature type based on the preset use case feature type; thus, the embodiment of the present application can match the online test data with the use case features of the same use case feature type of the offline test cases, respectively, to obtain the similarity between the online test data and the use case features of the offline test cases in each use case feature type;

[0070] For example, the preset use case feature types may include: use case request feature type, use case expected feature type, use case label feature type, and use case description feature type; thus, the embodiment of the present application can extract the use case request features of the use case request feature type, the use case expected features of the use case expected feature type, the use case label features of the use case label feature type, and the use case description features of the use case description feature type of the online test data and the offline test cases, respectively, and then match the use case request features of the online test data and the offline test cases to obtain the similarity between the online test data and the offline test cases in the use case request features, match the use case expected features of the online test data and the offline test cases to obtain the similarity between the online test data and the offline test cases in the use case expected features, match the use case label features of the online test data and the offline test cases to obtain the similarity between the online test data and the offline test cases in the use case label features, and match the use case description features of the online test data and the offline test cases to obtain the similarity between the online test data and the offline test cases in the use case description features.

[0071] Of course, the above-mentioned preset use case feature types are only examples. No matter which use case feature type is used in the embodiment of the present application, the embodiment of the present application matches the use case features of the same use case feature type of the online test data and the offline test cases respectively.

[0072] Step S230: Determine the similarity between the online test data and the offline test case according to the similarity corresponding to the use case features of each use case feature type.

[0073] After obtaining the similarity between the online test data and the offline test cases in the use case features of each use case feature type, the embodiment of the present application can determine the similarity between the online test data and the offline test cases based on the similarity between the use case features of each use case feature type.

[0074] In an optional implementation, the embodiment of the present application may preset the weight of each use case feature, and different use case features have different weights. For example, the weight of the use case feature that has a greater impact on the similarity is higher, so the embodiment of the present application may multiply the similarity corresponding to each use case feature obtained in step S220 by the weight of the corresponding use case feature, and then accumulate the multiplication results to obtain the similarity between the online test data and the offline test case. The larger the value of the accumulated result, the higher the similarity between the online test data and the offline test case. In an optional example, assuming that use case feature 1, use case feature 2, ... and use case feature n are obtained based on the preset use case feature type, the embodiment of the present application may preset the weight 1 of use case feature 1, the weight 2 of use case feature 2 ... the weight n of use case feature n, so that the similarity between the online test data and an offline test case can be expressed as:

[0075] Similarity corresponding to use case feature 1 * weight 1 + similarity corresponding to use case feature 2 * weight 2 + … similarity corresponding to use case feature n * weight n.

[0076] Of course, the above-described method of calculating the similarity between online test data and offline test cases is only optional. The embodiments of the present application may also use other methods to calculate the similarity. For example, for any offline test case, directly add the similarities between the online test data and the offline test case corresponding to each case feature to obtain the similarity between the online test data and the offline test case.

[0077] Step S240: According to the similarity between the online test data and the offline test cases, a set number of offline test cases with the greatest similarity are determined from the offline test cases.

[0078] After calculating the similarity between the online test data and any offline test case, in an optional implementation, the embodiment of the present application can sort the offline test cases according to the similarity, determine a set number of offline test cases with the greatest similarity, and the set number of offline test cases can be used to select target offline test cases. The specific value of the set number can be set according to actual conditions, and the embodiment of the present application is not limited.

[0079] Step S250: Select a target offline test case from the set number of offline test cases.

[0080] The set number of offline test cases may be recommended to the user, and the user may select target offline test cases therefrom, so that the offline server may determine the target offline test cases based on the user's selection operation on the set number of offline test cases.

[0081] Optionally, steps S240 to S250 can be considered as an optional method of determining a target offline test case that is similar to the online test data from offline test cases based on the similarity between the online test data and the offline test cases. The embodiments of the present application may also use other methods to determine the target offline test case, such as directly selecting an offline test case with the greatest similarity from the offline test cases as the target offline test case.

[0082] Step S260: Replace the data content of the use case features extracted from the online test data at least according to the use case content of the use case features extracted from the target offline test case, so as to obtain the offline test case corresponding to the online test data.

[0083] After determining the target offline test cases that are similar to the online test data, the embodiments of the present application may adjust the online test data based on the target offline test cases. In an optional implementation, the embodiments of the present application may replace the data content of the corresponding use case features extracted from the online test data based on the use case content of the use case features extracted from the target offline test cases.

[0084] The embodiment of the present application adjusts the online test data based on the target offline test case that is similar to the online test data, which can reduce the data difference between the online test and the offline test, so that the offline test case obtained after the data adjustment can be applicable to the offline test scenario, and the purpose of generating offline test cases based on the online test data is achieved. Optionally, in order to further reduce the data difference between the online test and the offline test, the embodiment of the present application can also manually adjust the data related to the use case execution in the offline test case after the data adjustment, so that the offline test case finally obtained can better meet the expectations of the offline test.

[0085] It should be noted that in an optional application scenario, before the business system and other tested objects go online, it is necessary to first conduct offline testing on the functions that need to be launched by the tested objects in the offline environment. After the offline test passes, the functions that need to be launched by the tested objects are tested online in the online pre-release environment (equivalent to a small-scale functional experiment on the business system in the online environment). After the online test passes, the functions that need to be launched by the tested objects can be officially released for large-scale use by users. This testing process needs to go through offline testing and online testing successively, so that the functions that need to be launched by the tested objects can be officially released only after both the offline test and the online test pass. This undoubtedly has the problem of a relatively complicated testing process. Therefore, in the scenario of high-frequency iteration of the algorithm, the process of testing the functions that need to be launched by the tested objects is often to conduct online testing directly in the online pre-release environment, and then officially release the functions that need to be launched by the tested objects after the online test passes. However, this method does not take into account the difference between online testing and offline testing, resulting in low comprehensiveness of the test.

[0086] Based on this, the embodiment of the present application considers utilizing online test data, generating offline test cases based on the online test data of online tests, and on the basis of narrowing the data differences between online and offline tests, utilizing offline test cases generated based on online test data to perform regression testing on the functions that need to be put online of the object under test, so as to achieve the same effect of testing the functions that need to be put online of the object under test in an online pre-release environment.

[0087] Based on this idea, in order to reduce the code intrusion brought to the business system by generating offline test cases based on online test data, the embodiment of the present application uses the method of use case feature matching to determine the target offline test cases that are similar to the online test data from the generated offline test cases, and then uses the target offline test cases to adjust the online test data, so as to realize the generation of offline test cases based on online test data.

[0088] In an optional implementation, online test data can be obtained based on the online domain and flow back to the offline domain, so that offline test cases can be generated based on the online test data in the offline domain. Furthermore, in an optional application scenario, the embodiment of the present application can use offline test cases generated based on online test data to perform regression testing on the functions of the object under test that need to be put online; optionally, Figure 4 A test case generation system is shown, such as Figure 4 As shown, the system may include an online test server 10 and an offline server 20; wherein the online test server is located in an online domain, and the offline server is located in an offline domain.

[0089] Combination Figure 4 , Figure 5 An example diagram of the process of generating offline test cases based on online test data is shown in FIG. Figure 5 As shown, the offline domain can set up a use case library to store the generated offline test cases. Taking the preset use case feature types as the use case request feature type, the use case expectation feature type, the use case label feature type, and the use case description feature type as an example, the embodiment of the present application can extract use case features for the offline test cases in the use case library at a regular time (such as at a preset time every day). Specifically, the embodiment of the present application can regularly obtain offline test cases from the use case library, and extract the use case request features, use case expectation features, use case label features, and use case description features of the offline test cases.

[0090] The use case features of each use case feature type of offline test cases can be stored in the feature pool. The feature pool can be divided into different use case feature sets according to different use case feature types, such as Figure 5 As shown, the feature pool can be divided into a request feature set, an expected feature set, a label feature set and a use case description feature set, so that the embodiment of the present application can save the use case request features of the offline test case into the request feature set, save the use case expected features of the offline test case into the expected feature set, save the use case label features of the offline test case into the label feature set, and save the use case description features of the offline test case into the use case description feature set; wherein, the request feature set, the expected feature set, the label feature set and the use case description feature set can be recorded in a preset feature pool.

[0091] It should be noted that each use case feature set stores use case features of multiple generated offline test cases. In order to distinguish the use case features of different offline test cases, the embodiment of the present application may further carry the use case identifier (such as use case ID) of the offline test case in the use case feature set. For example, the request feature set may store the use case request features and the corresponding use case identifier of each offline test case, the expected feature set may store the use case expected features and the corresponding use case identifier of each offline test case, the label feature set may store the use case label features and the corresponding use case identifier of each offline test case, and the use case description feature set may store the use case description features and the corresponding use case identifier of each offline test case.

[0092] Continue to combine Figure 5 As shown, the embodiments of the present application can perform online testing in an online domain; specifically, the test request data used for online testing is input into an online business system, and the business system outputs test result data based on an online pre-release environment, so that the test result data can be compared with the expected results to see if they are consistent; if not, after debugging, the step of inputting the test request data into the business system is returned, and the online test is performed again; if they are consistent, the test request data, test result data, business description data, etc. of the online domain for online testing can be collected and integrated to obtain the online test data.

[0093] like Figure 5As shown, the online test data obtained by the online domain integration can flow back to the offline domain, and the use case features of the online test data can be extracted in the offline domain; specifically, in the embodiment of the present application, according to the use case request feature type, the use case request feature can be extracted from the test request data, according to the use case expected feature type, the use case expected feature can be extracted from the test result data, and according to the use case label feature type and the use case expected feature type, the use case label feature and the use case description feature can be extracted from the business description data respectively;

[0094] Based on extracting the use case features corresponding to each use case feature type of the online test data and storing the use case features corresponding to each use case feature type of the offline test cases in the feature pool, the embodiment of the present application can match the use case features of the online test data with the use case features corresponding to the generated offline test cases recorded in the feature pool; Figure 5 As shown, the embodiment of the present application can obtain the use case features of the offline test cases in each use case feature type from the feature pool, so as to match the online test data with the use case features of the same use case feature type of the offline test cases, respectively, to obtain the similarity corresponding to the use case features of the online test data and the offline test cases in each use case feature type; in an optional specific implementation, the embodiment of the present application can match the use case request features, use case expectation features and use case description features of the online test data and the offline test cases according to the maximum likelihood matching algorithm (such as the naive Bayes algorithm), respectively, to obtain the use case request feature similarity, use case expectation feature similarity and use case description feature similarity between the online test data and the offline test cases; and, match the value of the use case label feature of the online test data with the value of the use case label feature of the offline test case to obtain the use case label feature similarity between the online test data and the offline test case.

[0095] After obtaining the similarities between the online test data and the offline test case in the use case request features, use case expected features, use case label features and use case description features, for any offline test case, the embodiment of the present application can multiply the similarity corresponding to the use case request feature by the weight of the use case request feature, multiply the similarity corresponding to the use case expected feature by the weight of the use case expected feature, multiply the similarity corresponding to the use case label feature by the weight of the use case label feature, and multiply the similarity corresponding to the use case description feature by the weight of the use case description feature, so that the results of each multiplication are accumulated to obtain the similarity between the online test data and the offline test case.

[0096] like Figure 5 As shown, based on the similarity between the online test data and each offline test case, the embodiment of the present application can recommend a preset number of offline test cases with the greatest similarity from the offline test cases, so that the user can select the target offline test case from the recommended offline test cases.

[0097] like Figure 5 As shown, the embodiment of the present application can adjust the online test data based on the target offline test case, so as to obtain the offline test case corresponding to the online test data, and realize the generation of offline test cases based on the online test data.

[0098] In an optional implementation, the embodiment of the present application may replace the test request data of the online test data with the test request of the target offline test case, replace the test result data of the online test data with the expected result of the target offline test case, and replace the business description data of the online test data with the use case description of the target offline test case, so as to achieve data adjustment of the online test data.

[0099] It should be noted that the feature content of the use case features extracted from the target offline test case is used as the basis here, and replacing the data content of the use case features extracted from the online test data is only an optional way to adjust the data of the online test data. In another optional implementation, the scheme for adjusting the data of the online test data can also be customized. For example, when the test request data of the online test data includes multiple key-value pairs, the embodiment of the present application can retain the test request data, and the key-value pairs represent the online test experiment switch of the creative script business. At the same time, the test result data of the online test data is replaced with the expected result of the target offline test case, and the business description data of the online test data is replaced with the use case description of the target offline test case. It should be noted that the examples here illustrate some customized data adjustment schemes for some businesses. The test request data is a data structure of key-value pairs, which may represent the online test experiment switch of the creative script business. At this time, the test request data of the online test data can be retained, and the data content of other use case features extracted in the online test data is replaced based on the target offline test case.

[0100] Furthermore, based on the offline test cases generated from the online test data, the embodiments of the present application can perform regression testing on the functions of the object under test that need to be put online.

[0101] The embodiment of the present application utilizes a use case feature matching method to determine a target offline test case that is similar to the online test data from the generated offline test cases, thereby utilizing the target offline test case to perform data adjustment on the online test data, thereby realizing the generation of offline test cases based on the online test data. Therefore, the test case generation method provided in the embodiment of the present application has less code intrusion on the business system and can have a higher degree of versatility.

[0102] The following is an introduction to the test case generation device provided in the embodiment of the present application. The test case generation device described below can be considered as a functional module that the offline server needs to set up to implement the test case generation method provided in the embodiment of the present application. The content of the test case generation device described below can be referenced to the content of the test case generation method described above.

[0103] In an optional implementation, Figure 6 A block diagram of a test case generating device provided in an embodiment of the present application is shown. Figure 6 As shown, the device may include:

[0104] An online test data acquisition module 100 is used to acquire online test data;

[0105] A feature extraction module 110, configured to extract use case features of the online test data from the online test data;

[0106] A matching module 120, configured to match the use case features of the online test data with the use case features of the generated offline test cases;

[0107] A target offline test case determination module 130 is used to determine, according to the matching result, an offline test case similar to the online test data from the offline test cases as a target offline test case;

[0108] The adjustment module 140 is configured to perform data adjustment on the online test data at least according to the target offline test case to obtain an offline test case corresponding to the online test data.

[0109] Optionally, the feature extraction module 110, for extracting use case features of the online test data from the online test data, includes:

[0110] According to at least one preset use case feature type, use case features of each use case feature type are extracted from the online test data.

[0111] Optionally, the matching module 120, for matching the use case features of the online test data with the use case features of the generated offline test cases, includes:

[0112] Matching the online test data with the use case features of the same use case feature type of the offline test case respectively to obtain the similarity between the online test data and the use case features of each use case feature type of the offline test case;

[0113] The similarity between the online test data and the offline test case is determined according to the similarity corresponding to the use case features of each use case feature type.

[0114] Optionally, the target offline test case determination module 130 is used to determine, according to the matching result, offline test cases similar to the online test data from the offline test cases, as target offline test cases including:

[0115] According to the similarity between the online test data and the offline test cases, determining a preset number of offline test cases with the greatest similarity from the offline test cases;

[0116] A target offline test case is selected from the preset number of offline test cases.

[0117] Optionally, the adjustment module 140, configured to adjust the online test data at least according to the target offline test case, includes:

[0118] At least according to the use case content of the use case feature extracted from the target offline test case, the data content of the use case feature extracted from the online test data is replaced.

[0119] In an optional implementation, the at least one use case feature type includes: a use case request feature type, a use case expected feature type, a use case label feature type, and a use case description feature type; wherein the use case request feature type corresponds to the use case request feature, the use case expected feature type corresponds to the use case expected feature, the use case label feature type corresponds to the use case label feature, and the use case description feature type corresponds to the use case description feature.

[0120] Optionally, the online test data may include at least: test request data, test result data and business description data; accordingly, the feature extraction module 110 is used to extract the use case features of each use case feature type from the online test data according to at least one preset use case feature type, including:

[0121] Extracting a use case request feature from the test request data according to the use case request feature type;

[0122] Extracting expected features of the use case from the test result data according to the expected feature type of the use case;

[0123] According to the use case label feature type and the use case expected feature type, use case label features and use case description features are respectively extracted from the business description data.

[0124] Optionally, the adjusting module 140 is configured to replace the data content of the use case feature extracted from the online test data according to at least the use case content of the use case feature extracted from the target offline test case, including:

[0125] Replacing the test request data of the online test data with the test request of the target offline test case;

[0126] Replacing the test result data of the online test data with the expected result of the target offline test case;

[0127] The business description data of the online test data is replaced with the use case description of the target offline test case.

[0128] In another optional implementation, the adjusting module 140 is configured to replace the data content of the use case feature extracted from the online test data according to at least the use case content of the use case feature extracted from the target offline test case, including:

[0129] When the test request data of the online test data includes a plurality of key-value pairs, retaining the test request data, wherein the key-value pairs represent an online test experiment switch of the creative script service;

[0130] Replacing the test result data of the online test data with the expected result of the target offline test case;

[0131] The business description data of the online test data is replaced with the use case description of the target offline test case.

[0132] Optionally, the matching module 120 is used to match the online test data with the use case features of the same use case feature type of the offline test case, respectively, to obtain the similarity between the online test data and the use case features of each use case feature type of the offline test case, including:

[0133] According to the maximum likelihood matching algorithm, the online test data is matched with the use case request features, the use case expectation features and the use case description features of the offline test cases, respectively, to obtain the use case request feature similarity, the use case expectation feature similarity and the use case description feature similarity between the online test data and the offline test cases;

[0134] The value of the use case label feature of the online test data is matched with the value of the use case label feature of the offline test case to obtain the similarity of the use case label features of the online test data and the offline test case.

[0135] Optionally, the test case generating device provided in the embodiment of the present application may also be used for:

[0136] Get the generated offline test cases from the use case library;

[0137] Extracting use case request features, use case expectation features, use case label features, and use case description features of the offline test case;

[0138] The use case request features of the offline test case are saved into a request feature set, the use case expected features of the offline test case are saved into an expected feature set, the use case label features of the offline test case are saved into a label feature set, and the use case description features of the offline test case are saved into a use case description feature set; wherein the request feature set, the expected feature set, the label feature set and the use case description feature set are recorded in a preset feature pool.

[0139] Correspondingly, when the matching module 120 matches the use case features of the online test data with the use case features of the generated offline test cases, the matching module 120 may match the use case features of the online test data with the use case features of the generated offline test cases recorded in the feature pool.

[0140] The embodiment of the present application utilizes a use case feature matching method to determine a target offline test case that is similar to the online test data from the generated offline test cases, thereby utilizing the target offline test case to perform data adjustment on the online test data, thereby realizing the generation of offline test cases based on the online test data. Therefore, the test case generation method provided in the embodiment of the present application has less code intrusion on the business system and can have a higher degree of versatility.

[0141] The present application also provides a test case generation system, the system architecture can be as follows: Figure 4 As shown, it includes: online test server and offline server;

[0142] The online test server is used to perform online testing on the business system. When the test results meet the expected results, the online test data is integrated and transmitted to the offline server.

[0143] An offline server is used to obtain online test data transmitted by the online test server; extract use case features of the online test data from the online test data; match the use case features of the online test data with the use case features of the generated offline test cases; determine, based on the matching result, offline test cases similar to the online test data from the offline test cases as target offline test cases; and perform data adjustment on the online test data at least based on the target offline test cases to obtain offline test cases corresponding to the online test data.

[0144] The embodiment of the present application also provides an offline server, which can be provided with the above-mentioned test case generation device in the form of a program to implement the test case generation method provided by the embodiment of the present application. In an optional implementation, the hardware block diagram of the offline server can be as follows Figure 7As shown, it includes: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;

[0145] In the embodiment of the present application, the number of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 is at least one, and the processor 1, the communication interface 2, and the memory 3 communicate with each other through the communication bus 4; obviously, the communication connection diagram of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 shown in the figure is only optional;

[0146] Optionally, the communication interface 2 may be an interface of a communication module for performing network communication;

[0147] Optionally, processor 1 may be a CPU (central processing unit), a GPU (Graphics Processing Unit), an NPU (embedded neural network processor), an FPGA (Field Programmable Gate Array), a TPU (tensor processing unit), an AI chip, an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement an embodiment of the present application.

[0148] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0149] Among them, the memory 3 stores one or more computer-executable instructions, and the processor 1 calls the one or more computer-executable instructions to execute the test case generation method provided in the embodiment of the present application.

[0150] An embodiment of the present application also provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the test case generation method provided in the embodiment of the present application.

[0151] The above describes multiple implementation schemes provided by the embodiments of the present application. The various optional methods introduced in each implementation scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible implementation schemes, which can all be considered as implementation schemes disclosed and open in the embodiments of the present application.

[0152] Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be subject to the scope defined by the claims.

Claims

1. A test case generation method, wherein: The method comprises: Get online test data; Extracting use case features of the online test data from the online test data; Matching the use case features of the online test data with the use case features of the generated offline test cases, including: matching the use case features of the same use case feature type of the online test data with the offline test cases respectively to obtain the similarity between the use case features of the online test data and the offline test cases in each use case feature type; determining the similarity between the online test data and the offline test cases according to the similarity between the use case features of each use case feature type; According to the matching result, determining offline test cases similar to the online test data from the offline test cases as target offline test cases; The online test data is adjusted at least according to the target offline test case to obtain an offline test case corresponding to the online test data.

2. The test case generation method according to claim 1, wherein: The extracting the use case features of the online test data from the online test data comprises: According to at least one preset use case feature type, use case features of each use case feature type are extracted from the online test data.

3. The test case generation method according to claim 2, wherein: The determining, according to the matching result, from the offline test cases, offline test cases similar to the online test data as target offline test cases comprises: According to the similarity between the online test data and the offline test cases, determining a preset number of offline test cases with the greatest similarity from the offline test cases; A target offline test case is selected from the preset number of offline test cases.

4. The test case generation method according to claim 3, wherein: The adjusting the online test data at least according to the target offline test case comprises: At least according to the use case content of the use case feature extracted from the target offline test case, the data content of the use case feature extracted from the online test data is replaced.

5. The test case generation method according to claim 4, wherein: The at least one use case feature type includes: a use case request feature type, a use case expected feature type, a use case label feature type, and a use case description feature type; wherein the use case request feature type corresponds to the use case request feature, the use case expected feature type corresponds to the use case expected feature, the use case label feature type corresponds to the use case label feature, and the use case description feature type corresponds to the use case description feature.

6. The test case generation method according to claim 5, wherein: The online test data at least includes: test request data, test result data and service description data; The extracting, from the online test data, use case features of each use case feature type according to at least one preset use case feature type comprises: Extracting a use case request feature from the test request data according to the use case request feature type; Extracting expected features of the use case from the test result data according to the expected feature type of the use case; According to the use case label feature type and the use case expected feature type, use case label features and use case description features are respectively extracted from the business description data.

7. The test case generation method according to claim 6, wherein: The replacing the data content of the use case feature extracted from the online test data at least according to the use case content of the use case feature extracted from the target offline test case comprises: Replacing the test request data of the online test data with the test request of the target offline test case; Replacing the test result data of the online test data with the expected result of the target offline test case; The business description data of the online test data is replaced with the use case description of the target offline test case.

8. The test case generation method according to claim 6, wherein: The replacing the data content of the use case feature extracted from the online test data at least according to the use case content of the use case feature extracted from the target offline test case comprises: When the test request data of the online test data includes a plurality of key-value pairs, retaining the test request data, wherein the key-value pairs represent an online test experiment switch of the creative script service; Replacing the test result data of the online test data with the expected result of the target offline test case; The business description data of the online test data is replaced with the use case description of the target offline test case.

9. The test case generation method according to claim 6, wherein: The matching of the online test data with the use case features of the same use case feature type of the offline test case to obtain the similarity between the online test data and the use case features of each use case feature type of the offline test case includes: According to the maximum likelihood matching algorithm, the online test data is matched with the use case request features, the use case expectation features and the use case description features of the offline test cases, respectively, to obtain the use case request feature similarity, the use case expectation feature similarity and the use case description feature similarity between the online test data and the offline test cases; The value of the use case label feature of the online test data is matched with the value of the use case label feature of the offline test case to obtain the similarity of the use case label features of the online test data and the offline test case.

10. The test case generation method according to claim 5, further comprising: Get the generated offline test cases from the use case library; Extracting use case request features, use case expectation features, use case label features, and use case description features of the offline test case; The use case request features of the offline test case are saved into a request feature set, the use case expected features of the offline test case are saved into an expected feature set, the use case label features of the offline test case are saved into a label feature set, and the use case description features of the offline test case are saved into a use case description feature set; wherein the request feature set, the expected feature set, the label feature set and the use case description feature set are recorded in a preset feature pool.

11. A test case generating device, comprising: An online test data acquisition module is used to acquire online test data; A feature extraction module, used to extract use case features of the online test data from the online test data; A matching module, used to match the use case features of the online test data with the use case features of the generated offline test cases, including: matching the use case features of the same use case feature type of the online test data with the offline test cases respectively to obtain the similarity between the online test data and the offline test cases in the use case features of each use case feature type; determining the similarity between the online test data and the offline test cases according to the similarity between the use case features of each use case feature type; A target offline test case determination module, configured to determine, according to the matching result, an offline test case similar to the online test data from the offline test cases as a target offline test case; The adjustment module is used to perform data adjustment on the online test data at least according to the target offline test case to obtain the offline test case corresponding to the online test data.

12. A test case generation system, comprising: Online test server and offline server; The online test server is used to perform online testing on the business system, and when the test results meet the expected results, integrate the online test data and transmit the online test data to the offline server; The offline server is used to obtain the online test data transmitted by the online test server; Extracting use case features of the online test data from the online test data; Matching the use case features of the online test data with the use case features of the generated offline test cases, including: matching the use case features of the same use case feature type of the online test data with the offline test cases respectively to obtain the similarity between the online test data and the offline test cases in the use case features of each use case feature type; determining the similarity between the online test data and the offline test cases according to the similarity between the use case features of each use case feature type; and determining, from the offline test cases, offline test cases similar to the online test data as target offline test cases according to the matching results; The online test data is adjusted at least according to the target offline test case to obtain an offline test case corresponding to the online test data.

13. An offline server, comprising: at least one memory for storing one or more computer executable instructions; At least one processor is used to call the one or more computer executable instructions to execute the test case generation method as described in any one of claims 1-10.

14. A storage medium storing one or more computer executable instructions, wherein the one or more computer executable instructions are used to execute the test case generation method according to any one of claims 1 to 10.