Test data initialization method and device, electronic device, and storage medium

By obtaining the transaction code of the case to be tested, we determine whether script initialization data is needed, query the associated transaction initialization script template and online transaction template, and generate transaction packets for data initialization, solving the problem of low initialization efficiency in the existing technology and achieving efficient test data initialization.

CN115481042BActive Publication Date: 2025-08-19BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211210557.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-30
Publication Date
2025-08-19
Estimated Expiration
2042-09-30

AI Technical Summary

Technical Problem

The prior art test data initialization efficiency in system testing is low, the script volume is large, the maintenance cost is high, and the execution time for some scenarios is long.

Method used

By obtaining the transaction code of the case to be tested, we determine whether script initialization data is needed, query the associated transaction initialization script template and online transaction template, generate transaction packets for data initialization, and subdivide scripts and data configuration to improve efficiency.

Benefits of technology

It realizes efficient test data initialization, reduces script volume and maintenance costs, and improves processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115481042B_ABST
    Figure CN115481042B_ABST
Patent Text Reader

Abstract

The present application provides a test data initialization method and device, electronic device, and storage medium, which can be applied to the big data field or the financial field. The method includes: obtaining a transaction code corresponding to a test case; if the test case needs to initialize data through a script, and queries the script template associated with the transaction code, then substituting the information of the test case into the script template to obtain the current transaction initialization script; executing the current transaction initialization script to initialize basic test data or clean up the test environment; executing the case script corresponding to the test case to obtain test data matching the test case; if the test case does not need to initialize data through a script, or the test data after script initialization does not meet the preset requirements, then obtaining the online transaction data of the test case and the online transaction template associated with the transaction code; generating a message based on the online transaction data and the online transaction template; and sending the message to the application system to initialize the test data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of system testing technology, and in particular to a test data initialization method and device, electronic equipment, and storage medium. Background Art

[0002] Currently, automated testing is commonly used for system testing. Automated testing often requires support for multiple concurrent cases and repeatable execution. However, test scenario data cannot be initialized based on the system's native functionality. Instead, data cleansing and generation must be performed by executing scripts, essentially initializing test data through scripts.

[0003] Currently, test data initialization primarily involves using a unified script to clean the original test data. The scripts for each test case are then re-executed to create a baseline of test data for all cases. If the baseline does not meet test requirements, adjustments are made through online trading.

[0004] However, the existing approach requires a set of scripts for each case, resulting in a large number of scripts and requiring extensive compilation, resulting in low efficiency and high maintenance costs. Furthermore, scenarios requiring only partial case execution require re-uploading the entire case data, increasing execution time and impacting processing efficiency. Summary of the Invention

[0005] Based on the above-mentioned deficiencies of the prior art, the present application provides a test data initialization method and device, an electronic device, and a storage medium to solve the problem of relatively slow efficiency of the prior art.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] The first aspect of the present application provides a test data initialization method, comprising:

[0008] Get the transaction code corresponding to the current test case;

[0009] Determine whether the current test case requires data initialization through a script;

[0010] If it is determined that the current case to be tested requires data initialization through a script, query whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested;

[0011] If a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested is found, the information of the current case to be tested is substituted into the target transaction initialization script template to obtain the current transaction initialization script;

[0012] Execute the current transaction initialization script to initialize basic test data or clean up the test environment;

[0013] If there is a case script corresponding to the current case to be tested, executing the case script corresponding to the current case to be tested to obtain test data matching the current case to be tested;

[0014] Determine whether the test data after script initialization meets the preset requirements;

[0015] If it is determined that the current case to be tested does not require script initialization data, or if it is determined that the test data after script initialization does not meet preset requirements, then obtaining pre-configured online transaction data of the current case to be tested and a target online transaction template associated with the transaction code corresponding to the current case to be tested;

[0016] Generate a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template;

[0017] The current transaction message is sent to the application system for test data initialization.

[0018] Optionally, in the above test data initialization method, before obtaining the transaction code corresponding to the current case to be tested, the method further includes:

[0019] In response to the script template configuration operation of the user, respectively configuring a transaction initialization script template associated with each transaction code according to the transaction codes of the multiple transactions;

[0020] In response to the transaction template configuration operation of the user, respectively configuring an online transaction template associated with each transaction code according to the transaction code of each transaction;

[0021] In response to the user's case script configuration operation, generating a case script corresponding to the current case to be tested;

[0022] In response to the transaction data configuration operation of the user, online transaction data of the current case to be tested is generated.

[0023] Optionally, in the above-mentioned test data initialization method, after responding to the user's transaction template configuration operation and configuring the online transaction template associated with each transaction code according to the transaction code of each transaction, the method further includes:

[0024] Based on the mapping relationship of the preset configuration, the Chinese interface configuration items in each of the online transaction templates are matched with the interface field items.

[0025] Optionally, in the above-mentioned test data initialization method, generating a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template includes:

[0026] By comparing the online transaction data of the current case to be tested with the target online transaction template, each inconsistent data item is determined;

[0027] Replacing the data of each inconsistent data item in the target online transaction template with the data of each inconsistent data item in the online transaction data of the current case to be tested;

[0028] The current transaction message is assembled using the data in the target online transaction template.

[0029] A second aspect of the present application provides a test data initialization device, comprising:

[0030] The first acquisition unit is used to obtain the transaction code corresponding to the current test case;

[0031] A first judgment unit is used to judge whether the current case to be tested needs to initialize data through a script;

[0032] a query unit configured to, when determining that the current case to be tested requires data initialization through a script, query whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested;

[0033] a substitution unit configured to, upon querying for a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested, substitute the information of the current case to be tested into the target transaction initialization script template to obtain a current transaction initialization script;

[0034] A first execution unit is configured to execute the current transaction initialization script to initialize basic test data or clean up the test environment;

[0035] A second execution unit is configured to execute the case script corresponding to the current case to be tested when there is a case script corresponding to the current case to be tested, to obtain test data matching the current case to be tested;

[0036] A second judging unit, configured to judge whether the test data after the script is initialized meets preset requirements;

[0037] a second acquiring unit configured to acquire pre-configured online transaction data of the current case to be tested and a target online transaction template associated with a transaction code corresponding to the current case to be tested, when determining that the current case to be tested does not require script initialization data or determining that the test data after script initialization does not meet preset requirements;

[0038] a message generating unit, configured to generate a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template;

[0039] The sending unit is used to send the current transaction message to the application system for test data initialization.

[0040] Optionally, the test data initialization device further includes:

[0041] a first configuration unit, configured to respond to a script template configuration operation by the user and configure, according to transaction codes of multiple transactions, a transaction initialization script template associated with each transaction code;

[0042] a second configuration unit, configured to respond to the transaction template configuration operation of the user and configure an online transaction template associated with each transaction code according to the transaction code of each transaction;

[0043] A third configuration unit is configured to generate a case script corresponding to the current case to be tested in response to the case script configuration operation of the user;

[0044] The fourth configuration unit is configured to generate the online transaction data of the current case to be tested in response to the transaction data configuration operation of the user.

[0045] Optionally, the test data initialization device further includes:

[0046] The matching unit is used to match the Chinese interface configuration items with the interface field items in each of the online transaction templates based on a preset mapping relationship.

[0047] Optionally, in the above-mentioned test data initialization device, the message generation unit includes:

[0048] a comparing unit, configured to determine each inconsistent data item by comparing the online transaction data of the current case to be tested with the target online transaction template;

[0049] a replacing unit, configured to replace data of each inconsistent data item in the target online transaction template with data of each inconsistent data item in the online transaction data of the current case to be tested;

[0050] An assembling unit is used to assemble the current transaction message using the data in the target online transaction template.

[0051] A third aspect of the present application provides an electronic device, including:

[0052] memory and processor;

[0053] Wherein, the memory is used to store programs;

[0054] The processor is used to execute the program, and when the program is executed, it is specifically used to implement any one of the test data initialization methods described above.

[0055] In a fourth aspect, the present application provides a first computer storage medium, characterized in that it is used to store a computer program, and when the computer program is executed, it is used to implement the test data initialization method as described in any one of the above.

[0056] An embodiment of the present application provides a test data initialization method to obtain the transaction code corresponding to the current case to be tested. Then, it is determined whether the current case to be tested needs to initialize data through a script. If it is determined that the current case to be tested needs to initialize data through a script, it is queried whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested. If it is queried that there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested, the information of the current case to be tested that is passed in is substituted into the target transaction initialization script template to obtain the current transaction initialization script, and then the current transaction initialization script is executed to initialize basic test data or clean up the test environment. In addition, if there is a case script corresponding to the current case to be tested, the case script corresponding to the current case to be tested is executed to obtain test data that matches the current case to be tested. The script then determines whether the test data after initialization meets preset requirements. If the current test case determines that script initialization data is not required, or if the test data after script initialization does not meet the preset requirements, the pre-configured online transaction data for the current test case and the target online transaction template associated with the transaction code corresponding to the current test case are obtained. Based on the online transaction data of the current test case and the data in the target online transaction template, the current transaction message is generated and finally sent to the application system for test data initialization. Thus, by segmenting the script and related data and then implementing template post-processing and dynamic configuration, an efficient test data initialization method is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0058] Figure 1 A flowchart of a test data initialization method provided in an embodiment of the present application;

[0059] Figure 2 A flowchart of a data configuration method provided in an embodiment of the present application;

[0060] Figure 3 A flowchart of a method for generating a current transaction message provided in an embodiment of the present application;

[0061] Figure 4 A schematic diagram of the structure of a test data initialization device provided in an embodiment of the present application;

[0062] Figure 5 A schematic diagram of the architecture of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0064] In this application, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.

[0065] The present application embodiment provides a test data initialization method, such as Figure 1 As shown, the following steps are included:

[0066] S101. Obtain the transaction code corresponding to the current case to be tested.

[0067] It should be noted that in order to distinguish different transactions, corresponding transaction codes are set for different transactions.

[0068] In the embodiment of the present application, the configured information is configured according to the transaction code, so it is necessary to first obtain the transaction code corresponding to the current case to be tested in order to obtain the configuration information corresponding to the current case to be tested.

[0069] Specifically, the transaction to which the current test case belongs may be determined first, and then the transaction code corresponding to the transaction may be determined, thereby obtaining the transaction code.

[0070] S102: Determine whether the current case to be tested requires data initialization through a script.

[0071] It should be noted that for some test cases, it is relatively troublesome to initialize the test through scripts, or it is impossible to obtain data that meets the requirements. Initializing the test data online may be simpler or ensure that the data meets the requirements. Therefore, for some test cases, it is not necessary to initialize the data through scripts.

[0072] Optionally, it may be determined whether the current case to be tested requires data initialization through a script according to the type of the current case to be tested.

[0073] If it is determined that the current case to be tested needs to initialize data through a script, step S103 is executed. If it is determined that the current case to be tested does not need to initialize data through a script, step S108 is executed.

[0074] S103: Check whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current test case.

[0075] It should be noted that in the embodiment of the present application, the originally identical foundation script and online transaction configuration data are split into two parts according to the transaction code, one part is the template configuration, and the other part is the case data configuration.

[0076] Template configuration is divided into transaction initialization script template configuration and online transaction template configuration. Case data configuration is divided into case script and online transaction data configuration. Therefore, before initializing the test data for the current test case, that is, before executing step S101, these data configurations must be performed.

[0077] Optionally, another embodiment of the present application provides a data configuration method, such as Figure 2 As shown, the following steps are included:

[0078] S201. In response to a script template configuration operation by a user, a transaction initialization script template associated with each transaction code is configured according to transaction codes of multiple transactions.

[0079] S202: In response to the user's transaction template configuration operation, configure the online transaction template associated with each transaction code according to the transaction code of each transaction.

[0080] Specifically, the interface message configuration data for each transaction is configured based on the transaction code, maintaining a one-to-one relationship between the transaction code and the Excel data configuration. When assembling online messages during automated testing, the configuration template data is first used as the initialization message template. This template data is then used by all test cases for a single transaction to obtain online message data.

[0081] Optionally, the information items in the fields about the interface in the configuration may be in Chinese. Therefore, in another embodiment of the present application, after executing step S202, the following steps may be further performed:

[0082] Based on the mapping relationship of the preset configuration, match the Chinese interface configuration items in each online transaction template with the interface field items.

[0083] S203: Respond to the user's case script configuration operation and generate a case script corresponding to the current case to be tested.

[0084] It should be noted that in the embodiment of the present application, when generating the case script corresponding to the case, dynamic parameter input is supported, that is, only the information that needs to be changed needs to be input, so that the case script corresponding to the case can be generated, thereby improving the generation efficiency of the case script.

[0085] S204: In response to the user's transaction data configuration operation, generate online transaction data of the current case to be tested.

[0086] It should be noted that for the online transaction data of the current test case, it is only necessary to configure the fields that need to be modified in the interface, and other interface field items can be directly obtained from the template, thereby improving the configuration efficiency of the online transaction data and further improving the efficiency of test data initialization.

[0087] Therefore, if it is found that there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current test case, step S104 is executed.

[0088] S104: Substitute the information of the current case to be tested into the target transaction initialization script template to obtain the current transaction initialization script.

[0089] Specifically, the changed information such as the customer number of the current case to be tested is substituted into the target transaction initialization script template, thereby obtaining the transaction initialization script corresponding to the current case to be tested.

[0090] S105. Execute the current transaction initialization script to initialize basic test data or clean up the test environment.

[0091] Specifically, for similar cases that have been executed before, it is only necessary to initialize the basic test data, that is, adjust the data value. For situations where the test environment does not meet the current test case, it is necessary to use the corresponding basic test data to replace the original data to clean up the test environment and avoid applying this test execution.

[0092] S106: If there is a case script corresponding to the current case to be tested, execute the case script corresponding to the current case to be tested to obtain test data matching the current case to be tested.

[0093] S107: Determine whether the test data after the script is initialized meets the preset requirements.

[0094] It should be noted that after initialization through the script, the initialized test data may not meet the test requirements, so it is necessary to first determine whether the test data after the script initialization meets the preset requirements, so that when it is determined that the test data after the script initialization does not meet the preset requirements, step S108 can be executed to further improve the test data.

[0095] S108: Obtain pre-configured online transaction data of the current case to be tested and a target online transaction template associated with the transaction code corresponding to the current case to be tested.

[0096] S109: Generate a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template.

[0097] It should be noted that the online transaction data of the current case to be tested is the information about the interface of the current case to be tested, and the target online transaction template is equivalent to the template of the transaction message. Therefore, by substituting the online transaction data of the current case to be tested into the data in the target online transaction template, the current transaction message can be obtained.

[0098] Optionally, in another embodiment of the present application, a specific implementation method of step S109 is as follows: Figure 3 As shown, the following steps are included:

[0099] S301. Determine each inconsistent data item by comparing the online transaction data of the current case to be tested with the target online transaction template.

[0100] In order to improve efficiency, in the embodiment of the present application, it is only necessary to replace the inconsistent data between the online transaction data of the current case to be tested and the target online transaction template. Therefore, it is necessary to first compare the online transaction data of the current case to be tested with the target online transaction template to determine each inconsistent data item, and then execute step S302.

[0101] S302: Replace the data of each inconsistent data item in the target online transaction template with the data of each inconsistent data item in the online transaction data of the current case to be tested.

[0102] S303: Assemble the current transaction message using the data in the target online transaction template.

[0103] S110: Send the current transaction message to the application system to initialize test data.

[0104] Specifically, after the current transaction message is sent to the application system, the application system will initialize the test data of the current case to be tested based on the current transaction message.

[0105] An embodiment of the present application provides a test data initialization method to obtain the transaction code corresponding to the current case to be tested. Then, it is determined whether the current case to be tested needs to initialize data through a script. If it is determined that the current case to be tested needs to initialize data through a script, it is queried whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested. If it is queried that there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested, the information of the current case to be tested that is passed in is substituted into the target transaction initialization script template to obtain the current transaction initialization script, and then the current transaction initialization script is executed to initialize basic test data or clean up the test environment. In addition, if there is a case script corresponding to the current case to be tested, the case script corresponding to the current case to be tested is executed to obtain test data that matches the current case to be tested. The script then determines whether the test data after initialization meets preset requirements. If the current test case determines that script initialization data is not required, or if the test data after script initialization does not meet the preset requirements, the pre-configured online transaction data for the current test case and the target online transaction template associated with the transaction code corresponding to the current test case are obtained. Based on the online transaction data of the current test case and the data in the target online transaction template, the current transaction message is generated and finally sent to the application system for test data initialization. Thus, by segmenting the script and related data and then implementing template post-processing and dynamic configuration, an efficient test data initialization method is achieved.

[0106] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0107] Although the operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.

[0108] Another embodiment of the present application provides a test data initialization device, such as Figure 4 As shown, it includes the following units:

[0109] The first acquiring unit 401 is configured to acquire a transaction code corresponding to the current case to be tested.

[0110] The first judgment unit 402 is used to judge whether the current case to be tested needs to initialize data through a script.

[0111] The query unit 403 is configured to query whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested when it is determined that the current case to be tested needs to initialize data through a script.

[0112] The substitution unit 404 is configured to substitute the information of the current test case into the target transaction initialization script template when finding a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current test case to obtain the current transaction initialization script.

[0113] The first execution unit 405 is configured to execute the current transaction initialization script to initialize basic test data or clean up the test environment.

[0114] The second execution unit 406 is configured to execute the case script corresponding to the current case to be tested, if there is a case script corresponding to the current case to be tested, to obtain test data matching the current case to be tested.

[0115] The second judging unit 407 is configured to judge whether the test data after the script is initialized meets a preset requirement.

[0116] The second acquisition unit 408 is used to obtain the pre-configured online transaction data of the current case to be tested and the target online transaction template associated with the transaction code corresponding to the current case to be tested when it is determined that the current case to be tested does not require script initialization data or when it is determined that the test data after script initialization does not meet the preset requirements.

[0117] The message generating unit 409 is configured to generate a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template.

[0118] The sending unit 410 is used to send the current transaction message to the application system for test data initialization.

[0119] Optionally, in another embodiment of the present application, the test data initialization device further includes:

[0120] The first configuration unit is configured to respond to a script template configuration operation of a user and configure a transaction initialization script template associated with each transaction code according to transaction codes of multiple transactions.

[0121] The second configuration unit is configured to respond to the transaction template configuration operation of the user and configure the online transaction template associated with each transaction code according to the transaction code of each transaction.

[0122] The third configuration unit is used to respond to the user's case script configuration operation and generate a case script corresponding to the current case to be tested.

[0123] The fourth configuration unit is configured to respond to the user's transaction data configuration operation and generate online transaction data of the current case to be tested.

[0124] Optionally, in another embodiment of the present application, the test data initialization device further includes:

[0125] The matching unit is used to match the Chinese interface configuration items with the interface field items in each online transaction template based on a mapping relationship of a preset configuration.

[0126] Optionally, in the test data initialization device provided in another embodiment of the present application, the message generating unit includes:

[0127] The comparison unit is used to determine each inconsistent data item by comparing the online transaction data of the current case to be tested with the target online transaction template.

[0128] The replacement unit is used to replace the data of each inconsistent data item in the target online transaction template with the data of each inconsistent data item in the online transaction data of the current test case.

[0129] The assembling unit is used to assemble the current transaction message using the data in the target online transaction template.

[0130] It should be noted that the specific working process of each unit provided in the above embodiments of the present application can refer to the corresponding steps in the above method embodiments, and will not be repeated here.

[0131] Another embodiment of the present application provides an electronic device, such as Figure 5 Shown, including:

[0132] Memory 501 and processor 502 .

[0133] The memory 501 is used to store programs.

[0134] The processor 502 is used to execute the program stored in the memory 501. When the program is executed, it is specifically used to implement the test data initialization method provided in any one of the above embodiments.

[0135] Another embodiment of the present application provides a first computer storage medium for storing a computer program. When the computer program is executed, it is used to implement the test data initialization method provided in any one of the above embodiments.

[0136] Computer storage media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0137] It should be noted that the test data initialization method and apparatus, electronic device, and storage medium provided by the present invention can be used in the big data field or the financial field. The above is merely an example and does not limit the application fields of the test data initialization method and apparatus, electronic device, and storage medium provided by the present invention.

[0138] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0139] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A test data initialization method, characterized in that: include: Get the transaction code corresponding to the current test case; Determine whether the current test case requires data initialization through a script; If it is determined that the current case to be tested requires data initialization through a script, query whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested; If a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested is found, the information of the current case to be tested is substituted into the target transaction initialization script template to obtain the current transaction initialization script; Execute the current transaction initialization script to initialize basic test data or clean up the test environment; If there is a case script corresponding to the current case to be tested, executing the case script corresponding to the current case to be tested to obtain test data matching the current case to be tested; Determine whether the test data after script initialization meets the preset requirements; If it is determined that the current case to be tested does not require script initialization data, or if it is determined that the test data after script initialization does not meet preset requirements, then obtaining pre-configured online transaction data of the current case to be tested and a target online transaction template associated with the transaction code corresponding to the current case to be tested; Generate a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template; Sending the current transaction message to the application system for test data initialization; Before obtaining the transaction code corresponding to the current test case, the following steps are also included: In response to the user's script template configuration operation, according to the transaction codes of multiple transactions, respectively configure the transaction initialization script template associated with each of the transaction codes; In response to the transaction template configuration operation of the user, respectively configuring an online transaction template associated with each transaction code according to the transaction code of each transaction; In response to the user's case script configuration operation, generating a case script corresponding to the current case to be tested; In response to the transaction data configuration operation of the user, online transaction data of the current case to be tested is generated.

2. The method according to claim 1, characterized in that After responding to the transaction template configuration operation of the user and configuring the online transaction template associated with each transaction code according to the transaction code of each transaction, the method further includes: Based on the mapping relationship of the preset configuration, the Chinese interface configuration items in each of the online transaction templates are matched with the interface field items.

3. The method according to claim 1, characterized in that The generating of the current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template includes: By comparing the online transaction data of the current case to be tested with the target online transaction template, each inconsistent data item is determined; Replacing the data of each inconsistent data item in the target online transaction template with the data of each inconsistent data item in the online transaction data of the current case to be tested; The current transaction message is assembled using the data in the target online transaction template.

4. A test data initialization device, characterized in that: include: A first configuration unit is configured to respond to a script template configuration operation by a user and configure, according to transaction codes of multiple transactions, a transaction initialization script template associated with each transaction code; a second configuration unit, configured to respond to the transaction template configuration operation of the user and configure an online transaction template associated with each transaction code according to the transaction code of each transaction; A third configuration unit is configured to generate a case script corresponding to the current case to be tested in response to the case script configuration operation of the user; A fourth configuration unit, configured to generate online transaction data of the current case to be tested in response to the transaction data configuration operation of the user; The first acquisition unit is used to obtain the transaction code corresponding to the current test case; A first judgment unit is used to judge whether the current case to be tested needs to initialize data through a script; a query unit configured to, when determining that the current case to be tested requires data initialization through a script, query whether there is a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested; a substitution unit configured to, upon querying for a pre-configured target transaction initialization script template associated with the transaction code corresponding to the current case to be tested, substitute the information of the current case to be tested into the target transaction initialization script template to obtain a current transaction initialization script; A first execution unit is configured to execute the current transaction initialization script to initialize basic test data or clean up the test environment; A second execution unit is configured to execute the case script corresponding to the current case to be tested when there is a case script corresponding to the current case to be tested, to obtain test data matching the current case to be tested; A second judging unit, configured to judge whether the test data after the script is initialized meets preset requirements; a second acquiring unit configured to acquire pre-configured online transaction data of the current case to be tested and a target online transaction template associated with a transaction code corresponding to the current case to be tested, when determining that the current case to be tested does not require script initialization data or determining that the test data after script initialization does not meet preset requirements; a message generating unit, configured to generate a current transaction message based on the online transaction data of the current case to be tested and the data in the target online transaction template; The sending unit is used to send the current transaction message to the application system for test data initialization.

5. The device according to claim 4, characterized in that Also includes: The matching unit is used to match the Chinese interface configuration items with the interface field items in each of the online transaction templates based on a preset mapping relationship.

6. The device according to claim 4, characterized in that The message generating unit includes: a comparing unit, configured to determine each inconsistent data item by comparing the online transaction data of the current case to be tested with the target online transaction template; a replacing unit, configured to replace data of each inconsistent data item in the target online transaction template with data of each inconsistent data item in the online transaction data of the current case to be tested; An assembling unit is used to assemble the current transaction message using the data in the target online transaction template.

7. An electronic device, characterized in that: include: memory and processor; Wherein, the memory is used to store programs; The processor is used to execute the program, and when the program is executed, it is specifically used to implement the test data initialization method according to any one of claims 1 to 3.

8. A computer storage medium, characterized in that Used to store a computer program, which, when executed, is used to implement the test data initialization method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Interface test method and device based on test scene, equipment and medium

    CN113176995A

  • Test case test method and device, equipment and storage medium

    CN113254352A