Instance generation method and device, equipment, storage medium and product
By automatically parsing message standards and generating test instances, the problem of low testing efficiency when connecting to different banking systems is solved, and efficient test case generation and improved system stability are achieved.
Patent Information
- Application Number
- CN202510909307.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-02
- Publication Date
- 2025-10-21
AI Technical Summary
When connecting to different banking systems, development and testing personnel need to read and understand the definitions of various messages one by one, resulting in a large amount of manpower and time spent on checking message standards, which reduces testing efficiency.
By obtaining the message standard, parsing the message list and basic rules, generating test cases and filling the test data into the message template, the system automatically generates test instances, including identifying signature elements and performing encryption processing, to meet the testing needs in different scenarios.
It improves testing efficiency, reduces the time for manual reading and comprehension, and improves test coverage and system stability and adaptability.
Smart Images

Figure CN120825532A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing technology, and in particular to an instance generation method, apparatus, device, storage medium, and product. Background Art
[0002] In related technologies, when connecting to different bank systems, development and testing personnel need to read and understand the various message definitions and scenarios of the message standards provided by different banks one by one. As a result, when checking the message definitions of the message standards, a large amount of manpower and time are required to do test analysis, design and execution, which reduces testing efficiency. Summary of the Invention
[0003] The main purpose of this application is to provide an instance generation method, device, equipment, storage medium and product, aiming to solve the technical problem that manual inspection of message definitions of message standards reduces test efficiency.
[0004] To achieve the above objectives, the present application proposes an instance generation method, which includes:
[0005] Obtaining a message standard and parsing the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard;
[0006] Traversing the message list, parsing to obtain a message structure of each message in the message list, wherein the message structure includes element rules of fields and logical relationships between fields;
[0007] Generate test cases based on the relevant basic rules, and generate corresponding test data according to the test cases;
[0008] Fill the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance.
[0009] In one embodiment, after the step of traversing the message list and parsing to obtain the message structure of the message list, the following steps are included:
[0010] Identifying the signature element in the message structure;
[0011] Obtaining signature information corresponding to the signature element from the message structure, wherein the signature information includes a signature field list, a signature algorithm, and a signature key;
[0012] Based on the signature information, a signature method is called to encrypt the signature content corresponding to the signature element based on the called signature method.
[0013] In one embodiment, the step of filling the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance includes:
[0014] Extracting signature elements from the test data;
[0015] Digitally signing the elements to be signed based on the order of arrangement of the signing elements in the message template using the signing method to obtain the signed content;
[0016] A test instance is generated based on the message template corresponding to the signature content and the signature elements.
[0017] In one embodiment, the steps of generating a test case based on the relevant basic rules and generating corresponding test data according to the test case include:
[0018] Based on the relevant basic rules, generating test cases in different scenarios, wherein the scenarios include normal scenarios, boundary scenarios, and abnormal scenarios;
[0019] When the scenario is the normal scenario, generating test data that complies with the relevant basic rules for the test case corresponding to the normal scenario;
[0020] When the scenario is the boundary scenario, determining the boundary conditions based on the relevant basic rules, and generating the test data that meets the boundary conditions for the test case corresponding to the boundary scenario;
[0021] When the scenario is the abnormal scenario, the test data that does not comply with the relevant basic rules is generated for the test case corresponding to the abnormal scenario.
[0022] In one embodiment, after the step of generating a test instance based on the message template corresponding to the endorsement content and the endorsement element, the following steps are included:
[0023] Sending the test case to a test platform, and receiving a test result returned by the test platform based on the test case;
[0024] If the test result is that the decryption fails, the arrangement order of the signature elements in the message template is adjusted to obtain the adjusted message template;
[0025] Encrypting the elements to be signed based on the adjusted arrangement order of the message templates, and generating a new test instance based on the encrypted signed elements;
[0026] The new test case is sent to the test platform again until the test platform returns a test result indicating that the test has passed.
[0027] In one embodiment, after the step of filling the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance, the step includes:
[0028] When the updated message standard is obtained, the message structure of the updated message standard is compared with that of the previous version of the message standard to obtain update information;
[0029] Based on the update information, the message template is updated to obtain an updated target message template;
[0030] Based on the target message template, the test instance corresponding to the message standard of the previous version is converted into a test instance adapted to the updated message standard.
[0031] In addition, to achieve the above-mentioned purpose, the present application also proposes an instance generation device, which includes:
[0032] An acquisition module, configured to acquire a message standard and parse the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard;
[0033] a parsing module, configured to traverse the message list and parse to obtain a message structure of each message in the message list, wherein the message structure includes element rules of fields and logical relationships between fields;
[0034] A generation module, configured to generate test cases based on the relevant basic rules, and generate corresponding test data according to the test cases;
[0035] A filling module is used to fill the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes an instance generation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the instance generation method described above.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the steps of the instance generation method described above are implemented.
[0038] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the instance generation method described above are implemented.
[0039] One or more technical solutions proposed in this application have at least the following technical effects:
[0040] Compared with the related art, when connecting to different bank systems, development testers need to read and understand the various message definitions and scenarios of the message standards provided by different banks one by one, resulting in a large amount of manpower and time required for test analysis, design and execution when checking the message definitions of the message standards, which reduces the test efficiency. In comparison, the present application obtains the message standard and parses the message standard to obtain a message list and related basic rules, wherein the message list includes a collection of all message types defined in the message standard; traverses the message list and parses to obtain the message structure of each message in the message list, wherein the message structure includes the element rules of the fields and the logical relationship between the fields; based on the related basic rules, a test case is generated, and corresponding test data is generated according to the test case, and the test data corresponding to each test case is filled in the message template assembled based on the message structure to generate a test instance. After obtaining the message standard, this application will automatically parse it and automatically parse the parsed message list to obtain a message structure including the logical relationship between fields and the element rules of the fields. According to the relevant basic rules after parsing the message standard, the application will automatically generate test cases, and generate corresponding test data based on the generated test cases. The test data will be filled into the message template assembled based on the message structure to generate a test instance. Through the above series of automated instance generation steps, there is no need for development testers to read and understand the various message definitions and scenarios of the message standards provided by different banks one by one, thereby improving testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0043] Figure 1 A flowchart of the first embodiment of the method for generating an example of this application is provided;
[0044] Figure 2Generate an overall flow chart for the example of the example generation method of this application;
[0045] Figure 3 A flow chart illustrating the second embodiment of the method for generating an example of this application;
[0046] Figure 4 This is a schematic diagram of the module structure of an example generating device according to an embodiment of the present application;
[0047] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the example generation method in the embodiment of the present application.
[0048] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0050] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0051] The main solution of the embodiment of the present application is: obtaining the message standard, and parsing the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard; traversing the message list, parsing to obtain the message structure of each message in the message list, wherein the message structure includes the element rules of the fields and the logical relationship between the fields; based on the related basic rules, generating test cases, and generating corresponding test data according to the test cases, filling the test data corresponding to each test case into the message template assembled based on the message structure to generate a test instance.
[0052] In related technologies, when connecting to different bank systems, development and testing personnel need to read and understand the various message definitions and scenarios of the message standards provided by different banks one by one. As a result, when checking the message definitions of the message standards, a large amount of manpower and time are required to do test analysis, design and execution, which reduces testing efficiency.
[0053] After obtaining the message standard, this application will automatically parse it and automatically parse the parsed message list to obtain the message structure including the logical relationship between fields. According to the relevant basic rules after the message standard is parsed, the application will automatically generate test cases, and generate corresponding test data based on the generated test cases. The test data will be filled into the message template assembled based on the message structure to generate a test instance. Through the above series of automated instance generation steps, there is no need for development test personnel to read and understand the various message definitions and scenarios of the message standards provided by different banks one by one, thereby improving testing efficiency.
[0054] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of implementing the above functions, an instance generation device, etc. The following uses the instance generation device as an example to illustrate this embodiment and the following embodiments.
[0055] Based on this, the embodiment of the present application provides an example generation method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the example generation method of this application.
[0056] In this embodiment, the instance generation method includes steps S10 to S40:
[0057] Step S10: Acquire a message standard and parse the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard;
[0058] It should be noted that the executor of this embodiment is the instance generation device. The message standard is adapted to various banking systems, such as the ELCS electronic certificate system and the HVPS large-value system. The relevant basic rules include key information such as field name, type, length, mandatory, and value range. The message list may include message types such as payment service request messages and letter of credit opening applications. The instance generation device obtains a message standard file in PDF or Word format, parses the message standard, removes irrelevant information (headers, footers, directories, watermarks, etc.), retains the core field definition and message description, and obtains a message list and relevant basic rules.
[0059] Furthermore, specifically, taking the People's Bank of China as an example, the latest version of the message standard can be downloaded from the official channels provided by the People's Bank of China or relevant regulatory agencies, or received from the official standard documents released by partners or third-party platforms.
[0060] Step S20, traversing the message list and parsing to obtain the message structure of each message in the message list, wherein the message structure includes the element rules of the fields and the logical relationship between the fields;
[0061] It can be understood that the element rules represent the basic requirements and constraints that a field must meet in terms of structure and content. The message structure is in XML format. For each message type, the instance generation device locates its structure definition part from the message standard. For example, if the message standard is a Word / PDF document, the field structure table or nested hierarchy description is extracted. The parent-child relationship, number of repetitions, optionality and other information between fields must be retained. According to the field definition in the message standard, corresponding elements and attributes are created, and the data type, number of occurrences (minOccurs, maxOccurs), default value, etc. of each element are defined to ensure that the hierarchical relationship between elements is reflected in the message structure in XML format.
[0062] Furthermore, after obtaining the message structure, the instance generation device will compare it with the original document to confirm that all necessary fields and constraints have been correctly represented.
[0063] Step S30: generating a test case based on the relevant basic rules, and generating corresponding test data according to the test case;
[0064] It's important to note that the instance generation device generates clearly structured, scenario-complete test cases based on field-based rules, and also generates corresponding test data for them. This approach not only improves testing efficiency but also enhances system stability and maintainability, making it a valuable practical approach in scenarios such as financial systems, payment systems, and interbank messaging.
[0065] Step S40: Fill the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance.
[0066] It can be understood that the instance generation device establishes a structured template with fillable field values for each message type according to the message structure, substitutes the specific test data in the test case into the corresponding position of the template, and saves the filled message as a complete test instance.
[0067] Specifically, the instance generation device builds a template with placeholders based on the parsed message structure. The placeholders represent the field positions to be replaced with actual test data in the future, where the field names in each test case correspond one-to-one to the placeholders in the template. The instance generation device compares the field names listed in the test case and finds the corresponding placeholders in the template to ensure that all fields are correctly identified and can be used for replacement. After obtaining the template, the field values provided in the test case need to be replaced with the placeholders in the template in turn. For nested structure or array fields, their subfields are processed recursively. If the field is optional and the test case is not assigned a value, the field is omitted in the final message. Figure 2 , Figure 2 Provides an overall flow chart for instance generation.
[0068] In a feasible implementation manner, step S10 may include the following steps:
[0069] Identifying the signature element in the message structure;
[0070] It should be noted that the instance generation device determines which fields belong to signature-related fields (i.e., "signature elements"). Specifically, it searches for signature-related fields or nodes in the parsed message structure, and the message standard document clearly marks them as being used for signature verification.
[0071] Obtaining signature information corresponding to the signature element from the message structure, wherein the signature information includes a signature field list, a signature algorithm, and a signature key;
[0072] It is understandable that the signature field is the name of the field storing the signature value. The instance generation device searches for the field containing the signature information in the parsed message structure. Since the signature is asymmetric, the public and private key configuration requirements required for the signature are also obtained.
[0073] Based on the signature information, a signature method is called to encrypt the signature content corresponding to the signature element based on the called signature method.
[0074] It should be noted that the instance generation device constructs a standardized signing method template, the content of which should include: method name (such as generateSignature), input parameters (original data, private key, signature algorithm), output result (signature value) and usage scenario description (such as "used for signature generation before HVPS message sending"), as well as insertion rules for which field in the template the signature information corresponding to the signature element after signing should be inserted back into. Because the message signing methods for different usage scenarios may be different, a signing method template should be assigned to different types of messages.
[0075] Specifically, the instance generation device calls the signing method corresponding to each field according to the signing information corresponding to the signing element.
[0076] In a feasible implementation manner, the test data corresponding to each test case is filled into a message template assembled based on the message structure, and the step of generating a test instance includes:
[0077] Extracting signature elements from the test data;
[0078] It can be understood that the instance generation device extracts the fields that need to be signed in the test data. If the field is empty or not provided, it is filled with a default value or marked as an exception according to the rules. If the field is in a nested structure, the complete value needs to be extracted according to the path.
[0079] Digitally signing the elements to be signed based on the order of arrangement of the signing elements in the message template using the signing method to obtain the signed content;
[0080] It should be noted that in the process of generating test instances, in order to ensure the integrity and security of the message, the information corresponding to the elements to be signed in the message needs to be digitally signed. The key to this process is that the instance generation device must generate a valid signature value according to the arrangement order of the fields corresponding to the signing elements defined in the message template, and perform the signing operation through the existing signing method according to the message type.
[0081] A test instance is generated based on the message template corresponding to the signature content and the signature elements.
[0082] It can be understood that the instance generation device returns the signature result as the signature element and its corresponding signature information, inserts it into the message template, and finally generates a complete test instance.
[0083] In a feasible implementation manner, the step of generating a test case based on the encrypted signature element includes:
[0084] Sending the test case to a test platform, and receiving a test result returned by the test platform based on the test case;
[0085] It should be noted that the instance generation device submits the test case to the test platform for execution, and obtains the actual response of the test platform under different test instances.
[0086] If the test result is that the decryption fails, the arrangement order of the signature elements in the message template is adjusted to obtain the adjusted message template;
[0087] It is understandable that after the instance generation device obtains the test results, it will analyze the reasons for failure in the test results to confirm whether the failure is caused by inconsistent signature field order. If the test result returns "decryption failed" or "signature verification failed", it means that the current message structure (especially the arrangement order or field content of the elements to be signed) is inconsistent with the expected signature logic of the docking bank. At this time, the instance generation device needs to adjust the arrangement order of the fields involved in the signature (i.e., the elements to be signed) in the message template to match the recipient's parsing and verification logic.
[0088] Encrypting the elements to be signed based on the adjusted arrangement order of the message templates, and generating a new test instance based on the encrypted signed elements;
[0089] It can be understood that after the instance generation device adjusts the arrangement order of the elements to be signed in the message template, the next step is to encrypt (sign) these elements to be signed based on the new field order, and generate new test instances that conform to the new structure, ensuring that the test data is not only compliant in content, but also has the ability to perform verification under the premise that the signature logic is consistent with the requirements of the docking bank.
[0090] The new test case is sent to the test platform again until the test platform returns a test result indicating that the test has passed.
[0091] It should be noted that in the test process, the instance generation device will send the adjusted "new test case" to the test platform again, and continue to verify until the returned test result is "test passed". This is a key closed-loop operation to ensure that the system docking logic, signature mechanism, data format, etc. are all in line with expectations.
[0092] In a feasible implementation manner, after filling the test data corresponding to each test case into a message template assembled based on the message structure, the step of generating a test instance includes:
[0093] When the updated message standard is obtained, the message structure of the updated message standard is compared with that of the previous version of the message standard to obtain update information;
[0094] It should be noted that when the instance generation device obtains the message standard, it will also obtain the version number corresponding to the message standard. After receiving the updated message standard, it will identify the structural differences between the new and old versions and extract the following types of update information: new fields, deleted fields, field name modifications, field order adjustments, field type / length limit changes, and signature fields or signature logic changes and other more detailed information.
[0095] Based on the update information, the message template is updated to obtain an updated target message template;
[0096] It is understandable that the instance generating device may update the message template according to the update information to obtain a more refined target message template.
[0097] The specific steps include:
[0098] Add the new fields to the corresponding positions in the template:
[0099] 1. Insert a new field node at the specified level;
[0100] 2. If the insertion position is not specified, it is added to the end of the field list by default;
[0101] 3. If the field belongs to the signature range, the signature field list is updated synchronously.
[0102] Remove deprecated fields to keep the template simple:
[0103] 1. Find and delete deprecated fields from the template;
[0104] 2. If a field is required and has no alternative field, it should be marked as an exception for manual confirmation;
[0105] 3. If the field is involved in the signature, it must be removed from the signature field list simultaneously.
[0106] Adapt to changes in field naming or definition:
[0107] 1. Replace the old field name with the new field name;
[0108] 2. If the field type changes (e.g. string → decimal), mark the new type in the template;
[0109] 3. For field changes in nested structures, recursive processing is required.
[0110] Match changes in field arrangement or structural hierarchy in the new version of the message:
[0111] 1. Rearrange the field nodes according to the new field order;
[0112] 2. If there is a structural reorganization (such as moving a field from the body to the header), adjust its hierarchical position;
[0113] 3. Synchronously update the signature field path and splicing order.
[0114] Ensure that the signature mechanism is consistent with the new version of the message structure:
[0115] 1. Update the signature field path;
[0116] 2. If the signature algorithm changes, the signing method will be updated synchronously;
[0117] 3. If the number or order of signature fields changes, the signature data logic needs to be reconstructed.
[0118] Based on the target message template, the test instance corresponding to the message standard of the previous version is converted into a test instance adapted to the updated message standard.
[0119] It should be noted that the instance generation device obtains the test data of the previous version for subsequent mapping and conversion, and clarifies the field structure and constraints supported in the new version, compares the field definitions of the new and old versions, establishes a field name mapping table, and maps the old data to the new structure through the above mapping table.
[0120] In this embodiment, by automating the entire process from message standard parsing to test instance generation, not only the test efficiency and quality are improved, but also the adaptability and stability of the system are enhanced.
[0121] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 3 , step S30, the instance generation method further includes steps S01 to S04:
[0122] Step S01: generating test cases in different scenarios based on the relevant basic rules, wherein the scenarios include normal scenarios, boundary scenarios, and abnormal scenarios;
[0123] It is understandable that before generating test cases, the instance generation device needs to conduct a detailed analysis of the fields in the message structure and extract the basic rules of the fields. These rules will serve as an important basis for generating test cases. According to the above basic rules and combined with actual business needs, test cases for different test scenarios are generated.
[0124] Step S02: when the scenario is the normal scenario, generating test data that complies with the relevant basic rules for the test case corresponding to the normal scenario;
[0125] It should be noted that a normal scenario refers to a scenario where the test data strictly complies with the relevant basic rules defined in the message standard. When the scenario is normal, the instance generation device obtains the constraint rules for each field based on the relevant basic rules and generates compliant test data, thereby ensuring that transactions can be processed correctly and stably under standard input conditions.
[0126] Step S03: when the scenario is the boundary scenario, determining the boundary conditions based on the relevant basic rules, and generating the test data that meets the boundary conditions for the test case corresponding to the boundary scenario;
[0127] It can be understood that a boundary scenario is one in which the field values of the test data fall within boundary conditions. When the scenario is a boundary scenario, the instance generation device identifies and constructs test data with field values falling within boundary conditions based on the constraint rules of each field. This enhances the ability to handle extreme inputs and provides strong support for building a high-quality, high-reliability test system.
[0128] Step S04: When the scenario is the abnormal scenario, the test data that does not comply with the relevant basic rules is generated for the test case corresponding to the abnormal scenario.
[0129] It should be noted that abnormal scenarios are those in which test data does not conform to relevant basic rules. When a scenario is abnormal, the instance generator reversely constructs test data that does not conform to these rules to simulate abnormal conditions such as illegal input, missing fields, and format errors. This not only enhances the stability and security of the system, but also provides solid support for building a high-quality, high-coverage test system.
[0130] In this implementation, based on relevant basic rules, constructing test data that complies with or violates the rules for different scenarios (normal, boundary, abnormal) is a key link in building a high-quality testing system. This method not only improves test coverage and system robustness, but also provides strong guarantees for system stability, security and compliance.
[0131] This application also provides an example generation device, please refer to Figure 4 , the instance generating device includes:
[0132] An acquisition module 10 is configured to acquire a message standard and parse the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard;
[0133] A parsing module 20, configured to traverse the message list and parse to obtain a message structure of each message in the message list, wherein the message structure includes element rules of fields and logical relationships between fields;
[0134] A generating module 30 is configured to generate a test case based on the relevant basic rules, and generate corresponding test data according to the test case;
[0135] The filling module 40 is used to fill the test data corresponding to each test case into the message template assembled based on the message structure to generate a test instance.
[0136] Optionally, the parsing module includes:
[0137] The signing method generation submodule is used to identify the signing elements in the message structure; obtain the signing information corresponding to the signing elements from the message structure, wherein the signing information includes a signature field list, a signature algorithm, and a signature key; based on the signing information, call the signing method to encrypt the signing content corresponding to the signing elements based on the called signing method.
[0138] Optionally, the filling module includes:
[0139] An extraction submodule is used to extract the signature elements in the test data; digitally sign the elements to be signed based on the arrangement order of the signature elements in the message template through the signing method to obtain the signature content after signing; and generate a test instance based on the signature content and the message template corresponding to the signature elements.
[0140] An update submodule is used to compare the message structure of the updated message standard with that of the previous version of the message standard to obtain update information when the updated message standard is obtained; based on the update information, the message template is updated to obtain an updated target message template; based on the target message template, the test instance corresponding to the previous version of the message standard is converted into a test instance that adapts to the updated message standard.
[0141] Optionally, the generating module includes:
[0142] The test data generation submodule is used to generate test cases in different scenarios based on the relevant basic rules, wherein the scenarios include normal scenarios, boundary scenarios and abnormal scenarios; when the scenario is the normal scenario, test data that complies with the relevant basic rules is generated for the test case corresponding to the normal scenario; when the scenario is the boundary scenario, boundary conditions are determined based on the relevant basic rules, and test data that complies with the boundary conditions is generated for the test case corresponding to the boundary scenario; when the scenario is the abnormal scenario, test data that does not comply with the relevant basic rules is generated for the test case corresponding to the abnormal scenario.
[0143] Optionally, the signing method generates a submodule, including:
[0144] An adjustment unit is used to send the test case to the test platform and receive the test result returned by the test platform based on the test case; if the test result is decryption failure, the arrangement order of the signature elements in the message template is adjusted to obtain the adjusted message template; based on the adjusted arrangement order of the message template, the elements to be signed are encrypted, and a new test instance is generated based on the encrypted signature elements; the new test case is sent to the test platform again until the test result returned by the test platform is that the test passed.
[0145] The example generation device provided in this application utilizes the example generation method described in the aforementioned embodiments to address the technical issues surrounding example generation. Compared to the prior art, the example generation device provided in this application achieves the same beneficial effects as the example generation method described in the aforementioned embodiments. Other technical features of the example generation device are the same as those disclosed in the aforementioned embodiments and are not further elaborated upon here.
[0146] The present application provides an instance generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the instance generation method in the above-mentioned embodiment 1.
[0147] Reference below Figure 5 , which shows a schematic diagram of the structure of an example generation device suitable for implementing the embodiments of the present application. The example generation device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, tablet computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The example generating device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0148] like Figure 5As shown, the instance generation device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. RAM 1004 also stores various programs and data required for the operation of the instance generation device. Processing device 1001, ROM 1002, and RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input device 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output device 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage device 1003 including, for example, a magnetic tape, hard disk, etc.; and communication device 1009. The communication device 1009 can allow the instance generation device to communicate with other devices wirelessly or wired to exchange data. Although the figure shows an instance generation device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems can be implemented or have alternatively.
[0149] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0150] The example generation device provided in this application utilizes the example generation method described in the aforementioned embodiment to solve the technical problem of example generation. Compared to the prior art, the example generation device provided in this application has the same beneficial effects as the example generation method described in the aforementioned embodiment. Other technical features of the example generation device are the same as those disclosed in the aforementioned embodiment and are not further elaborated here.
[0151] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0152] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0153] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, and the computer-readable program instructions are used to execute the instance generation method in the above embodiment.
[0154] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0155] The computer-readable storage medium may be included in the instance generation device, or may exist independently without being incorporated into the instance generation device.
[0156] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the instance generation device, the instance generation device is enabled to: obtain the message standard, and parse the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard; traverse the message list, and parse to obtain the message structure of each message in the message list, wherein the message structure includes the element rules of the fields and the logical relationship between the fields; generate a test case based on the related basic rules, and generate corresponding test data according to the test case; fill the test data corresponding to each of the test cases into the message template assembled based on the message structure to generate a test instance.
[0157] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0158] The flow charts and block diagrams in the accompanying drawings illustrate the possible 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 flow chart 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 realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than 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 flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0159] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0160] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for executing the aforementioned instance generation method, thereby resolving the technical problem of instance generation. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the instance generation method provided in the aforementioned embodiments, and are not further elaborated here.
[0161] The present application also provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned instance generation method when executed by a processor.
[0162] The computer program product provided in this application can solve the technical problem of instance generation. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the instance generation method provided in the above embodiment, and will not be repeated here.
[0163] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for generating an instance, characterized in that: The instance generation method includes: Obtaining a message standard and parsing the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard; Traversing the message list, parsing to obtain a message structure of each message in the message list, wherein the message structure includes element rules of fields and logical relationships between fields; Generate test cases based on the relevant basic rules, and generate corresponding test data according to the test cases; Fill the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance.
2. The instance generation method according to claim 1, wherein: After the step of traversing the message list and parsing to obtain the message structure of the message list, the following steps are included: Identifying the signature element in the message structure; Obtaining signature information corresponding to the signature element from the message structure, wherein the signature information includes a signature field list, a signature algorithm, and a signature key; Based on the signature information, a signature method is called to encrypt the signature content corresponding to the signature element based on the called signature method.
3. The instance generation method according to claim 2, wherein: The step of filling the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance includes: Extracting signature elements from the test data; Digitally signing the signing elements based on the arrangement order of the signing elements in the message template using the signing method to obtain the signed content; A test instance is generated based on the message template corresponding to the signature content and the signature elements.
4. The instance generation method according to claim 1, wherein: The steps of generating a test case based on the relevant basic rules and generating corresponding test data according to the test case include: Based on the relevant basic rules, generating test cases in different scenarios, wherein the scenarios include normal scenarios, boundary scenarios, and abnormal scenarios; When the scenario is the normal scenario, generating test data that complies with the relevant basic rules for the test case corresponding to the normal scenario; When the scenario is the boundary scenario, determining the boundary conditions based on the relevant basic rules, and generating the test data that meets the boundary conditions for the test case corresponding to the boundary scenario; When the scenario is the abnormal scenario, the test data that does not comply with the relevant basic rules is generated for the test case corresponding to the abnormal scenario.
5. The instance generation method according to claim 3, wherein: The step of generating a test case based on the encrypted signature element includes: Sending the test case to a test platform, and receiving a test result returned by the test platform based on the test case; If the test result is that the decryption fails, the arrangement order of the signature elements in the message template is adjusted to obtain the adjusted message template; Encrypting the elements to be signed based on the adjusted arrangement order of the message templates, and generating a new test instance based on the encrypted signed elements; The new test case is sent to the test platform again until the test platform returns a test result indicating that the test has passed.
6. The instance generation method according to claim 3, wherein: After the step of filling the test data corresponding to each test case into the message template assembled based on the message structure to generate a test instance, the following steps are included: When the updated message standard is obtained, the message structure of the updated message standard is compared with that of the previous version of the message standard to obtain update information; Based on the update information, the message template is updated to obtain an updated target message template; Based on the target message template, the test instance corresponding to the message standard of the previous version is converted into a test instance adapted to the updated message standard.
7. An instance generation device, characterized in that: The device comprises: An acquisition module, configured to acquire a message standard and parse the message standard to obtain a message list and related basic rules, wherein the message list includes a set of all message types defined in the message standard; a parsing module, configured to traverse the message list and parse to obtain a message structure of each message in the message list, wherein the message structure includes element rules of fields and logical relationships between fields; A generation module, configured to generate test cases based on the relevant basic rules, and generate corresponding test data according to the test cases; A filling module is used to fill the test data corresponding to each test case into a message template assembled based on the message structure to generate a test instance.
8. An instance generation device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the example generation method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the example generation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, which implements the steps of the example generation method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Cited By
Test data generation method, electronic equipment and computer readable medium
CN121255660A