Business logic test method and device, computer device and storage medium

By binding business test scenarios and template data in business logic testing, and generating test data using the expected results of the scenarios, the problems of complexity and inefficiency in test data construction are solved, thus achieving efficient business logic testing.

CN116089296BActive Publication Date: 2025-12-23CHINA CONSTRUCTION BANK +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310119149.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-07
Publication Date
2025-12-23
Estimated Expiration
2043-02-07

AI Technical Summary

Technical Problem

Existing business logic testing methods suffer from low efficiency due to the enormous workload involved in constructing test data and the complexity of data fields, which requires high skill levels and time from testers.

Method used

By acquiring business test template data corresponding to the business test scenario, business test data is generated based on the expected results of the scenario. The fields of the template data are categorized, extracted, and populated to generate test data that meets the expected results.

Benefits of technology

It effectively reduced the workload of generating test data, improved testing efficiency, and enhanced the reliability of business systems and the expected accuracy of test data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116089296B_ABST
    Figure CN116089296B_ABST
Patent Text Reader

Abstract

The present disclosure designs the technical field of data processing, and specifically discloses a business logic testing method and device, computer equipment, a storage medium and a computer program product. The method comprises: acquiring business test template data corresponding to a business test scene; determining a scene expected result of the business test scene according to the business test scene; generating business test data of the business test scene based on the business test scene, the scene expected result and the business test template data; and testing the business logic of the business test scene according to the business test data to obtain a business logic test result of the business test scene. The method can effectively improve the test efficiency of the business logic test and enhance the reliability of the operation of the business system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a business logic testing method and device, computer equipment, a storage medium and a computer program product. BACKGROUND

[0002] With the continuous development of Internet technology, business systems undertake most of the data processing tasks of business processing. In order to ensure the normal operation of business functions, it has become a necessary work for each business industry to supervise the business system and regularly test the business system to determine whether the business logic of the business system is running normally.

[0003] Test data is important data for testing the functions and running logic of a business system. By constructing a large amount of test data to simulate the situation during actual business processing, abnormalities in the functions of the business system can be discovered in a timely manner.

[0004] However, the existing business logic testing method requires a large amount of work to construct test data and most data fields have complex meanings. Therefore, the test personnel often need to make multiple adjustments to obtain test data that meets the requirements when generating test data. Therefore, the traditional business logic testing method has high requirements for the skills and testing time of the test personnel, which greatly reduces the efficiency of business logic testing. SUMMARY

[0005] Therefore, it is necessary to provide a business logic testing method, device, computer equipment, computer readable storage medium and computer program product that can improve the business logic testing rate in order to solve the above technical problems.

[0006] In a first aspect, the present application provides a business logic testing method, which comprises:

[0007] obtaining business test template data corresponding to a business test scenario;

[0008] determining a scenario expected result of the business test scenario according to the business test scenario;

[0009] generating business test data of the business test scenario based on the business test scenario, the scenario expected result and the business test template data;

[0010] testing the business logic of the business test scenario according to the business test data to obtain a business logic test result of the business test scenario.

[0011] In one embodiment, the generating of the business test data of the business test scenario based on the business test scenario, the scenario expected result and the business test template data comprises:

[0012] performing field classification extraction on the business test template data based on the business test scenario, to obtain template fields of different filling types;

[0013] determining a key expected field from each of the template fields according to the scenario expected result;

[0014] obtaining field filling data of each of the template fields based on each of the template fields containing the key expected field and a filling type corresponding to each of the template fields;

[0015] generating business test data of the business test scenario according to each of the field filling data.

[0016] In one of the embodiments, the obtaining of the field filling data of each of the template fields based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields comprises:

[0017] obtaining the filling type of the key expected field;

[0018] if the filling type corresponding to the key expected field belongs to a directly fillable type, obtaining the field filling data of each of the template fields based on the filling type corresponding to each of the template fields.

[0019] In one of the embodiments, the method further comprises:

[0020] if the filling type corresponding to the key expected field belongs to a non-directly fillable type, determining a related field and a non-related field of the key expected field from each of the template fields;

[0021] obtaining related field filling data of the related field and non-related field filling data of the non-related field according to the filling type corresponding to the related field and the filling type corresponding to the non-related field, respectively;

[0022] performing expected result processing on the related field filling data to obtain key field filling data of the key expected field;

[0023] obtaining the field filling data of each of the template fields based on the related field filling data, the non-related field filling data and the key field filling data.

[0024] In one of the embodiments, the filling type comprises interface input.

[0025] The obtaining of the field filling data of each of the template fields based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields comprises:

[0026] If the filling type corresponding to the template field is interface input, field filling data of each template field is generated based on each template field containing the key expected field and the filling type corresponding to each template field.

[0027] The field filling data of the template field is obtained from the data construction interface.

[0028] In one embodiment, the filling type includes direct construction.

[0029] The field filling data of each template field is obtained based on each template field containing the key expected field and the filling type corresponding to each template field, including:

[0030] If the filling type corresponding to the template field is direct construction, a preset construction function is obtained according to the test scenario.

[0031] The field filling data of the template field is obtained based on the preset construction function.

[0032] In one embodiment, the filling type includes database acquisition.

[0033] The field filling data of each template field is obtained based on each template field containing the key expected field and the filling type corresponding to each template field, including:

[0034] If the filling type corresponding to the template field is database acquisition, a preset acquisition rule is determined according to the test scenario.

[0035] The field filling data of the template field is obtained from the database based on the preset acquisition rule.

[0036] In a first aspect, the application also provides a business logic testing device, the device comprising:

[0037] A template data acquisition module is configured to acquire business test template data corresponding to a business test scenario.

[0038] An expected information determination module is configured to determine a scenario expected result of the business test scenario according to the business test scenario.

[0039] A test data generation module is configured to generate business test data of the business test scenario based on the business test scenario, the scenario expected result, and the business test template data.

[0040] A test module is configured to test business logic of the business test scenario according to the business test data, and obtain a business logic test result of the business test scenario.

[0041] In one of the embodiments, the test data generation module is further configured to:

[0042] perform field classification extraction on the business test template data based on the business test scenario, to obtain template fields of different filling types; determine a key expected field from each of the template fields according to the scenario expected result; obtain field filling data of each of the template fields based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields; and generate business test data of the business test scenario according to the field filling data.

[0043] In one of the embodiments, the test data generation module is further configured to:

[0044] obtain the filling type of the key expected field; and if the filling type corresponding to the key expected field belongs to a directly fillable type, obtain the field filling data of each of the template fields based on the filling type corresponding to each of the template fields.

[0045] In one of the embodiments, the test data generation module is further configured to:

[0046] if the filling type corresponding to the key expected field belongs to a non-directly fillable type, determine a related field and an unrelated field of the key expected field from each of the template fields; obtain related field filling data of the related field and unrelated field filling data of the unrelated field according to the filling type corresponding to the related field and the filling type corresponding to the unrelated field, respectively; perform expected result processing on the related field filling data to obtain key field filling data of the key expected field; and obtain the field filling data of each of the template fields based on the related field filling data, the unrelated field filling data, and the key field filling data.

[0047] In one of the embodiments, the filling type includes interface input.

[0048] The test data generation module is further configured to: if the filling type corresponding to the template field is interface input, generate a data construction interface based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields; and obtain the field filling data of the template field from the data construction interface.

[0049] In one of the embodiments, the filling type includes direct construction.

[0050] The test data generation module is further configured to: if the filling type corresponding to the template field is direct construction, obtain a preset construction function according to the test scenario; and obtain the field filling data of the template field based on the preset construction function.

[0051] In one embodiment, the filling type includes database acquisition.

[0052] The test data generation module is further configured to: if the filling type corresponding to the template field is database acquisition, determine a preset acquisition rule according to the test scenario; and acquire field filling data of the template field from a database based on the preset acquisition rule.

[0053] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described above when executing the computer program.

[0054] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the method described above when executed by a processor.

[0055] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, and the computer program implements the steps of the method described above when executed by a processor.

[0056] The business logic test method, device, computer device, storage medium and computer program product described above bind the business test scenario and the business test template data in advance, acquire the business test template data corresponding to the business test scenario when performing business logic test, process the business test template data according to the business test scenario and the expected information of the business test scenario to generate business test data, reduce the workload of the test personnel when generating the test data through the binding template, then test the business logic of the business test scenario according to the business test data to obtain the business logic test result of the business test scenario, and since the expected result is oriented when generating the business test data, the situation that the generated business test data needs to be adjusted multiple times because it does not meet the expected result can be avoided, the test efficiency of the business logic test is effectively improved from the two aspects of reducing the workload of constructing the test data and increasing the expected accuracy of constructing the test data, and the reliability of the operation of the business system is enhanced. BRIEF DESCRIPTION OF DRAWINGS

[0057] Figure 1 An application environment diagram of the business logic test method in one embodiment;

[0058] Figure 2 A flowchart of the business logic test method in one embodiment;

[0059] Figure 3A flowchart of a business test data generation step for a business test scenario based on a business test scenario, a scenario expected result and a business test template data in an embodiment;

[0060] Figure 4 A flowchart of a business logic test method in another embodiment;

[0061] Figure 5 A flowchart of a business logic test method in yet another embodiment;

[0062] Figure 6 A structural block diagram of a business logic test device in an embodiment;

[0063] Figure 7 An internal structural diagram of a computer device in an embodiment. DETAILED DESCRIPTION

[0064] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not to limit the present application.

[0065] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.

[0066] The business logic test method provided by the embodiments of the present application can be applied to, for example, Figure 1The application environment is shown. Among them, the test tool 102 can be integrated on the business system 104, and communicate with the external system 106 through the network. The data storage system can store the data required by the test tool 102 to process. The data storage system can be integrated on the test tool 102 or the business system 104, or placed on the cloud or other network servers. The test tool 102 obtains the business test template data corresponding to the business test scene from the business system 104. The business test template data is uploaded to the business system 104 by the external system 106. The test tool determines the scene expected result of the business test scene according to the business test scene, generates the business test data of the business test scene based on the business test scene, the scene expected result and the business test template data, tests the business logic of the business test scene according to the business test data, and obtains the business logic test result of the business test scene. Among them, the business system 104 and the external system 106 can be but not limited to various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart vehicle-mounted device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. It can also be implemented by an independent server or a server cluster composed of multiple servers.

[0067] In one of the embodiments, the business system can connect multiple external systems, and the number of external systems is determined according to the running performance of the business system. Among them, the external system is a system that executes a business and generates business data, and is a provider of business data. The business system is a background system that processes and calculates business data generated by executing a business according to certain business logic, and is a receiver of business data. Taking a trust business as an example, the trust system is a background system for handling trust business by a trust person or a trust institution, such as a bank, which can be regarded as a business system of trust business. At this time, the external system can be a provider of external data required for trust, such as various exchanges and trading institutions.

[0068] In one of the embodiments, as shown in Figure 2 , a business logic test method is provided. Taking the test tool in Figure 1 as an example, the method includes the following steps:

[0069] Step 202, obtaining the business test template data corresponding to the business test scene.

[0070] The business test scenario is a scenario in the test tool for a specific business, which can be considered as a business scenario in the test tool, consistent with the business scenario that the business system can run. The business test scenario is the basis for implementing business logic test running. Different business systems protect different business test scenarios. For example, in a bank business system, "bank flow statistics" can be used as a business scenario, and in a custody business system, "custody asset management" can be used as a business scenario.

[0071] The business logic contained in the business test scenario is consistent with the business logic contained in the business scenario of the business system, that is, the business test scenario is determined, and the business logic under the scenario is determined.

[0072] The business test template data refers to a file template that meets the corresponding specifications of the external system, which can be understood as a standard file template of the external system. The business test template data can include template information such as standard format, column name, and field information.

[0073] In one embodiment, when the tester generates a test tool for a business system, the tester receives the business test template data uploaded by each external system corresponding to the business system, and binds each business test template data to its corresponding business test scenario, and stores them together in the data storage of the business system, for easy access at any time when performing business logic testing.

[0074] Specifically, the test tool obtains the business test template data corresponding to the business test scenario according to the business test scenario determined by the tester.

[0075] Step 204, determining the scenario expected result of the business test scenario according to the business test scenario.

[0076] The scenario expected result is the expected running result corresponding to the business test scenario. Specifically, the business test scenario itself corresponds to a business logic, and after processing the external data with the business logic, a business running result is obtained. For example, if the external data is product transaction data within a period of time, the product transaction data is processed with the business logic to obtain the total product transaction data, and then the total product transaction data is determined as the scenario expected result of the business test scenario, so as to quickly generate business test data oriented to the scenario expected result in the subsequent process.

[0077] Specifically, the test tool determines the scenario expected result corresponding to the business test scenario according to the business test scenario. It can be understood that the test tool contains all business test scenarios corresponding to the business system, and the business test scenario and the scenario expected structure are one-to-one corresponding.

[0078] In step 206, the business test data of the business test scene is generated based on the business test scene, the scene expected result and the business test template data.

[0079] Specifically, the test tool determines the standard data structure of the external system currently tested according to the business test template data, and generates the business test data based on the determined business test scene and scene expected result, and the standard data structure of the external system. Unlike the conventional test data generation method, the scheme introduces the scene expected result corresponding to the business test scene when generating the business test data, and the expected result is oriented, which can effectively avoid the situation that the generated business test data needs to be adjusted for multiple times because it does not meet the expected result.

[0080] In step 208, the business logic of the business test scene is tested according to the business test data, and the business logic test result of the business test scene is obtained.

[0081] Specifically, the test tool inputs the generated business test data as input data into the business test scene, and processes the business test data according to the business logic corresponding to the business test scene, so as to obtain the business logic running result. Comparing the business logic running result with the expected result, the business logic test result of the business test scene is obtained, and whether the business logic in the business system is normally running is determined.

[0082] In the above business logic test method, the business test scene is bound with the business test template data in advance. When the business logic test is performed, the business test template data corresponding to the business test scene is obtained, the business test template data is processed according to the business test scene and the expected information of the business test scene to generate the business test data. The workload of the test personnel in generating the test data can be reduced by binding the template. Then, the business logic of the business test scene is tested according to the business test data, and the business logic test result of the business test scene is obtained. Since the expected result is oriented when the business test data is generated, the situation that the generated business test data needs to be adjusted for multiple times because it does not meet the expected result can be avoided. From the aspects of reducing the workload of constructing the test data and increasing the expected accuracy of constructing the test data, the test efficiency of the business logic test is effectively improved, and the reliability of the business system operation is enhanced.

[0083] In one embodiment, as shown in FIG. 3, the business test data of the business test scene is generated based on the business test scene, the scene expected result and the business test template data, including: Figure 3

[0084] In step 302, the business test template data is classified and extracted based on the business test scene, and the template fields of different filling types are obtained. ​

[0085] The field classification extraction is an operation for extracting and classifying information in the business test template data, and is composed of field extraction and field classification. Specifically, the business test template data is data containing external system standard data format information. By field extraction on the business test template data, a template field set corresponding to the business test data template can be extracted, i.e., a basic data template for generating business test data. The template field set contains a plurality of template fields of different filling types, each of which carries basic data information. The template fields are filled to obtain business test data conforming to the external system data standard. For example, the template fields can be amount, row number, total amount, combined name, etc.

[0086] The filling type can be used to identify the filling method for filling the content of the template field and the filling category to which the template field belongs. The filling category can be divided into a directly fillable type and a non-directly fillable type. If the filling method of the template field belongs to the directly fillable type, only one acquisition operation is needed for the template field to obtain the filling content of the template field. If the filling method of the template field belongs to the non-directly fillable type, at least two acquisition operations are needed for the template field to obtain the filling content of the template field. It can be understood that when the filling type of the template field is determined, the filling method of the template field and the filling category to which the filling type belongs, i.e., whether it is a directly fillable type or a non-directly fillable type, can be determined at the same time.

[0087] Specifically, in the test tool, one external system can have multiple business scenarios, i.e., one business test template data can be used by multiple business test scenarios, and each business test scenario has its corresponding field classification rule. After obtaining the business test template data, the test tool needs to perform field classification extraction on the business test template data according to the field classification rule of the business test scenario to obtain template fields of different filling types.

[0088] Step 304: determining a key expected field from the template fields according to the scenario expected result.

[0089] The key expected field is a template field that can carry the scenario expected result. The key expected field can refer to a single field or a combined field obtained by combining two or more fields. For example, if the template fields include amount, row number, and combined name, and the scenario expected result is one value per row of data, then the row number can be determined as the key expected field. If the scenario expected result is a total amount of one value, then the key expected field is a combined field of the amount and the row number.

[0090] Specifically, the test tool determines the key expected field carrying the scenario expected result from each template field according to the scenario expected result.

[0091] In step 306, the field filling data of each template field is obtained based on each template field containing the key expected field and the filling type corresponding to each template field.

[0092] Specifically, the filling method of each template field is determined according to the filling type corresponding to each template field, and the field filling data of each template field is obtained based on the filling method.

[0093] In step 308, the business test data of the business test scenario is generated according to each field filling data.

[0094] Specifically, after obtaining the field filling data of each template field, the test tool generates the business test data conforming to the external system data standard format according to each field filling data, which is used to test the business logic of the business test scenario.

[0095] In this embodiment, by field classification and extraction of the business test template data, the filling type of each template field is determined, and the key expected field is determined from each template field based on the scenario expected result, so that the expected result can be guided when generating the business test data, and the situation that the generated business test data does not conform to the expected result and needs to be adjusted multiple times can be avoided, thereby improving the test efficiency of the business logic test.

[0096] Since the key expected field can be a single field or a combined field, in one embodiment, the field filling data of each template field is obtained based on each template field containing the key expected field and the filling type corresponding to each template field, including:

[0097] The filling type of the key expected field is obtained, and if the filling type corresponding to the key expected field belongs to the directly fillable type, the field filling data of each template field is obtained based on the filling type corresponding to each template field.

[0098] Specifically, the test tool obtains the filling type of the key expected field, and if the filling type corresponding to the key expected field belongs to the directly fillable type, the key expected field can be considered as a single field, which is the same as other template fields in the template field set, and only one acquisition operation is needed to obtain the field filling data of the key expected field, so the test tool can directly obtain the field filling data of each template field based on the filling type corresponding to each template field.

[0099] In the embodiment, the test tool first determines the filling type of the key expected field. If the filling type belongs to the directly fillable type, the field filling data of each template field is obtained based on the filling type corresponding to each template field, which accelerates the generation of the business test data and improves the test efficiency of the business logic test.

[0100] Further, in one embodiment, as shown in Figure 4 the business logic test method further includes the following steps:

[0101] In step 402, if the filling type corresponding to the key expected field belongs to the non-directly fillable type, the related fields and the non-related fields of the key expected field are determined from the template fields.

[0102] Specifically, the test tool obtains the filling type of the key expected field. If the filling type corresponding to the key expected field belongs to the non-directly fillable type, it can be considered that the key expected field is a combined field obtained by combining at least two template fields, and the combined template fields are the related fields of the key expected field. The test tool determines the related fields of the key expected field from the template fields according to the key expected field, and determines the non-related fields in the template field set as the template fields other than the related fields.

[0103] In step 404, the related field filling data of the related fields and the non-related field filling data of the non-related fields are obtained according to the filling types corresponding to the related fields and the non-related fields, respectively.

[0104] Specifically, the test tool obtains the related field filling data of the related fields according to the filling types corresponding to the related fields, and obtains the non-related field filling data of the non-related fields according to the filling types corresponding to the non-related fields.

[0105] In step 406, the related field filling data is processed according to the expected result to obtain the key field filling data of the key expected field.

[0106] The expected result processing refers to a processing manner of processing the related field filling data to obtain the scenario expected result. For example, if the scenario expected result is a total amount, the related fields of the key expected field are the amount and the number of rows at this time, and the related field filling data is the number of rows filling data and the amount filling data. The test tool calculates the total amount under this business scenario according to the number of rows filling data and the amount filling data, which is the key field filling data of the key expected field.

[0107] Specifically, after the test data obtains the related field filling data, the key field filling data of the key expected field can be obtained by processing the related field filling data according to the expected result.

[0108] In step 408, the field filling data of each template field is obtained based on the relevant field filling data, the non-relevant field filling data and the key field filling data.

[0109] Specifically, after obtaining the relevant field filling data, the non-relevant field filling data and the key field filling data, the test tool can consider that the field filling data of the entire template field set has been obtained.

[0110] In this embodiment, when it is determined that the key expected field is formed by a combination of multiple fields, the test tool first determines the relevant fields that form the key expected field, obtains the relevant field filling data and the non-relevant field filling data based on the filling types corresponding to the relevant fields and the non-relevant fields respectively, processes the relevant field filling data to obtain the key field filling data, and then obtains the field filling data of the entire template field set based on the three kinds of filling data, thereby providing a data basis for subsequent generation of the expected result-oriented business test data.

[0111] The filling type is key information for determining the filling method of the template field. In an embodiment, the filling type of the template field includes interface input, and the field filling data of each template field is obtained based on the template fields containing the key expected field and the filling types corresponding to the template fields, including:

[0112] If the filling type corresponding to the template field is interface input, a data construction interface is generated based on the template fields containing the key expected field and the filling types corresponding to the template fields, and the field filling data of the template field is obtained from the data construction interface.

[0113] The interface input refers to a filling type of filling the template field by obtaining the filling data from the interface.

[0114] Specifically, if the filling type of the template field is interface input, it means that the filling field of the field template is obtained by directly obtaining the filling data from the interface input information. The test tool generates a data construction interface based on the test scene, i.e., the template fields containing the key expected field and the filling types corresponding to the template fields, and the test personnel can input the filling data of the template field based on the data construction interface. The test tool obtains the filling data input by the test personnel to obtain the field filling data of the template field, thereby providing a data basis for subsequent generation of the business test data.

[0115] In addition to the interface input, the filling type of the template field includes direct construction in an embodiment, and the field filling data of each template field is obtained based on the template fields containing the key expected field and the filling types corresponding to the template fields, including:

[0116] If the filling type corresponding to the template field is direct construction, a preset constructor is obtained according to the test scenario, and field filling data of the template field is obtained based on the preset constructor.

[0117] Direct construction refers to a filling type of filling the template field by using a preset constructor to construct filling data.

[0118] Specifically, if the filling type of the template field is direct construction, it can be considered that the data to be filled in the template field is not critical data in the test process, and has little effect on the test result. For example, an account field, and filling the template field is mainly to ensure the structural integrity of the generated business test data. Therefore, the test tool can use a preset constructor to directly construct the field filling data of the template field, providing a data basis for obtaining complete business test data subsequently.

[0119] Further, in an embodiment, the filling type of the template field includes database acquisition, and the field filling data of each template field is obtained based on each template field containing a key expected field and the filling type corresponding to each template field, including:

[0120] If the filling type corresponding to the template field is database acquisition, a preset acquisition rule is determined according to the test scenario, and the field filling data of the template field is obtained from the database based on the preset acquisition rule.

[0121] Database acquisition refers to a filling type of filling the template field by using a preset acquisition rule to obtain filling data from a business system database. The preset acquisition rule corresponds to the test scenario, and specifies the specific position and form of obtaining data in the database under the test scenario.

[0122] Specifically, if the filling type of the template field is database acquisition, it can be considered that the data to be filled in the template field is data already stored in the database, which can be directly obtained from the database, such as a combination name. The test tool determines a preset acquisition rule according to the test scenario, and then obtains the field filling data of the template field from the database based on the preset acquisition rule, providing a data basis for obtaining complete business test data subsequently.

[0123] In the hosting system test process, in order to test the related function of the external system data, there is a large amount of test data construction workload, and the data field meaning is complex, and is strongly coupled with the existing test data of the system. The test expected result is related to the total amount, limit and the like of the amount field of the data. In the existing test scheme, the test personnel mainly manually conceive the required test data from the positive direction, without constructing the data from the perspective of the test expected result. The test personnel has high requirements for the external data function, and needs to adjust the test data according to the expected result in the later period. Based on this, in an embodiment, as shown in Figure 5 a business logic test method is provided, which is applied to the hosting system as an example for description.

[0124] Firstly, the test tool determines the test scene for this test, imports the test data file template required for the test, and determines the scene expected result of the test scene according to the test scene. Based on the test scene, the field classification extraction operation is performed on the test data file template to obtain all template fields of the test data file template. The template field contains different filling types, including interface input, direct construction and database acquisition. At the same time, the key expected field is determined from each template field according to the scene expected result.

[0125] The test tool generates a data construction interface according to the test scene, each template field and the filling type corresponding to each template field, and obtains the field filling data of each template field based on each template field containing the key expected field and the filling type corresponding to each template field, in response to the test data generation operation triggered by the test personnel based on the data construction interface.

[0126] Specifically, if the filling type corresponding to the template field is interface input, the filling data input by the test personnel is obtained from the data construction interface according to the pre-written logic code, and the field filling data of the template field is obtained. If the filling type corresponding to the template field is direct construction, the preset construction function is obtained according to the test scene, and the field filling data of the template field is obtained based on the preset construction function. If the filling type corresponding to the template field is database acquisition, the preset acquisition rule is determined according to the test scene, and the field filling data of the template field is obtained from the database through SQL based on the preset acquisition rule.

[0127] Finally, the test tool generates the test data of the hosting system according to all the obtained field filling data, and tests the business logic of the test scene according to the test data to obtain the business logic test result of the test scene.

[0128] For example, if a test scene needs to use a certain template test under 10000 lines of data, a combination, test data with the lowest amount of 0 and the highest amount of 10000, and the expected total amount is 200000, the test expectation of a certain item in this scene is that the data characteristics of the combination are 200000, the interface input line number is 10000, the total amount is 200000, the minimum amount is 0, and the maximum amount is 10000. Among them, according to the combination name, the related information of the combination can be obtained from the existing data in the test environment database through SQL, and the amount greater than or equal to 0, less than 10000 and less than the remaining total amount is filled into the test amount field through the constructor function. Finally, a 10000-line data file that meets the test expectation is generated, and the test result can be directly tested to see if it meets the expectation of the combination voucher of 200000.

[0129] The business logic test method in the embodiment introduces the automatic association of templates and test scenes, and automatically generates test data according to the test purpose, thereby improving the test efficiency and reducing the threshold of test data preparation.

[0130] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.

[0131] Based on the same inventive concept, the embodiment of the present application also provides a business logic test device for implementing the above-mentioned business logic test method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more business logic test device embodiments provided below can refer to the limitations of the business logic test method in the foregoing, which will not be repeated here.

[0132] In one embodiment, as shown in Figure 6 A business logic test device 600 is provided, which includes a template data acquisition module 601, an expectation information determination module 602, a test data generation module 603, and a test module 604, wherein:

[0133] The template data acquisition module 601 is configured to acquire business test template data corresponding to the business test scenario.

[0134] The expected information determination module 602 is configured to determine a scenario expected result of the business test scenario according to the business test scenario.

[0135] The test data generation module 603 is configured to generate business test data of the business test scenario based on the business test scenario, the scenario expected result and the business test template data.

[0136] The test module 604 is configured to test the business logic of the business test scenario according to the business test data, to obtain a business logic test result of the business test scenario.

[0137] The business logic test device described above binds the business test scenario and the business test template data in advance, acquires the business test template data corresponding to the business test scenario when the business logic test is performed, processes the business test template data according to the business test scenario and the expected information of the business test scenario to generate the business test data, and reduces the workload of the test personnel when the test data is generated through the binding template. Then, the business logic of the business test scenario is tested according to the business test data, to obtain the business logic test result of the business test scenario. Since the expected result is used as a guide when the business test data is generated, the situation that the generated business test data needs to be adjusted multiple times because it does not meet the expected result can be avoided. From the aspects of reducing the workload of constructing the test data and increasing the expected accuracy of constructing the test data, the test efficiency of the business logic test is effectively improved, and the reliability of the operation of the business system is enhanced.

[0138] In one embodiment, the test data generation module is further configured to: perform field classification extraction on the business test template data based on the business test scenario, to obtain template fields of different filling types; determine key expected fields from the template fields according to the scenario expected result; obtain field filling data of each template field based on each template field containing the key expected field and the filling type corresponding to each template field; and generate the business test data of the business test scenario according to the field filling data.

[0139] In one embodiment, the test data generation module is further configured to: acquire the filling type of the key expected field; and if the filling type corresponding to the key expected field belongs to a directly fillable type, obtain the field filling data of each template field based on the filling type corresponding to each template field.

[0140] In an embodiment, the test data generation module is further configured to: if the filling type corresponding to the key expected field belongs to the non-direct filling type, determine the relevant fields and the irrelevant fields of the key expected field from the template fields; obtain the relevant field filling data of the relevant fields and the irrelevant field filling data of the irrelevant fields according to the filling types corresponding to the relevant fields and the filling types corresponding to the irrelevant fields; perform expected result processing on the relevant field filling data to obtain the key field filling data of the key expected field; and obtain the field filling data of each template field based on the relevant field filling data, the irrelevant field filling data and the key field filling data.

[0141] In an embodiment, the filling type includes interface input, and the test data generation module is further configured to: if the filling type corresponding to the template field is interface input, generate a data construction interface based on the template fields containing the key expected field and the filling types corresponding to the template fields; and obtain the field filling data of the template field from the data construction interface.

[0142] In an embodiment, the filling type includes direct construction, and the test data generation module is further configured to: if the filling type corresponding to the template field is direct construction, obtain a preset construction function according to the test scenario; and obtain the field filling data of the template field based on the preset construction function.

[0143] In an embodiment, the filling type includes database acquisition, and the test data generation module is further configured to: if the filling type corresponding to the template field is database acquisition, determine a preset acquisition rule according to the test scenario; and obtain the field filling data of the template field from the database based on the preset acquisition rule.

[0144] The above-mentioned various modules in the business logic test device can be realized by software, hardware and combinations thereof in whole or in part. The above-mentioned various modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to the above-mentioned various modules.

[0145] In an embodiment, a computer device is provided, which can be a server integrated with a test tool, and an internal structure diagram of the computer device can be as shown in Figure 7As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store business test template data, business test scenarios, scenario expected results and other data. The network interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to implement a business logic test method.

[0146] Those skilled in the art can understand that, Figure 7 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.

[0147] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the following steps:

[0148] Obtain business test template data corresponding to the business test scenario;

[0149] Determine the scenario expected result of the business test scenario according to the business test scenario;

[0150] Generate business test data of the business test scenario based on the business test scenario, the scenario expected result and the business test template data;

[0151] Test the business logic of the business test scenario according to the business test data, and obtain the business logic test result of the business test scenario.

[0152] In one embodiment, the processor executing the computer program further implements the following steps:

[0153] Classify and extract the business test template data based on the business test scenario to obtain template fields of different filling types;

[0154] Determine the key expected field from each template field according to the scenario expected result;

[0155] Obtain field filling data of each template field based on each template field containing the key expected field and the filling type corresponding to each template field;

[0156] Generate business test data of the business test scenario according to each field filling data.

[0157] In one embodiment, the processor, when executing the computer program, also implements the following steps:

[0158] obtaining a filling type of the key expected field;

[0159] if the filling type corresponding to the key expected field belongs to the directly fillable type, obtaining field filling data of each template field based on the filling type corresponding to each template field.

[0160] In one embodiment, the processor, when executing the computer program, also implements the following steps:

[0161] if the filling type corresponding to the key expected field belongs to the non-directly fillable type, determining a related field and an unrelated field of the key expected field from each template field;

[0162] obtaining related field filling data of the related field and unrelated field filling data of the unrelated field according to the filling type corresponding to the related field and the filling type corresponding to the unrelated field, respectively;

[0163] performing expected result processing on the related field filling data to obtain key field filling data of the key expected field;

[0164] obtaining field filling data of each template field based on the related field filling data, the unrelated field filling data, and the key field filling data.

[0165] In one embodiment, the processor, when executing the computer program, also implements the following steps:

[0166] if the filling type corresponding to the template field is interface input, generating a data construction interface based on each template field containing the key expected field and the filling type corresponding to each template field;

[0167] obtaining the field filling data of the template field from the data construction interface.

[0168] In one embodiment, the processor, when executing the computer program, also implements the following steps:

[0169] if the filling type corresponding to the template field is direct construction, obtaining a preset construction function according to the test scenario;

[0170] obtaining the field filling data of the template field based on the preset construction function.

[0171] In one embodiment, the processor, when executing the computer program, also implements the following steps:

[0172] if the filling type corresponding to the template field is database acquisition, determining a preset acquisition rule according to the test scenario;

[0173] obtain the field filling data of the template field from the database based on a preset obtaining rule.

[0174] In one embodiment, a computer readable storage medium is provided, and the computer readable storage medium has stored thereon a computer program, and the computer program is executed by a processor to implement the following steps:

[0175] obtain business test template data corresponding to the business test scenario;

[0176] determine a scenario expected result of the business test scenario according to the business test scenario;

[0177] generate business test data of the business test scenario based on the business test scenario, the scenario expected result and the business test template data;

[0178] test a business logic of the business test scenario according to the business test data, and obtain a business logic test result of the business test scenario.

[0179] In one embodiment, the computer program is executed by the processor to further implement the following steps:

[0180] perform field classification and extraction on the business test template data based on the business test scenario, and obtain template fields of different filling types;

[0181] determine a key expected field from each template field according to the scenario expected result;

[0182] obtain field filling data of each template field based on each template field containing the key expected field and a filling type corresponding to each template field;

[0183] generate business test data of the business test scenario according to each field filling data.

[0184] In one embodiment, the computer program is executed by the processor to further implement the following steps:

[0185] obtain a filling type of the key expected field;

[0186] if the filling type corresponding to the key expected field belongs to a directly fillable type, obtain field filling data of each template field based on the filling type corresponding to each template field.

[0187] In one embodiment, the computer program is executed by the processor to further implement the following steps:

[0188] if the filling type corresponding to the key expected field belongs to a non-directly fillable type, determine a related field and an unrelated field of the key expected field from each template field;

[0189] According to the filling type corresponding to the relevant field and the filling type corresponding to the irrelevant field, the relevant field filling data of the relevant field and the irrelevant field filling data of the irrelevant field are obtained respectively;

[0190] The relevant field filling data is processed according to an expected result to obtain key field filling data of a key expected field;

[0191] Based on the relevant field filling data, the irrelevant field filling data and the key field filling data, field filling data of each template field is obtained.

[0192] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0193] If the filling type corresponding to the template field is interface input, based on each template field containing the key expected field and the filling type corresponding to each template field, a data construction interface is generated;

[0194] The field filling data of the template field is obtained from the data construction interface.

[0195] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0196] If the filling type corresponding to the template field is direct construction, a preset construction function is obtained according to the test scenario;

[0197] Based on the preset construction function, the field filling data of the template field is obtained.

[0198] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0199] If the filling type corresponding to the template field is database acquisition, a preset acquisition rule is determined according to the test scenario;

[0200] Based on the preset acquisition rule, the field filling data of the template field is obtained from the database.

[0201] In one embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the following steps:

[0202] Obtain business test template data corresponding to a business test scenario;

[0203] Determine a scenario expected result of the business test scenario according to the business test scenario;

[0204] Generate business test data of the business test scenario based on the business test scenario, the scenario expected result and the business test template data;

[0205] According to the business test data, the business logic of the business test scene is tested, and a business logic test result of the business test scene is obtained.

[0206] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0207] Based on the business test scene, field classification and extraction are performed on the business test template data, and template fields of different filling types are obtained.

[0208] According to the scene expected result, a key expected field is determined from each template field;

[0209] Based on each template field containing the key expected field and the filling type corresponding to each template field, field filling data of each template field is obtained.

[0210] According to each field filling data, business test data of the business test scene is generated.

[0211] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0212] The filling type of the key expected field is obtained.

[0213] If the filling type corresponding to the key expected field belongs to the directly fillable type, the field filling data of each template field is obtained based on the filling type corresponding to each template field.

[0214] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0215] If the filling type corresponding to the key expected field belongs to the non-directly fillable type, the related field and the non-related field of the key expected field are determined from each template field.

[0216] According to the filling type corresponding to the related field and the filling type corresponding to the non-related field, the related field filling data of the related field and the non-related field filling data of the non-related field are obtained respectively.

[0217] The related field filling data is processed according to the expected result, and the key field filling data of the key expected field is obtained.

[0218] Based on the related field filling data, the non-related field filling data and the key field filling data, the field filling data of each template field is obtained.

[0219] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0220] If the filling type corresponding to the template field is interface input, a data construction interface is generated based on each template field containing a key expected field and the filling type corresponding to each template field;

[0221] Field filling data of the template field is obtained from the data construction interface.

[0222] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0223] If the filling type corresponding to the template field is direct construction, a preset construction function is obtained according to the test scenario;

[0224] Field filling data of the template field is obtained based on the preset construction function.

[0225] In one embodiment, the computer program, when executed by the processor, further implements the following steps:

[0226] If the filling type corresponding to the template field is database acquisition, a preset acquisition rule is determined according to the test scenario;

[0227] Field filling data of the template field is obtained from the database based on the preset acquisition rule.

[0228] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.

[0229] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0230] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.

[0231] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method of testing service logic, characterized by, The method comprises: obtaining business test template data corresponding to a business test scenario; determining a scenario expected result of the business test scenario according to the business test scenario; the scenario expected result is an expected running result corresponding to the business test scenario; performing field classification extraction on the business test template data based on the business test scenario to obtain template fields of different filling types; the filling types include a directly fillable type and a non-directly fillable type; the directly fillable type means that filling content can be obtained by performing only one acquisition operation on the corresponding template field; the non-directly fillable type means that filling content can be obtained by performing at least two acquisition operations on the corresponding template field; determining a key expected field from each of the template fields according to the scenario expected result; the key expected field is a template field carrying the scenario expected result; obtaining a filling type of the key expected field; if the filling type corresponding to the key expected field belongs to the non-directly fillable type, determining a related field and an unrelated field of the key expected field from each of the template fields; obtaining related field filling data of the related field and unrelated field filling data of the unrelated field according to the filling type corresponding to the related field and the filling type corresponding to the unrelated field, respectively; performing expected result processing on the related field filling data to obtain key field filling data of the key expected field; the expected result processing means a processing mode of processing the related field filling data to obtain a scenario expected result; obtaining field filling data of each of the template fields based on the related field filling data, the unrelated field filling data, and the key field filling data; generating business test data of the business test scenario according to each of the field filling data; testing a business logic of the business test scenario according to the business test data to obtain a business logic test result of the business test scenario.

2. The method of claim 1, wherein, The method further comprises: if the filling type corresponding to the key expected field belongs to the directly fillable type, obtaining field filling data of each of the template fields based on the filling type corresponding to each of the template fields.

3. The method of claim 1, wherein, The filling type includes interface input; obtaining field filling data of each of the template fields based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields, comprises: if the filling type corresponding to the template field is interface input, generating a data construction interface based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields; obtaining field filling data of the template field from the data construction interface.

4. The method of claim 1, wherein, The filling type includes direct construction; obtaining field filling data of each of the template fields based on each of the template fields containing the key expected field and the filling type corresponding to each of the template fields, comprises: if the filling type corresponding to the template field is direct construction, obtaining a preset construction function according to the test scenario; The field filling data of the template field is obtained based on the preset constructor.

5. The method of claim 1, wherein, The filling type includes database acquisition; The field filling data of each template field is obtained based on each template field containing the key expected field and the filling type corresponding to each template field, and includes: If the filling type corresponding to the template field is database acquisition, a preset acquisition rule is determined according to the test scenario; The field filling data of the template field is obtained from the database based on the preset acquisition rule.

6. A service logic test apparatus, characterized by The device includes: A template data acquisition module, configured to acquire business test template data corresponding to a business test scenario; An expected information determination module, configured to determine a scenario expected result of the business test scenario according to the business test scenario; the scenario expected result is an expected running result corresponding to the business test scenario; A test data generation module, configured to perform field classification extraction on the business test template data based on the business test scenario, to obtain template fields of different filling types; the filling type includes a directly fillable type and a non-directly fillable type; the directly fillable type refers to that filling content can be obtained by performing an acquisition operation once for a corresponding template field; the non-directly fillable type refers to that filling content can be obtained by performing at least two acquisition operations for a corresponding template field; a key expected field is determined from the template fields according to the scenario expected result; the key expected field is a template field bearing the scenario expected result; a filling type of the key expected field is acquired; if the filling type corresponding to the key expected field belongs to the non-directly fillable type, a related field and a non-related field of the key expected field are determined from the template fields; related field filling data of the related field and non-related field filling data of the non-related field are respectively obtained according to the filling type corresponding to the related field and the filling type corresponding to the non-related field; key field filling data of the key expected field is obtained by performing expected result processing on the related field filling data; the expected result processing refers to a processing manner of processing the related field filling data to obtain the scenario expected result; field filling data of each template field is obtained based on the related field filling data, the non-related field filling data, and the key field filling data; business test data of the business test scenario is generated according to the field filling data; A test module, configured to test a business logic of the business test scenario according to the business test data, to obtain a business logic test result of the business test scenario.

7. The apparatus of claim 6, wherein, The test data generation module is further configured to: If the filling type corresponding to the key expected field belongs to the directly fillable type, field filling data of each template field is obtained based on the filling type corresponding to each template field.

8. The apparatus of claim 6, wherein, The filling type includes interface input; The test data generation module is further configured to generate a data construction interface based on each template field containing the key expected field and the filling type corresponding to each template field, if the filling type corresponding to the template field is interface input. The field filling data of the template field is obtained from the data construction interface.

9. The apparatus of claim 6, wherein, The filling type includes direct construction. The test data generation module is further configured to obtain a preset construction function according to the test scenario, if the filling type corresponding to the template field is direct construction, and obtain the field filling data of the template field based on the preset construction function.

10. The apparatus of claim 6, wherein, The filling type includes database acquisition. The test data generation module is further configured to determine a preset acquisition rule according to the test scenario, if the filling type corresponding to the template field is database acquisition, and obtain the field filling data of the template field from a database based on the preset acquisition rule. 11.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-10 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 5.

12. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 5.

13. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for generating test data, computer equipment and storage medium

    CN114185770A