A method and device for quickly and automatically building system use cases based on mapping models
Automatically construct interface test cases by using a mapping model-based method, the problems of low generation efficiency and insufficient coverage of traditional interface test cases are solved, and efficient and standardized test case generation and maintenance are achieved.
Patent Information
- Application Number
- CN202411287646.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-14
AI Technical Summary
The generation of traditional interface test cases depends on manual writing, resulting in low generation efficiency, insufficient test coverage, lack of unified standards and specifications, and difficult to update and maintain.
Using a mapping model-based method, we can automatically build system use cases by determining the use case list, obtaining and sorting data, generating data mapping tables, and generating test cases based on this.
It significantly improves the generation efficiency of test cases, ensures that the test cases can fully cover various functional points and scenarios, and the generated use cases format is unified and the content is standardized, reducing manual intervention and error rates.
Smart Images

Figure CN118820116B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of interface testing technology, and in particular to a method and device for quickly and automatically constructing system use cases based on a mapping model. Background Art
[0002] Interface testing is a test of the interfaces between system components. Interface testing is mainly used to detect the interaction points between external systems and internal subsystems. The focus of the test is to check the data exchange, transmission and control management process, as well as the mutual logical dependencies between systems.
[0003] Interface testing is implemented through test cases. In traditional methods, the generation of test cases relies on manual writing, which is not only time-consuming but also easily limited by the personal experience and ability of test engineers. Manually written test cases are difficult to fully cover all possible test scenarios, resulting in insufficient test coverage and possible omission of important test points. Test cases written by different test engineers may be inconsistent in format and content, and lack unified standards and specifications. When requirements change, manually updating test cases is very cumbersome and error-prone, resulting in test cases being out of sync with actual requirements. When requirements change, manually updating test cases is very cumbersome and error-prone, resulting in test cases being out of sync with actual requirements. Summary of the invention
[0004] In order to at least to some extent overcome the problems of low generation efficiency, insufficient test coverage, lack of unified standards and specifications, and difficulty in updating and maintenance in use case testing in related technologies, the present application provides a method and device for quickly and automatically constructing system use cases based on a mapping model.
[0005] The scheme of this application is as follows:
[0006] According to a first aspect of an embodiment of the present application, a method for quickly and automatically building a system use case based on a mapping model is provided, comprising:
[0007] Determine the list of use cases required for testing;
[0008] Obtain data corresponding to each unit in the use case list, and sort them according to the execution order of each unit;
[0009] The sorted data is processed and stored in the data warehouse, and a tag ID of the data is generated;
[0010] Pair the cells in the use case list with the corresponding tag IDs by key value, and generate a data mapping table in the mapping model;
[0011] Generate test cases required for testing based on the data mapping table in the mapping model;
[0012] The use case list includes single test cases, test case sets and test case suites sorted in order of execution; the test case suite is composed of single test cases and / or test case sets sorted in combination.
[0013] Preferably, the method further comprises:
[0014] Take single test cases and test case collections as basic particles, combine, sort and encapsulate them through preset business logic to generate test case suites;
[0015] The test case suite has an input parameter set function, an output result set function and a specified business logic function.
[0016] Preferably, the sorted data is processed, including:
[0017] The sorted data is classified according to the use case type, data type and label type, and the classified data is input into the data processing channel of the corresponding type for data processing.
[0018] Preferably, the method further comprises:
[0019] Parse the processed data to obtain complete executable data;
[0020] The executable data is stored in a data warehouse.
[0021] Preferably, after generating the data mapping table in the mapping model, the method further comprises:
[0022] The data mapping tables are combined through a tree structure, and standardized JSON data is output, and the standardized JSON data is stored in a data warehouse.
[0023] Preferably, based on the data mapping table in the mapping model, a test case required for testing is generated, including:
[0024] The data mapping table is input into the reverse parser for parsing, and the obtained data structure is input into the concurrent device for tracing to obtain the tag ID;
[0025] Obtain the corresponding data in the data warehouse according to the tag ID;
[0026] Traverse the acquired data and assign corresponding parameters, inject the parameters into the use case synthesis code, and generate the use cases required for testing.
[0027] Preferably, the parameters are variables generated during data execution.
[0028] Preferably, the method further comprises:
[0029] Perform logic verification on the generated use cases to eliminate logical errors and redundant steps.
[0030] Preferably, the method further comprises:
[0031] Integrate the generated test cases into the automated testing platform framework to perform automated testing.
[0032] According to a second aspect of an embodiment of the present application, there is provided a device for quickly and automatically building a system use case based on a mapping model, comprising:
[0033] Processor and memory;
[0034] The processor and the memory are connected via a communication bus:
[0035] Wherein, the processor is used to call and execute the program stored in the memory;
[0036] The memory is used to store a program, and the program is used to execute at least a method for quickly and automatically constructing a system use case based on a mapping model as described in any one of the above items.
[0037] The technical solution provided by this application may have the following beneficial effects:
[0038] The method for quickly and automatically building system use cases based on a mapping model in the present application includes: determining a list of use cases required for testing; obtaining data corresponding to each unit in the use case list, and sorting the data according to the execution order of each unit; storing the sorted data in a data warehouse after processing, and generating a data tag ID; pairing the units in the use case list with the corresponding tag IDs by key value, and generating a data mapping table in the mapping model; generating use cases required for testing based on the data mapping table in the mapping model; wherein the use case list includes single test cases, test case sets, and test case suites sorted according to the execution order; and the test case suite is composed of a single test case and / or a test case set that are combined and sorted.
[0039] In this technical solution, when test cases need to be generated, key information (data mapping table) is extracted from the mapping model to automatically construct test cases, which significantly improves the efficiency of test case generation. Using the mapping model, test points are systematically identified and associated to ensure that test cases can fully cover various functional points and scenarios. By using a unified mapping model and automation tools, test cases with unified format and standardized content can be generated. When business logic changes, the mapping model can respond quickly and automatically update all associated test cases, reducing manual intervention and lowering the error rate.
[0040] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. 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] Figure 1 It is a flowchart of a method for quickly and automatically building a system use case based on a mapping model provided by an embodiment of the present application;
[0043] Figure 2 It is a flowchart of another method for quickly and automatically building a system use case based on a mapping model provided by an embodiment of the present application;
[0044] Figure 3 It is a structural diagram of a device for quickly and automatically building system use cases based on a mapping model, provided by an embodiment of the present application.
[0045] Reference numerals: processor-21; memory-22. DETAILED DESCRIPTION
[0046] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0047] Embodiment 1
[0048] Figure 1 This is a flowchart of a method for quickly and automatically building a system use case based on a mapping model provided by an embodiment of the present application. Figure 1 , a method for quickly and automatically building system use cases based on a mapping model, comprising:
[0049] S11: Determine the list of use cases required for testing;
[0050] The test case list includes single test cases, test case sets and test case suites sorted in order of execution; a test case suite is composed of single test cases and / or test case sets in a combined and sorted order.
[0051] It should be noted that when implementing this technical solution, it is necessary to first take single test cases and test case sets as basic particles, combine, sort and encapsulate them through preset business logic to generate a test case suite; the test case suite has an input parameter set function, an output result set function and a specified business logic function.
[0052] The test case collection is a complete functional case collection that has been added before. It is a functional case collection formed by sorting individual test cases according to business function logic and stored in the case pool for use.
[0053] Use cases (such as a single interface case) and test case sets (such as a case with certain business functions composed of multiple interface cases) as basic particles, and combine and sort them through certain business logic to form an indivisible new functional case unit. Then encapsulate the functional case unit to get a test case suite. The test case suite is a basic case unit with input parameter set and output result set functions, and has specific business logic functions (such as login function unit, dispatch function unit, driver registration function unit, etc.). The test case suite is an indivisible unit with specific business logic functions.
[0054] S12: Obtain data corresponding to each unit in the use case list, and sort them according to the execution order of each unit;
[0055] The sorting here refers to the order of use case execution, which can also be understood as a serial number. Its function is to perform sequential execution and sequential data extraction according to the sorting (which can also be understood as a serial number) when executing automated use cases later, so that the business logic can be carried out according to a fixed business process.
[0056] S13: Process the sorted data and store them in the data warehouse, generating a tag ID for the data;
[0057] The sorted data is processed, including:
[0058] The sorted data is classified according to the use case type, data type and label type, and the classified data is input into the data processing channel of the corresponding type for data processing.
[0059] The sorted data is input into the classifier, which stores the data according to the use case type (such as suite, use case set, single interface use case), data type (such as request parameter, pre-function, post-function, verification method, global variable, local variable, pre-SQL, post-SQL, public configuration, functional method, etc.), and tag type (classified according to use case tags, such as test environment use case, pre-release environment use case, online environment use case, order placement failure use case, etc.) so that it can be called later according to testing needs.
[0060] The classified data is input into the data processing channel of the corresponding type for data processing. For example, according to the data type classification, the pre- and post-functions are sent to the function processing channel for processing. The processing includes obtaining the corresponding variables from the global variable pool according to the mapping ID and replacing the global variables in the function, obtaining the public methods from the public method pool according to the mapping ID and replacing the public methods, etc.
[0061] It should be noted that the method also includes:
[0062] Parse the processed data to obtain complete executable data;
[0063] Store executable data in the data warehouse.
[0064] After parsing, complete executable data is obtained. For example, if the preceding function contains global variables, the global variables will be replaced with the actual corresponding values after parsing, and can be used directly in subsequent calls. Before parsing, the data includes various reference codes, which cannot be executed directly and need to be parsed to form complete data.
[0065] It should be noted that there are multiple ways to generate tag IDs. For example, the tag ID of data can be assigned through an ID automatically generated by the mongo database, which is a unique ID. The unique ID can also be defined through UUID.
[0066] The parsed data is stored in the cache and data warehouse according to the purpose of the data, and the cache and data warehouse will return the tag ID.
[0067] S14: pairing the units in the use case list with the corresponding tag IDs by key value, and generating a data mapping table in the mapping model;
[0068] Storage mapping is performed through key-value pairing. For example, the key is the use case name and the value is the tag ID of the use case. Then the data of the use case can be obtained from the data warehouse through the tag ID. The use case data in the data warehouse is marked by ID. Other data is also marked in this way, such as the prefix function, post-function, prefix SQL, etc. of the use case.
[0069] After generating the data mapping table in the mapping model, the method further includes:
[0070] The data mapping tables are combined through a tree structure, and standardized JSON data is output, and the standardized JSON data is stored in the data warehouse.
[0071] The tree result refers to a tree structure. For example, a suite is divided into multiple use case sets, multiple interface use cases, and multiple other suites. The use case sets are further divided into multiple interface use cases and multiple suites. The suites repeat this process layer by layer, like a tree. The last layer is the data type (such as variables, functions, parameters, etc.).
[0072] S15: Generate test cases required for testing based on the data mapping table in the mapping model;
[0073] After the above steps, the correspondence of the data mapping table in the mapping model includes the correspondence between suites and suite data, through the tag ID correspondence, the use case set and the use case set data correspondence, the use case and the use case data correspondence, the function and the function structure data correspondence, etc. The response analysis is through the reverse correspondence (which can be understood as the decoding of the password table), the corresponding component data is found through the tag ID, and combined according to the corresponding logic.
[0074] Specifically, based on the data mapping table in the mapping model, the test cases required for testing are generated, including:
[0075] Input the data mapping table into the reverse parser for parsing, and input the obtained data structure into the concurrent device for tracing to obtain the tag ID;
[0076] Obtain the corresponding data in the data warehouse according to the tag ID;
[0077] Traverse the acquired data and assign corresponding parameters, inject the parameters into the use case synthesis code, and generate the use cases required for testing.
[0078] It should be noted that the acquired data is traversed because the acquired data is original data rather than metadata. The original data may also contain dynamic parameters (such as global variables or suite methods of tag IDs, etc.), and the acquired data needs to be mapped through traversal.
[0079] The method of configuring global / local variables in functions of some original data (data in the data warehouse) will generate global variables / local variables during the dynamic execution process. The variables generated during the execution of this original data may be used in subsequent use cases, so the generated variables of the original data will be passed into the use cases of the subsequent execution as parameters.
[0080] It should be noted that, refer to Figure 2 , the method further comprises:
[0081] S16: Perform logic verification on the generated use cases to eliminate logical errors and redundant steps.
[0082] The existing use case testing methods still have the problem of test resource dispersion and loss. The existing tests are performed by division of labor, and business knowledge is isolated between each business, resulting in the inability to concentrate test resources and repeated construction of test resources and test processes, which greatly wastes test resources.
[0083] In this embodiment, by performing logic verification on the generated test cases, logical errors and redundant steps are eliminated, the logic of the generated test cases is ensured to be rigorous, thereby improving the accuracy and reliability of the test.
[0084] It should be noted that, refer to Figure 2 , the method further comprises:
[0085] S17: Integrate the generated use cases into the automated testing platform framework and perform automated testing.
[0086] There are still test automation integration problems in the existing use case testing methods, which are difficult to integrate seamlessly with the automated testing framework, limiting the implementation and effectiveness of test automation.
[0087] As well as the problem of cross-business learning costs, the existing businesses are relatively large and independent, and the single-soldier combat mode cannot adapt well to the current huge business system. The work mode of being proficient in local module business has become the work theme of various enterprises or units. This will lead to a large amount of additional learning costs when testing cross-business applications.
[0088] The test cases generated in this embodiment can be directly applied to automated testing to achieve automated execution of the test and result collection.
[0089] The overall technical solution in this embodiment can adapt to the software development environment of agile development and continuous integration, and quickly respond to changes in business logic.
[0090] It can be understood that a method for quickly and automatically building system use cases based on a mapping model is provided in this embodiment, including: determining a list of use cases required for testing; obtaining data corresponding to each unit in the use case list, and sorting them according to the execution order of each unit; processing the sorted data and storing it in a data warehouse to generate a tag ID for the data; pairing the units in the use case list with the corresponding tag IDs by key value, and generating a data mapping table in the mapping model; based on the data mapping table in the mapping model, generating the use cases required for testing; wherein the use case list includes a single test case, a test case set, and a test case suite sorted in the execution order; the test case suite is composed of a single test case, and / or a test case set that is sorted in combination. In this technical solution, when it is necessary to generate a test case, key information (data mapping table) is extracted from the mapping model, and the test case is automatically constructed, which significantly improves the efficiency of test case generation. Using the mapping model, test points are systematically identified and associated to ensure that the test cases can fully cover various functional points and scenarios. Using a unified mapping model and automation tools, test cases with unified format and standardized content can be generated. When the business logic changes, the mapping model can respond quickly and automatically update all associated test cases, reducing manual intervention and lowering the error rate.
[0091] Embodiment 2
[0092] Figure 3 This is a schematic diagram of a device for quickly and automatically building a system use case based on a mapping model provided by an embodiment of the present application, referring to Figure 3 , a device for quickly and automatically building system use cases based on a mapping model, comprising:
[0093] Processor 21 and memory 22;
[0094] The processor 21 and the memory 22 are connected via a communication bus:
[0095] The processor 21 is used to call and execute the program stored in the memory 22;
[0096] The memory 22 is used to store a program, and the program is used to execute at least one method of quickly and automatically building a system use case based on a mapping model in the above embodiment.
[0097] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0098] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0099] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0100] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0101] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0102] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0103] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0104] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0105] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for quickly and automatically building system use cases based on a mapping model, characterized in that: include: Determine the list of use cases required for testing; Obtain data corresponding to each unit in the use case list, and sort them according to the execution order of each unit; The sorted data is processed and stored in the data warehouse, and a tag ID of the data is generated; Pair the cells in the use case list with the corresponding tag IDs by key value, and generate a data mapping table in the mapping model; Generate test cases required for testing based on the data mapping table in the mapping model; Take single test cases and test case collections as basic particles, combine, sort and encapsulate them through preset business logic to generate test case suites; The test case suite has an input parameter set function, an output result set function and a specified business logic function; The test case list includes single test cases, test case sets and test case suites sorted in order of execution; The test case suite is composed of a single test case and / or a test case set that is combined and sorted; The mapping model is used to systematically identify and associate test points so that the test cases comprehensively cover various functional points and scenarios; The mapping model automatically updates all associated test cases when the business logic changes.
2. The method according to claim 1, characterized in that The sorted data is processed, including: The sorted data is classified according to the use case type, data type and label type, and the classified data is input into the data processing channel of the corresponding type for data processing.
3. The method according to claim 1, characterized in that The method further comprises: Parse the processed data to obtain complete executable data; The executable data is stored in a data warehouse.
4. The method according to claim 1, characterized in that: After generating the data mapping table in the mapping model, the method further includes: The data mapping tables are combined through a tree structure, and standardized JSON data is output, and the standardized JSON data is stored in a data warehouse.
5. The method according to claim 1, characterized in that Generate test cases required for testing based on the data mapping table in the mapping model, including: The data mapping table is input into the reverse parser for parsing, and the obtained data structure is input into the concurrent device for tracing to obtain the tag ID; Obtain the corresponding data in the data warehouse according to the tag ID; Traverse the acquired data and assign corresponding parameters, inject the parameters into the use case synthesis code, and generate the use cases required for testing.
6. The method according to claim 5, characterized in that The parameters are variables generated during the data execution process.
7. The method according to claim 1, characterized in that The method further comprises: Perform logic verification on the generated use cases to eliminate logical errors and redundant steps.
8. The method according to claim 1, characterized in that The method further comprises: Integrate the generated test cases into the automated testing platform framework to perform automated testing.
9. A device for quickly and automatically building system use cases based on a mapping model, characterized in that: include: Processor and memory; The processor and the memory are connected via a communication bus: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store a program, and the program is used at least to execute a method for quickly and automatically constructing a system use case based on a mapping model as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Automated test case management method, apparatus and device, and storage medium
CN108268373A
Data storage method, access method, device and equipment based on tree structure
CN111475511A