Test case data preparation method and apparatus
By establishing a public function list and using text recognition technology, the problems of scattered test data preparation and reuse were solved, enabling the reuse of cross-team resources and improving testing efficiency.
Patent Information
- Application Number
- CN202210956255.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-10
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-08-10
AI Technical Summary
In existing technologies, test data preparation mainly relies on manual operations. Automated test scripts are scattered and cannot be managed in a unified manner, which makes data preparation difficult and unusable, affecting test efficiency.
By establishing a list of public functions and standardizing function specifications, using text recognition technology to identify user-inputted data preparation text, matching public functions and generating test data, supporting caching and real-time invocation, and providing a test data preparation platform.
It lowers the barrier to data preparation, improves testing efficiency, enables resource reuse across and within teams, and simplifies the data preparation process for both manual and automated testing.
Smart Images

Figure CN115237805B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of test case technology, and more particularly to a test case data preparation method and apparatus. Background Technology
[0002] Test data is the data required during the execution of test cases. Test data preparation is a prerequisite for testing tools, ensuring coverage of business conditions and fulfilling business requirements. Data preparation is a crucial prerequisite in software testing. Currently, data preparation during testing is primarily done manually, such as inserting data into the test environment's database or calling transaction programs used for data preparation.
[0003] Testers need to be very familiar with the data preparation process, but the reliance on external application data during testing makes data generation difficult. Besides manual data generation, automated test scripts are increasingly capable of generating data, meeting more data preparation requirements for both manual and automated testing. However, automated data generation scripts lack unified management, are distributed across different departments and applications, and cannot be effectively reused. Summary of the Invention
[0004] In view of the problems existing in the prior art, the main objective of the present invention is to provide a test case data preparation method and apparatus, thereby reducing the threshold for data preparation and improving testing efficiency.
[0005] To achieve the above objectives, embodiments of the present invention provide a method for preparing test case data, the method comprising:
[0006] The system acquires the user-inputted data preparation text, performs recognition on the data preparation text, and obtains the text recognition result; the text recognition result includes function parameter information.
[0007] Based on the text recognition results, a matching process is performed in a pre-established list of public functions to determine the public function corresponding to the text recognition results;
[0008] Test data is generated based on the function parameter information in the text recognition results and the common functions corresponding to the text recognition results.
[0009] Optionally, in one embodiment of the present invention, the text for data preparation is recognized to obtain the text recognition result, including:
[0010] Using a pre-defined word dictionary, the prepared text is segmented and parsed to obtain the text recognition result.
[0011] Optionally, in one embodiment of the present invention, the prepared text is segmented and parsed using a preset word dictionary to obtain text recognition results, including:
[0012] Using a pre-defined word dictionary, the data preparation text is segmented to obtain multiple data preparation vocabularies;
[0013] The vocabulary in the data preparation is processed by text parsing to obtain the text recognition results.
[0014] Optionally, in one embodiment of the present invention, generating test data based on the function parameter information in the text recognition result and the common function corresponding to the text recognition result includes:
[0015] The common functions corresponding to the text recognition results are packaged to obtain the number generation functions corresponding to the text recognition results;
[0016] The test data is generated based on the execution environment information and input parameter information in the data generation function and function parameter information.
[0017] Optionally, in one embodiment of the present invention, based on the text recognition result, matching is performed in a pre-established list of public functions to determine the public function corresponding to the text recognition result, including:
[0018] By using the class name and function name in the text recognition results, a search and matching process is performed in a pre-established list of public functions to determine the public function corresponding to the text recognition results.
[0019] Optionally, in one embodiment of the present invention, the list of public functions is established in the following manner:
[0020] Obtain historical common basic functions and summarize them using preset construction standards;
[0021] The historical common basic functions that have been summarized are processed for function conflict resolution and comment information parsing to obtain a list of common functions.
[0022] Optionally, in one embodiment of the present invention, obtaining historical common basic functions and summarizing them using preset construction standards includes:
[0023] Obtain historical common basic functions from multiple test case projects;
[0024] Using the script directory in the preset construction standards, historical common basic functions are stored in the script directory;
[0025] By using the preset class names and function names in the preset construction standards, the names of historical common basic functions are processed to complete the function summary.
[0026] This invention also provides a test case data preparation device, the device comprising:
[0027] The text recognition module is used to acquire the data preparation text input by the user, and to recognize the data preparation text to obtain the text recognition result; wherein, the text recognition result includes function parameter information;
[0028] The public function module is used to match the text recognition results with a pre-established list of public functions to determine the public function corresponding to the text recognition results.
[0029] The test data module is used to generate test data based on the function parameter information in the text recognition results and the common functions corresponding to the text recognition results.
[0030] Optionally, in one embodiment of the present invention, the text recognition module is further configured to: segment and parse the data preparation text using a preset word dictionary to obtain the text recognition result.
[0031] Optionally, in one embodiment of the present invention, the text recognition module includes:
[0032] The text segmentation unit is used to segment the data preparation text using a pre-set word dictionary to obtain multiple data preparation vocabularies;
[0033] The text recognition unit is used to perform text parsing on the vocabulary in the data preparation to obtain the text recognition results.
[0034] Optionally, in one embodiment of the present invention, the test data module includes:
[0035] The number generation function unit is used to package the common functions corresponding to the text recognition results to obtain the number generation function corresponding to the text recognition results;
[0036] The test data unit is used to generate test data based on the execution environment information and input parameter information in the number generation function and function parameter information.
[0037] Optionally, in one embodiment of the present invention, the public function module is further configured to: use the class name and function name in the text recognition result to search and match in a pre-established public function list to determine the public function corresponding to the text recognition result.
[0038] Optionally, in one embodiment of the present invention, the device further includes: a function list module, used to obtain historical common basic functions, and to summarize the historical common basic functions using preset construction standards; and to perform function conflict handling and annotation information parsing processing on the historical common basic functions that have been summarized to obtain the common function list.
[0039] Optionally, in one embodiment of the present invention, the function list module includes:
[0040] The basic function unit is used to retrieve historical common basic functions from multiple test case projects;
[0041] The script directory unit is used to store historical common basic functions in the script directory according to the preset construction standard;
[0042] The function summary unit is used to process the names of historical common basic functions by using the preset class names and function names in the preset construction standards, so as to complete the function summary.
[0043] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described method.
[0044] The present invention also provides a computer-readable storage medium storing a computer program for performing the above-described methods.
[0045] The present invention also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the above-described method.
[0046] This invention standardizes functions by constructing a list of common functions, preventing redundant construction of common functions. It also flexibly adapts data generation scripts by recognizing input text, reducing and simplifying the data preparation process for both manual and automated testing, lowering the threshold for data preparation, and improving testing efficiency. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 A flowchart illustrating a test case data preparation method according to an embodiment of the present invention;
[0049] Figure 2 This is a flowchart illustrating the text recognition results obtained in an embodiment of the present invention;
[0050] Figure 3 This is a flowchart illustrating the generation of test data in an embodiment of the present invention;
[0051] Figure 4 This is a flowchart illustrating the process of establishing a list of common functions in an embodiment of the present invention;
[0052] Figure 5 This is a flowchart summarizing the functions in an embodiment of the present invention;
[0053] Figure 6 This is a schematic diagram of a test case data preparation device according to an embodiment of the present invention;
[0054] Figure 7 This is a schematic diagram of the text recognition module in an embodiment of the present invention;
[0055] Figure 8 This is a schematic diagram of the test data module in an embodiment of the present invention;
[0056] Figure 9 This is a schematic diagram of the test case data preparation device in another embodiment of the present invention;
[0057] Figure 10 This is a schematic diagram of the function list module in an embodiment of the present invention;
[0058] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0059] This invention provides a test case data preparation method and apparatus, which can be used in the financial field and other fields. It should be noted that the test case data preparation method and apparatus of this invention can be used in the financial field, or in any field other than the financial field. The application field of the test case data preparation method and apparatus of this invention is not limited.
[0060] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0061] like Figure 1 The diagram shows a flowchart of a test case data preparation method according to an embodiment of the present invention. The execution subject of the test case data preparation method provided in this embodiment includes, but is not limited to, a computer. This invention standardizes functions by constructing a list of common functions, preventing redundant construction of common functions. It flexibly adapts the data generation script through input text recognition, reducing and simplifying the data preparation process for both manual and automated testing, lowering the threshold for data preparation, and improving testing efficiency. Figure 1 The methods shown include:
[0062] Step S1: Obtain the data preparation text input by the user, and recognize the data preparation text to obtain the text recognition result; wherein, the text recognition result includes function parameter information.
[0063] The user-input data preparation text records the user's basic requirements for test data, such as the test environment and function names. By analyzing this user-input data preparation text, word segmentation is performed, and the appropriate functions are called to prepare the data. Specifically, the input data preparation text is segmented into sentences using commas or verb-object structures, with each verb-object sentence being a short sentence. Word segmentation is then performed to obtain multiple data preparation terms. Conventional text parsing methods are used to parse these terms, resulting in text recognition results. For example, recognized data preparation terms might include "open a public account" or "open," thus enabling the recognition of the data preparation file.
[0064] As an embodiment of the present invention, the text recognition result also includes class name and function name.
[0065] Furthermore, the text input by the user is segmented and parsed to obtain text recognition results. Specifically, the text recognition results include function parameter information, that is, the input parameter information of the function required for the test data. In addition, the text recognition results also include class names and function names.
[0066] Step S2: Based on the text recognition results, match them in a pre-established list of public functions to determine the public function corresponding to the text recognition results.
[0067] The list of public functions is pre-established. Specifically, it utilizes historical public base functions from test cases and maintains public functions according to pre-defined public function library construction standards. During maintenance, the following specific requirements apply: public functions must be placed in the agreed-upon package directory; class names must begin with the letter "C," followed by a Chinese noun; function names should use Chinese characters, preferably verbs or verb-object structures; and functions should include function comments. This process handles function conflict resolution and comment information parsing, resulting in the public function list. It also establishes a good directory structure for the test case functions and significantly prevents conflicts caused by using identical package and class names in different applications when packaging and summarizing public functions later.
[0068] Furthermore, by utilizing the class names and function names included in the text recognition results, a search and matching process is performed in the list of public functions to determine the public functions corresponding to the text recognition results. Specifically, the text recognition results may include multiple function names, thereby allowing the retrieval of multiple public functions corresponding to the text recognition results.
[0069] Step S3: Generate test data based on the function parameter information in the text recognition results and the common function corresponding to the text recognition results.
[0070] wherein the common functions corresponding to the text recognition result are packaged to obtain a data generation function corresponding to the text recognition result. Specifically, a plurality of common functions corresponding to the text recognition result are combined and packaged, so that a new function, namely a data generation function for generating test data, can be obtained.
[0071] As an embodiment of the present invention, the function parameter information includes execution environment information and input parameter information.
[0072] Further, test data is generated according to the execution environment information, the input parameter information and the data generation function in the text recognition result. Specifically, the data generation function is configured and run by using the execution environment information and the input parameter information, so as to generate test data.
[0073] As an embodiment of the present invention, performing recognition on the data preparation text to obtain a text recognition result includes: performing word segmentation and parsing on the data preparation text by using a preset word dictionary library to obtain the text recognition result.
[0074] In this embodiment, as Figure 2 shown, performing word segmentation and parsing on the data preparation text by using a preset word dictionary library to obtain a text recognition result includes:
[0075] Step S21, performing word segmentation on the data preparation text by using the preset word dictionary library to obtain a plurality of data preparation words;
[0076] Step S22, performing text parsing processing on the data preparation words to obtain the text recognition result.
[0077] wherein a specific process of presetting the word dictionary library includes: importing commonly used Chinese word libraries such as verbs, nouns, and conjunctions; performing statistics and word segmentation on method names and parameters of the data generation function, where the word segmentation adopts a forward maximum matching method, and words with the maximum length at the current position are segmented from left to right of the text in a greedy algorithm manner. The function name is a verb-object structure phrase, the object is a noun, and the noun may be modified by a conditional adjective, such as "open a corporate current account", where "open" is a verb, "current account" is a noun, and "corporate" is an adjective modifying the object, and there may be multiple such adjectives.
[0078] Further, the words obtained after performing word segmentation on the data preparation text are recorded in the dictionary library for matching with the text input by the user, so that the parsing of the data preparation text is implemented to obtain the text recognition result.
[0079] In this embodiment, as Figure 3 shown, generating test data according to the function parameter information in the text recognition result and the common function corresponding to the text recognition result includes:
[0080] Step S31: Package the common functions corresponding to the text recognition results to obtain the number generation functions corresponding to the text recognition results;
[0081] Step S32: Generate test data based on the execution environment information and input parameter information in the number generation function and function parameter information.
[0082] Specifically, the common functions corresponding to the text recognition results are packaged to obtain the data generation function corresponding to the text recognition results. In other words, multiple common functions corresponding to the text recognition results are combined and packaged to obtain a new function, namely the data generation function used to generate test data.
[0083] As an embodiment of the present invention, the method of matching the text recognition result in a pre-established list of public functions to determine the public function corresponding to the text recognition result includes: using the class name and function name in the text recognition result to search and match in the pre-established list of public functions to determine the public function corresponding to the text recognition result.
[0084] Specifically, the text recognition results, including class names and function names, are used to search and match within a list of public functions to identify the public functions corresponding to the text recognition results. In particular, the text recognition results may include multiple function names, allowing for the retrieval of multiple public functions corresponding to those results.
[0085] As an embodiment of the present invention, such as Figure 4 As shown, the list of public functions is constructed in the following way:
[0086] Step S41: Obtain historical common basic functions and summarize the historical common basic functions using preset construction standards;
[0087] Step S42: Perform function conflict resolution and comment information parsing on the historical common basic functions that have been summarized to obtain a list of common functions.
[0088] In this embodiment, as Figure 5 As shown, the process involves retrieving historical common basic functions and summarizing them using preset construction standards, including:
[0089] Step S51: Obtain historical common basic functions from multiple test case projects;
[0090] Step S52: Using the script directory in the preset construction standards, store the historical common basic functions in the script directory;
[0091] Step S53: Using the preset class names and function names in the preset construction standards, the names of historical common basic functions are processed to complete the function summary.
[0092] The public function list is pre-built. Specifically, historical common basic functions are obtained from multiple test case projects. These historical common basic functions are then used to maintain the public functions according to the pre-defined public function library construction standards. During maintenance, the following specific requirements apply: public functions must be placed in the agreed-upon package directory; class names must begin with the letter "C," followed by a Chinese noun; function names should use Chinese characters, preferably verbs or verb-object structures; and functions should include function comments. This process completes function conflict resolution and comment information parsing, resulting in the public function list. It also establishes a good directory structure for the test case functions and largely prevents conflicts caused by using identical package and class names in different applications when packaging and summarizing public functions.
[0093] In a specific embodiment of the present invention, this embodiment also provides a system for preparing test case data. Specifically, the system is applied in the form of a test data supply platform. This platform can generate basic test data through a webpage or API, and supports real-time access and use of cached data, which greatly reduces the threshold for data preparation and improves testing efficiency. It reuses existing test case resources within and across teams, improving the efficiency of test case writing, enhancing test case data preparation capabilities, and providing a common foundation for writing scenario cases and cross-application cases. By searching a public test case library, it generates an operation interface and independently executable scripts based on the library information. The generated scripts serve as data preparation scripts for both manual and automated testing. It also supports two methods of obtaining data: directly reading from the cached database or real-time access.
[0094] In this embodiment, existing test case resources are reused within the project team and across teams to improve the efficiency of automated test case development, enhance test case data preparation capabilities, and provide common foundation functions for writing scenario-based and cross-application test cases. Based on the consensus reached, a common function library construction standard is jointly formulated, and each team maintains the common functions for its respective business domain within its test case projects. The following specific requirements apply to maintenance:
[0095] (1) Public functions must be placed in the agreed package directory. Specifically, the directory is divided according to business product line: common->fova / nova->business line->business system->public functions. Among them, the common name is a necessary condition.
[0096] (2) The class name begins with the letter C, followed by a Chinese noun.
[0097] (3) Function names should be in Chinese, preferably in the form of verbs or verb-object structures, and functions should include function comments.
[0098] Furthermore, through the above process of sharing common functions, a good directory structure can be established for the functions in the case study. At the same time, it can greatly prevent conflicts caused by different applications using the same package name and class name when packaging and summarizing common functions later.
[0099] In this embodiment, the common functions have been shared by various departments in the project directory, such as the COMMON directory. The batch program in this solution automatically generates JAR packages and Javadoc documentation on a regular schedule, including the following operations:
[0100] (1) Download resources: Download case projects from the case library of each project department, download all source code from the specified directory of each case project, such as the SRC / COMMON directory (where the public function package is located), download public functions and their dependent files, download dependent third-party packages (such as some third-party basic JAR package libraries required by the public function to run), and the basic classes required by the public function.
[0101] (2) Pre-compilation: Pre-compile the common function classes of each case project:
[0102] A. If there are compilation errors, the project with the error will not be updated that night, and the relevant person in charge will be notified.
[0103] B. If the compilation succeeds, the source code and dependent packages of the project will be compiled into the project, such as the MTCOMMON project.
[0104] (3) Conflict Handling: The package directory structure specified above can prevent most conflicts between public functions with the same package name and class name during aggregation. However, because the package paths and class names of dependent classes cannot be predicted, conflicts may still occur, such as two public functions depending on different versions of the third package. In this case, it is necessary to determine the version numbers of the two versions and select the class with the higher version number. The specific handling process is as follows:
[0105] A. Handling Package Conflicts: Loop through all the dependency packages for all test cases and record the correspondence between test project and dependency package. Calculate the MD5 hash of each dependency package using the MD5 message digest algorithm (MD5 can distinguish whether files are actually the same file) and add the package to a temporary directory. If a package with the same MD5 hash is already found in the temporary directory, do not add it. If the filenames are the same but the MD5 hashes are different, it proves that the two files are not the same file; keep the file with the more recent modification time, and email the application's contact person to investigate the problem. If the package name exists but the version is inconsistent, keep the higher version package.
[0106] B. Handling Class Conflicts: The above steps deduplicate dependency packages for all projects and centrally store them in a temporary directory. However, different packages may still contain duplicate package names (paths) and class names, potentially leading to incorrect class references in test cases. For multiple packages with the same package name (path) and class name, retrieve the package to which the class belongs and sort them by time from earliest to latest. Compile test projects that depend on these packages.
[0107] For example, consider two case projects, CASEPROJECT1 and CASEPROJECT2. Both CASEPROJECT1 and CASEPROJECT2 depend on the same package name (path) COM.COMPANY.PATH and class name APPOINTCLASS. APPOINTCLASS might have two different implementations in DEPEND1.JAR and DEPEND2.JAR. In this case, the dependency order is adjusted according to the last update of DEPEND1.JAR and DEPEND2.JAR, prioritizing the earlier updated package. DEPEND1.JAR is placed first. When compiling CASEPROJECT1 and CASEPROJECT2, both projects will preferentially use DEPEND1.JAR. If both compile successfully, it means DEPEND1.JAR is suitable for both projects, and the dependency order of DEPEND1.JAR is ultimately placed next to DEPEND2.JAR. If DEPEND1.JAR fails to compile both projects, the dependency order of DEPEND2.JAR is moved to the front to test if both projects compile successfully. If so, DEPEND1.JAR is placed in the final dependency order next to DEPEND2.JAR. If neither dependency package fails to compile all projects, the earlier dependency package is retained, and the later package is considered a conflicting package. The relevant applications are notified via email to resolve the issue. The conflicting package DEPEND2.JAR and the example project are removed from the temporary directory.
[0108] (4) Package and add source code control for release: For the final case projects without compilation errors, package mtcommon.jar uniformly, package the classes extracted from third-party dependencies into commons-pool.jar and release it to the DES project (the dependency projects that the test case projects need to import), and submit the DES project to the Git source code management platform. Since the public functions all have JAVADOC, the JAVADOC will be automatically extracted and generated into online documentation.
[0109] (5) Scheduled build: The above packaging pipeline is encapsulated into a callable program, and batch tasks are executed daily through JENKINS (configuration and scheduling tasks) to complete the extraction, packaging and release of common functions.
[0110] The specific process of using the announcement package includes: before using the public functions, you need to import the DES case dependency project that contains the MTCOMMON.JAR package of public functions.
[0111] Furthermore, when using public function methods, they are called using "ClassName.MethodName(parameters)".
[0112] Furthermore, the encapsulation process includes: since the source code of other applications can be viewed when using a common package, new common functions can be written based on combinations of common functions. For example, during data preparation, multiple functions may need to be called sequentially, with the output of the previous function serving as the input of the next function, allowing for flexible assembly into the required functions.
[0113] By sharing standardized public functions and generating public packages, conflicts arising from the aggregation of public functions can be resolved. Different users can then use public functions provided by other departments and applications by importing the public package.
[0114] In this embodiment, when using public functions, only Java projects can directly import and use the public package in the test case project. Furthermore, due to the large amount of public function data, users often struggle to find the specific data they need. To address these issues, the following describes the process of building a dependency-free test data platform, making it easier for ordinary users to prepare test data.
[0115] The first step is to generate a list of public functions. This list (in a JSON file) shows how each function is called. A user-friendly interface is then provided to generate the call logic and produce test data.
[0116] Furthermore, the detailed comments of each method in all classes are preprocessed. Methods without comments, deprecated methods with the `deprecated` tag, non-public methods, and non-static methods are filtered out. For other methods that meet the requirements, the comment information is extracted and parsed based on regular expression matching. Specifically, the following processing is performed:
[0117] 1) Create a method information object to record method information;
[0118] 2) Set the method name (Name), class name (ClassName), and method description (Description) for the method object;
[0119] 3) Obtain keyword information. If no keyword information is available, use the method name as the keyword (the keyword is used to search for functions);
[0120] 4) Obtain the author information and the method's return value;
[0121] 5) Obtain the parameter information of the method, including the parameter name, parameter type, parameter number, and parameter description for each parameter;
[0122] 6) Add all information and parameter details to the list;
[0123] 7) Sort the method list according to the keyword information and write it to a JSON file.
[0124] In this embodiment, once the JSON function list is available, it becomes clear how these common functions are called. By combining the mtCommon.jar package and its dependencies, test data preparation is achieved.
[0125] To facilitate user access, this invention provides a platform interface for searching available public function scripts. Usage is as follows: search criteria include environment, application, class name, and method name. The search criteria are explained below:
[0126] Environment: The environment in which the script is executed; the solution will automatically convert it to the corresponding IP and port in the background.
[0127] Application: The application to which the script belongs;
[0128] Class name: The class name corresponding to the script.
[0129] Method: The name of the method corresponding to the script.
[0130] The input includes class names and other conditional information, and the output is a list of classes. To help users find the classes they want, three sorting methods are provided in the configuration: the first is the default alphabetical sorting, the second is the overall usage frequency sorting, and the third is the number of times the current application project and class name match.
[0131] Furthermore, the input items for the query are class name and method. The interface is generated by parsing a JSON file, looping through the JSON's method list to read the method name, description, package path, type name, parameters, and other information, and converting it into a Java object. This lists the methods in the class, or you can directly search for the method name to match methods. After selecting a method, the Java object parses and generates detailed method information on the interface.
[0132] Furthermore, after selecting a method, click "Add Method" on the operation page. This will display method information, including parameter information, and generate the corresponding input interface. Enter the specific values of the parameters and click "Execute Method" on the page.
[0133] Furthermore, after execution, the corresponding results will be generated and can be used as test data. At the same time, this data will be stored in the background cache database with (method and + parameter) as the identifier, and will be read directly from the cache database when used.
[0134] In this embodiment, to enable the data generation process to be used multiple times on different platforms, the process is encapsulated into a URL address. The generation rule is to concatenate the platform server address and a request JSON string. The JSON string includes the environment, package name, class name, method name, parameter information, and cache duration. Different platforms can repeat this data generation process by accessing the URL address (which requires access to the data platform server's IP address and port 80). The specific process is as follows:
[0135] 1) Select environmental information;
[0136] 2) Enter the parameter input information;
[0137] 3) Click to generate the interface URL;
[0138] 4) Interface display.
[0139] The process involves generating data through page operations, which is then stored in a database cache. If the same environment and method parameters are used again, the cached data is read directly, eliminating the need to call the underlying real transaction and speeding up data generation. The cache period is set to 30 days; if cached data is available within 30 days (with the same environment and method parameters), the cached data will be used directly. If no cache period is set, the function is called in real-time each time. The generated URL can be executed in a browser or placed in different test case projects as a script.
[0140] Furthermore, by adding a monitoring program to the platform's backend server, and analyzing server request logs to parse call parameters, it's possible to count class names and method call counts. This allows for the tracking of usage patterns for each class and method within the environment.
[0141] In this embodiment, the platform of the present invention prepares data based on text recognition. To facilitate data preparation, a step is provided whereby the user inputs a text, which is then parsed and converted into data for preparation. The specific steps are as follows.
[0142] The process of constructing the word dictionary is as follows:
[0143] 1) Import the common Chinese lexicons including verbs, nouns, conjunctions, etc.
[0144] 2) Perform statistics and word segmentation on the method names and parameters of the data generation function. The forward maximum matching method is adopted for word segmentation, which splits words from left to right of the text in a greedy manner to obtain the longest word at the current position. The function name is a verb-object structure phrase, where the object is a noun that can be modified by conditional adjectives. For example, in "open corporate current account", "open" is a verb, "current account" is a noun, and "corporate" is an adjective modifying the object, and there may be multiple such adjectives.
[0145] 3) Record the segmented words into a dictionary database for matching with the text input by users.
[0146] Further, the data generation function is matched according to the text, and the specific process is as follows:
[0147] By analyzing a piece of text input by the user, the text is segmented and the corresponding function is called for data preparation. First, the input text is divided into clauses according to commas or verb-object structures, with each verb-object structure as a short sentence, and then word segmentation is performed, as described below;
[0148] 1) A single short sentence matches a single operation data generation function:
[0149] Perform word segmentation on the short sentence input by the user to obtain the corresponding noun object, and query the corresponding data generation function according to the noun. If multiple data generation functions are matched, matching is performed according to different conditions, where an adjective of the noun object in the function name of the data generation function is converted into a condition, and each parameter in the data generation function is converted into a condition. If the parameter has a data dictionary, the data dictionary can be used as a condition for matching. For example, if the data dictionary of the currency parameter is RMB, US dollar, and Euro, the condition can be one of the three currencies. Compare the number of matched conditions between the conditions converted from the user's input short sentence and the conditions converted from the data generation function, and select the data generation function with the most matched conditions as the calling object.
[0150] Matching example: the user inputs "open corporate RMB current account", which is segmented into "open", "corporate", "RMB", "current account". "Open" is an operation verb, "current account" is a noun object, and "corporate" and "RMB" are conditions modifying "current account". According to the noun object "current account", two data generation functions "open corporate current account" and "open personal current account" are searched. Both functions have two parameters "customer number" and "currency", where the data dictionary of "currency" is RMB, US dollar, and Euro. The matching situation is shown in the following table. The "open corporate current account (customer number, currency)" data generation function is matched, the calling parameter customer number takes the default value, and the currency is "RMB", as shown in Table 1.
[0151] Table 1
[0152]
[0153] 2) Multiple short phrases combined to generate multiple number functions:
[0154] The input text is divided into multiple short sentences based on verb-object structures or commas. Each short sentence is matched using a data generation function, and these functions are concatenated according to their parameters. When a function is called, the output of the previous function serves as the input parameter for the next function; if no match is found, the default value is used. When matching short sentences with data generation functions, if two functions have the same number of matching conditions, the conditions of other short sentences are compared; if a match is found, that function is used first.
[0155] Matching Example: The user inputs "Open customer account, open corporate account, open transfer agreement, transfer amount 100 yuan". The text is divided into four short sentences. The corresponding data generation functions are searched for each of the four short sentences. The matching method for short sentences 1 and 3 is the same as that for matching a single operation data generation function for a single short sentence. Short sentence 2 finds two data generation functions based on the noun object. Since the short sentence has no conditional matching, the "personal" part of short sentence 1 is used to match the corresponding function. Short sentence 4 cannot find a function based on the noun object. The function with the highest matching degree is searched based on the noun "amount" and the return type "account" corresponding to the previous short sentence, as shown in Table 2.
[0156] Table 2
[0157]
[0158] Among them, the number generation function can be based on the environment and quantity. Users can specify the environment in which the number generation function is executed when inputting text information, such as "open XX type accounts in function A environment". Users can also specify the number of verbs and nouns in the short sentences in the text to determine the number of calls, such as "open 10 XX type accounts in function A environment". If there are multiple short sentences, the quantifier will also apply to the later short sentences.
[0159] Furthermore, unmatched text is recorded. During the process of text recognition and matching number generation functions, unmatched short phrases are recorded for subsequent analysis. For example, in the above "multiple short phrases combined with multiple number generation functions", short phrase 4 cannot be matched. According to the records, it can be analyzed that the number generation function can improve the matching probability by modifying it into a verb-object format.
[0160] This invention can be used for data preparation for automated and manual testing, and has the following advantages: it standardizes functions by establishing common functions, preventing redundant construction of common functions; it allows for the creation of new common functions based on combinations of common functions; it enables flexible adaptation of data generation scripts via text input, reducing and simplifying the data preparation process for both manual and automated testing, and improving testing efficiency; it allows for the sharing of data generation capabilities across various applications' automated test scripts, meeting more data preparation requirements for both manual and automated testing; and it supports both reading directly from a cached database and real-time data retrieval.
[0161] like Figure 6 The figure shows a schematic diagram of a test case data preparation device according to an embodiment of the present invention. The device shown in the figure includes:
[0162] The text recognition module 10 is used to acquire the data preparation text input by the user, and to recognize the data preparation text to obtain the text recognition result; wherein, the text recognition result includes function parameter information;
[0163] The public function module 20 is used to match the text recognition results with a pre-established list of public functions to determine the public function corresponding to the text recognition results.
[0164] The test data module 30 is used to generate test data based on the function parameter information in the text recognition results and the common functions corresponding to the text recognition results.
[0165] As an embodiment of the present invention, the text recognition module is also used to: segment and parse the data preparation text using a preset word dictionary to obtain the text recognition result.
[0166] As an embodiment of the present invention, such as Figure 7 As shown, the text recognition module 10 includes:
[0167] The text segmentation unit 11 is used to segment the data preparation text using a preset word dictionary to obtain multiple data preparation words;
[0168] The text recognition unit 12 is used to perform text parsing processing on the vocabulary of the data preparation to obtain the text recognition result.
[0169] In this embodiment, as Figure 8 As shown, the test data module 30 includes:
[0170] The number generation function unit 31 is used to package the common functions corresponding to the text recognition results to obtain the number generation function corresponding to the text recognition results;
[0171] Test data unit 32 is used to generate test data based on the execution environment information and input parameter information in the number generation function and function parameter information.
[0172] As an embodiment of the present invention, the public function module 20 is further configured to: use the class name and function name in the text recognition result to search and match in a pre-established public function list to determine the public function corresponding to the text recognition result.
[0173] As one embodiment of the present invention, such as Figure 9 As shown, the device also includes: a function list module 40, used to obtain historical common basic functions and summarize the historical common basic functions using preset construction standards; and to perform function conflict handling and comment information parsing on the historical common basic functions that have been summarized to obtain a common function list.
[0174] In this embodiment, as Figure 10 As shown, the function list module 40 includes:
[0175] Basic function unit 41 is used to retrieve historical common basic functions from multiple test case projects;
[0176] The script directory unit 42 is used to store historical common basic functions in the script directory according to the preset construction standard.
[0177] Function aggregation unit 43 is used to process the names of historical common basic functions by using the preset class names and function names in the preset construction standards, so as to complete the function aggregation.
[0178] Based on the same concept as the aforementioned test case data preparation method, this invention also provides a test case data preparation apparatus. Since the principle by which this test case data preparation apparatus solves the problem is similar to that of the test case data preparation method, the implementation of this test case data preparation apparatus can refer to the implementation of the test case data preparation method, and repeated details will not be elaborated further.
[0179] This invention standardizes functions by constructing a list of common functions, preventing redundant construction of common functions, and enabling the creation of new number generation functions based on combinations of common functions. It also flexibly adapts the number generation script by recognizing the input text, reducing and simplifying the data preparation process for both manual and automated testing, lowering the threshold for data preparation, and improving testing efficiency.
[0180] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described method.
[0181] The present invention also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the above-described method.
[0182] The present invention also provides a computer-readable storage medium storing a computer program for performing the above-described methods.
[0183] like Figure 11 As shown, the electronic device 600 may also include: a communication module 110, an input unit 120, an audio processor 130, a display 160, and a power supply 170. It is worth noting that the electronic device 600 does not necessarily need to include these components. Figure 11 All components shown; in addition, the electronic device 600 may also include Figure 11 For components not shown, please refer to existing technologies.
[0184] like Figure 11 As shown, the central processing unit 100, sometimes also referred to as a controller or operating control, may include a microprocessor or other processor device and / or logic device. The central processing unit 100 receives inputs and controls the operation of various components of the electronic device 600.
[0185] The memory 140 may be, for example, one or more of a cache, flash memory, hard drive, removable media, volatile memory, non-volatile memory, or other suitable devices. It may store the aforementioned failure-related information, and also store a program for executing that information. The central processing unit 100 may execute the program stored in the memory 140 to perform information storage or processing, etc.
[0186] Input unit 120 provides input to central processing unit 100. Input unit 120 may be, for example, a keypad or touch input device. Power supply 170 provides power to electronic device 600. Display 160 displays images and text. Display may be, for example, an LCD display, but is not limited thereto.
[0187] The memory 140 can be a solid-state memory, such as a read-only memory (ROM), random access memory (RAM), a SIM card, etc. It can also be a memory that retains information even when power is off, can be selectively erased, and contains more data; examples of this type of memory are sometimes referred to as EPROMs. The memory 140 can also be some other type of device. The memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application / function storage unit 142 for storing application programs and function programs or processes for executing the operation of the electronic device 600 via the central processing unit 100.
[0188] The memory 140 may also include a data storage unit 143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 144 of the memory 140 may include various drivers for the electronic device's communication functions and / or for performing other functions of the electronic device (such as messaging applications, address book applications, etc.).
[0189] The communication module 110 is a transmitter / receiver 110 that transmits and receives signals via antenna 111. The communication module (transmitter / receiver) 110 is coupled to the central processing unit 100 to provide input signals and receive output signals, which can be the same as in a conventional mobile communication terminal.
[0190] Based on different communication technologies, multiple communication modules 110 can be configured in the same electronic device, such as cellular network modules, Bluetooth modules, and / or wireless LAN modules. The communication module (transmitter / receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide audio output via the speaker 131 and receive audio input from the microphone 132, thereby enabling typical telecommunications functions. The audio processor 130 may include any suitable buffer, decoder, amplifier, etc. Additionally, the audio processor 130 is coupled to a central processing unit 100, enabling on-device recording via the microphone 132 and on-device playback of stored audio via the speaker 131.
[0191] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0192] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0193] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0194] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0195] Specific embodiments have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A method for preparing test case data, characterized in that, The method includes: The system obtains the data preparation text input by the user and recognizes the data preparation text to obtain the text recognition result; wherein, the text recognition result includes the class name, function name and function parameter information; Using the class name and function name in the text recognition result, a search and matching is performed in a pre-established list of public functions to determine the public function corresponding to the text recognition result; The common functions corresponding to the text recognition results are packaged to obtain the number generation functions corresponding to the text recognition results; Test data is generated based on the data generation function, the execution environment information and input parameter information in the function parameter information; The step of recognizing the prepared text data to obtain the text recognition result includes: Based on the verb-object structure and / or commas, the data preparation text is split into multiple short sentences; Using a pre-defined word dictionary, each short sentence is segmented to obtain multiple data preparation words. The data preparation words are then parsed to obtain the class name, function name, and function parameter information corresponding to each short sentence. The common function for determining the text recognition result includes: Using the class name and function name corresponding to each short phrase, a search and match is performed in the pre-established list of public functions to determine the public function corresponding to each short phrase; The step of packaging the common functions corresponding to the text recognition results to obtain the number generation function corresponding to the text recognition results includes: The common functions corresponding to each of the short sentences are concatenated according to their parameters to determine the number generation function corresponding to the text recognition result; wherein, the concatenation is performed by using the output of the previous common function as the parameter input of the next common function.
2. The method according to claim 1, characterized in that, The list of public functions is established in the following way: Obtain historical common basic functions and summarize them using preset construction standards; The historical common basic functions that have been summarized are processed for function conflict resolution and comment information parsing to obtain the list of common functions.
3. The method according to claim 2, characterized in that, The process of obtaining historical common basic functions and summarizing them using preset construction standards includes: The historical common basic functions were obtained from multiple test case projects; Using the script directory in the preset construction standards, the historical common basic functions are stored in the script directory; By using the preset class names and function names in the aforementioned construction standards, the historical common basic functions are named to complete the function summary.
4. A test case data preparation device, characterized in that, The device includes: The text recognition module is used to acquire the data preparation text input by the user, and to recognize the data preparation text to obtain the text recognition result; wherein, the text recognition result includes class name, function name and function parameter information; The public function module is used to match the text recognition result with a pre-established list of public functions to determine the public function corresponding to the text recognition result. The test data module is used to generate test data based on the function parameter information in the text recognition result and the common function corresponding to the text recognition result; Specifically, the text recognition module is used for: Based on the verb-object structure and / or commas, the data preparation text is split into multiple short sentences; Using a pre-defined word dictionary, each short sentence is segmented to obtain multiple data preparation words. The data preparation words are then parsed to obtain the class name, function name, and function parameter information corresponding to each short sentence. Specifically, the common function module is used for: Using the class name and function name corresponding to each short phrase, a search and match is performed in the pre-established list of public functions to determine the public function corresponding to each short phrase; The test data module includes: The number generation function unit is used to package the common functions corresponding to the text recognition results to obtain the number generation function corresponding to the text recognition results; The test data unit is used to generate the test data based on the data generation function, the execution environment information and input parameter information in the function parameter information; The public function module is also used to: use the class name and function name in the text recognition result to search and match in a pre-established public function list to determine the public function corresponding to the text recognition result; Specifically, the number generation function unit is used for: The common functions corresponding to each of the short sentences are concatenated according to their parameters to determine the number generation function corresponding to the text recognition result; wherein, the concatenation is performed by using the output of the previous common function as the parameter input of the next common function.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that performs the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Test case intelligent matching method and device, computer equipment and storage medium
CN108536595A
