Automatic script generation method and device, equipment and medium
By identifying and matching test case parameters and templates of the automotive embedded controller application layer software, target test scripts are generated, which solves the problem of test script reuse between different projects and improves the efficiency of test development.
Patent Information
- Application Number
- CN202510113154.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-30
AI Technical Summary
It is difficult to implement the testing of the same set of test scripts for different projects in the application layer software of the automotive embedded controller, resulting in wasted test development time.
By obtaining test cases, identifying use case parameters, determining use case parameter labels, matching the target basic use case templates in the use case template library, and generating target test scripts.
It realizes script reuse across projects with as few script changes as possible, improves the reuse of application layer simulation automation test scripts, and reduces project adaptation time.
Smart Images

Figure CN120066960A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of testing technologies, and particularly to an automated script generation method, apparatus, device, and medium. Background Art
[0002] Due to the particularity of the functions and the flexibility of the logic of the application layer software of automotive embedded controllers, there are often obvious deviations between projects. Coupled with the fact that the content function logic of the application layer often depends on bus signals, there are bound to be signal differences when the same function is deployed in different projects. Therefore, it is very difficult to implement the same set of test scripts for testing different projects when conducting functional tests on the application layer software of automotive embedded controllers. And developing a single-project automated test script for different application test projects will inevitably waste a lot of test development time. Summary of the Invention
[0003] In view of the above-mentioned disadvantages of the prior art, this application provides an automated script generation method, apparatus, device, and medium for solving at least one defect in the prior art.
[0004] To achieve the above and other purposes, this application provides an automated script generation method, including:
[0005] Obtain test cases;
[0006] Identify multiple attribute fields of the test cases and the use case parameters corresponding to each attribute field;
[0007] Determine the use case parameter tags corresponding to the use case parameters;
[0008] Match a target basic use case template in a use case template library according to the use case parameter tags, where multiple basic use case templates are stored in the use case template library;
[0009] Generate a target test script based on the use case parameters and the target basic use case template.
[0010] In an embodiment of this application, the matching of the target basic use case template in the use case template library according to the use case parameter tags includes:
[0011] Use the use case parameter tags as the first tags, and obtain the second tags corresponding to the first tags according to the first tags and a pre-established first association relationship; the first association relationship represents the corresponding relationship between the first tags and the second tags;
[0012] Based on the second tag and the pre-constructed second association relationship, determine the use case template corresponding to the second tag as the target basic use case template, where the second association relationship is stored in the use case template library and is used to represent the correspondence between the second tag and the use case template.
[0013] In an embodiment of the present application, the establishment of the use case template library includes:
[0014] Obtain a plurality of historical test cases, and each historical test case includes a plurality of functional modules;
[0015] Group the plurality of historical test cases to obtain at least one test case group, and each test case group includes a plurality of historical test cases;
[0016] For the same test case group, determine the same functional modules of the plurality of historical test cases, strip the use case parameters of the same functional modules to obtain a basic use case template, and determine the template tag of the basic use case template;
[0017] Establish a use case template library based on the basic use case template.
[0018] In an embodiment of the present application, the basic use case template includes:
[0019] A use case function template composed of one or two functions;
[0020] A use case step template for implementing a set of test steps;
[0021] A complete use case template including several use case step templates or / and use case function templates for implementing complete use case function verification.
[0022] In an embodiment of the present application, the test case is a tabular test case, and the method further includes:
[0023] Perform a first preprocessing on the tabular test case, and the first preprocessing includes at least one of the following:
[0024] Check whether there are merged cells in the test case, and split the merged cells when there are merged cells;
[0025] Check whether there are missing cells in the test case, and fill in the content of the missing cells when there are missing cells.
[0026] In an embodiment of the present application, if the target basic use case template cannot be matched in the use case template library according to the use case parameter tag, then the method further includes:
[0027] Based on the similarity between the test case and the basic use case template, determine the basic use case template with the highest similarity to the test case in the use case template library as the target basic use case template;
[0028] Obtain the same functional modules and different functional modules between the test case and the target basic use case template;
[0029] Generate a first test script file based on the same functional modules;
[0030] Generate a second test script file based on the different functional modules;
[0031] Obtain a target test script file based on the first test script file and the second test script file.
[0032] In an embodiment of the present application, the method further includes:
[0033] Perform a second preprocessing on the use case parameters, and the second preprocessing includes at least one of the following:
[0034] Verify the validity of the use case parameters;
[0035] Verify the compliance of the use case parameters;
[0036] Verify the integrity of the use case parameters.
[0037] To achieve the above object and other related objects, the present application provides an automated script generation device, and the automated script generation device includes:
[0038] A use case file acquisition module for acquiring test cases;
[0039] A use case parameter identification module for identifying multiple attribute fields of the test case and use case parameters corresponding to each attribute field;
[0040] A template label determination module for determining use case parameter labels corresponding to the use case parameters;
[0041] A use case template matching module for matching a target basic use case template in a use case template library according to the use case parameter labels, and a plurality of basic use case templates are stored in the use case template library;
[0042] A test script generation module for generating a target test script based on the use case parameters and the target basic use case template.
[0043] To achieve the above object and other related objects, the present application provides an automated script generation device, including:
[0044] One or more processors; and
[0045] A memory for storing one or more programs, which, when executed by the one or more processors, cause the memory to implement the automated script generation method described above.
[0046] To achieve the above and other related objectives, the present application provides one or more machine-readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to execute the automated script generation method described above.
[0047] Advantages of the present application:
[0048] An automated script generation method of the present application includes: obtaining test cases; identifying multiple attribute fields of the test cases and use case parameters corresponding to each attribute field; determining use case parameter tags corresponding to the use case parameters; matching a target basic use case template in a use case template library, where the use case template library stores multiple basic use case templates; generating a target test script based on the use case parameters and the target basic use case template; when generating a use case script, the present application calls the corresponding use case template according to the attribute fields, then fills the corresponding use case parameters into the use case template, and realizes the whole process of template application and script automated development from the initial test case to the final test script file; after the script is automatically generated, only simple project engineering debugging needs to be carried out on the generated script to be used for the test of the actual project, which can greatly improve the development efficiency of the application layer function simulation test.
[0049] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts. In the drawings:
[0051] Figure 1 is a flowchart of an automated script generation method according to an embodiment of the present application;
[0052] Figure 2 is a schematic diagram of a test case according to an embodiment of the present application;
[0053] Figure 3 is a flowchart of the establishment of a use case template library according to an embodiment of the present application;
[0054] Figure 4 Flowchart of an automatic script generation method according to an embodiment of the present application;
[0055] Figure 5 Block diagram of an automatic script generation device according to an embodiment of the present application.
[0056] Figure 6 Schematic diagram of the structure of a computer system of a memory suitable for implementing the embodiments of the present application. Detailed implementation manners
[0057] The following uses specific specific examples to illustrate the implementation manners of the present application. Those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in this specification. The present application can also be implemented or applied through other different specific implementation manners. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0058] It should be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present application in a schematic manner. Therefore, only the components related to the present application are shown in the diagrams, rather than being drawn according to the number, shape, and size of the components in actual implementation. The type, quantity, and proportion of each component in actual implementation can be an arbitrary change, and the component layout type may also be more complex.
[0059] Although terms such as "first", "second", "A", and "B" can be used herein to describe various elements, these elements should not be limited by these terms and are only used to distinguish one element from another. For example, without departing from the scope of the following technology, the first element can be called the second element, and similarly, the second element can be called the first element. The term "and / or" includes combinations of multiple related items or any item in multiple related items.
[0060] As used herein, unless the context indicates otherwise, the singular form is also intended to include the plural form. It will be understood that the term "comprising" means the presence of the described features, quantities, steps, operations, elements, or combinations thereof, but does not exclude the presence or addition of one or more other features, quantities, steps, operations, elements, components, or combinations thereof.
[0061] Before the detailed description, it is intended to clarify that the division of components in this specification is only based on the main functions of each component. That is, two or more of the following-described components can be combined into one component, or can be divided into two or more components according to more detailed functions. In addition to the main functions of the components, each of the following-described components can also perform some or all of the functions of other components, and some of the main functions of each component can be specifically performed by other components.
[0062] In order to overcome the problem that it is difficult to achieve script-level test reuse in the simulation testing of the application layer software of automotive embedded controllers, and that the same set of test scripts can complete cross-project script reuse with as few script changes as possible, so as to maximize the reuse degree of application layer simulation automation test scripts and minimize the project adaptation time for application layer simulation testing based on different projects, this application provides an automated script generation method.
[0063] Please refer to Figure 1 , Figure 1 which is a flowchart of an automated script generation method according to an embodiment of this application.
[0064] Specifically, as shown in Figure 1 , the automated script generation method at least includes steps S110 - S150:
[0065] Step S110, obtain test cases;
[0066] A test case is a description of the test tasks for a specific software product, which reflects the test plan, methods, techniques, and strategies. Its content includes test objectives, test environments, input data, test steps, expected results, test scripts, etc., and finally forms a document. Simply put, a test case is a set of test inputs, execution conditions, and expected results prepared for a specific goal, used to verify whether a specific software requirement is met. A test case mainly contains four contents: use case title, precondition, test steps, and expected results. The use case title mainly describes the test of a certain function; the precondition means that the use case title needs to meet this condition; the test steps mainly describe the operation steps of the use case; the expected result refers to meeting the expected (development specification, requirement document, user requirement, etc.) requirements.
[0067] Step S120, identify multiple attribute fields of the test case and the use case parameters corresponding to each attribute field;
[0068] Generally, the test case is a tabular test case. There are some attribute fields in the tabular test case. As Figure 2 shown, Figure 2 is a schematic diagram of a test case according to an embodiment of this application. In Figure 2Among them, the attribute fields may include item / software, functional module, functional feature, test purpose, precondition, reference information, operation steps, operation description, data, expected result, use case name, use case identification, use case number, etc. By identifying the entire test case, the attribute fields in the test case are obtained. For a test case, multiple attribute fields and the use case parameters corresponding to the multiple attribute fields will be identified. For example, the use case parameter corresponding to "use case number" is "Project MA Login 1", the use case parameter corresponding to "functional feature" is "the initial form of the system and perform user legality verification", and the use case parameter corresponding to "test purpose" is "verify whether legal information is input, prevent illegal login to ensure the security features of the system", etc.
[0069] Step S130, determine the use case parameter label corresponding to the use case parameter;
[0070] Through step S120, multiple use case parameters are identified. Through the combination of one or more use case parameters among the multiple use case parameters, the corresponding label of the use case parameter can be determined. Through this use case parameter label, the corresponding use case template can be determined.
[0071] Step S140, match the target basic use case template in the use case template library, and multiple basic use case templates are stored in the use case template library;
[0072] It should be noted that the basic use case template means that multiple use case templates have the same basic framework. By extracting the frameworks of multiple use case templates, then determining the same parts, and then stripping the use case parameters of the same parts and retaining the corresponding attribute fields, the basic framework, that is, the basic use case template, can be obtained. Multiple basic use case templates are stored in the use case template library, and each basic use case template is set with a template label, and the template labels of different basic use case templates are different. By identifying the template label, the corresponding basic use case template can be determined.
[0073] After determining the use case parameter label corresponding to the use case parameter, according to the pre-established correspondence between the use case parameter label and the template label, the template label corresponding to the use case parameter label and the basic use case template corresponding to the template label are found in the use case template library as the target basic use case template.
[0074] Step S150, generate a target test script based on the use case parameter and the target basic use case template.
[0075] After obtaining the target basic use case template corresponding to the test case, fill the use case parameters into the target basic use case template according to the positions of the respective attribute fields in the target basic use case template to obtain a functional entity that serves a specific project and specific function and can be used for test execution. Then, organize the content of the specific code for the functional entity, and use the script generation function in the aforementioned script automation generation tool to organize the content of the specific code for the aforementioned materialized test case according to the aforementioned template framework, and at the same time complete the function index, the organization of the code project structure, and the output of the complete code to obtain a test script.
[0076] In one embodiment, the matching of the target basic use case template in the use case template library according to the use case parameter label includes: using the use case parameter label as a first label, and obtaining a second label corresponding to the first label according to the first label and a pre-established first association relationship; the first association relationship represents the corresponding relationship between the first label and the second label; based on the second label and a pre-constructed second association relationship, determine the use case template corresponding to the second label as the target basic use case template, where the second association relationship is stored in the use case template library and is used to represent the corresponding relationship between the second label and the use case template.
[0077] Specifically, identify the template type of the attribute field, and then determine the corresponding use case parameter label through the use case parameter corresponding to the attribute field. For example, the use case parameter label is type A, and type A is used as the first label. Use the first association relationship between the first label and the second label to search in the use case template library for the second label corresponding to the first label. The second label corresponding to the first label here refers to the second label that is the same as the first label. Since the use case template library stores the corresponding relationship between the second label and the use case template, based on the second label, the use case template corresponding to the second label can be determined, and thus the use case template corresponding to the first label, that is, the target basic use case template, can be determined. For example, if the first label is label A, then check whether there is label A in the use case template library. When there is label A, determine the use case template corresponding to label A, so as to find the target basic use case template.
[0078] Please refer to Figure 3 , Figure 3 which is a flowchart for the establishment of the use case template library according to an embodiment of the present application. In Figure 3 , the establishment of the use case template library includes:
[0079] Step S310, obtain a plurality of historical test cases, and each historical test case includes a plurality of functional modules;
[0080] For one test case, it includes a plurality of functional modules, and each functional module is different.
[0081] Step S320: Group the multiple historical test cases to obtain at least one test case group, where each test case group includes multiple historical test cases;
[0082] Specifically, the multiple historical test cases can be grouped according to the similarity between each historical test case. For example, the multiple historical test cases are grouped into multiple test case groups according to the range of similarity values. Those with similarity between [n1, n2] are divided into the same group, those with similarity between [n2, n3] are divided into the same group, those with similarity between [n3, n4] are divided into the same group, and those with similarity between [n4, n5] are divided into the same group. The specific number of groups can be set according to actual needs and is not limited here. For two test cases, the more identical functional modules they have, the greater their similarity.
[0083] Step S330: For the same test case group, determine the identical functional modules of the multiple historical test cases, strip the case parameters of the identical functional modules to obtain a basic use case template, and determine the template tags of the basic use case template;
[0084] To verify a certain function, organize and integrate some or certain functions in the underlying index code so that the organized functions form one or certain specific functions. The function combination with specific functions is organized through code and the specific case parameters are abstractly stripped to make it a template that can be applied, that is, the basic use case template. When conducting project testing, map the above basic use case template to the corresponding underlying index code completely, that is, adapt different case parameters based on the basic use case template, and the complete test logic organized by the underlying index code can be realized.
[0085] The underlying index code is the lowest-level data source for realizing the reuse of test scripts. It consists of a series of decoupled test functions serving simulation tests, including underlying function modules, specific case step functions, and specific case template functions. By extracting the basic framework of multiple historical test cases with multiple modules and multiple functions and stripping the case parameters related to the project and retaining the attribute fields, the basic use case template is obtained.
[0086] To extract the basic use case template, it is necessary to specifically distinguish the test cases related to the specific application functions, and divide the test cases into reusable test cases, temporarily non-reusable test cases, and non-reusable test cases according to the reuse level of the case scripts. Among them
[0087] Reusable test cases refer to test cases that are feasible to implement reuse transformation at the technical level and whose scripts are relatively easy to transform;
[0088] Test cases that cannot be reused temporarily refer to test cases that are feasible to implement reuse transformation at the technical level but are difficult to transform according to the current evaluation of the script;
[0089] Non-reusable test cases refer to test cases that are currently evaluated as impossible to implement reuse transformation at the technical level.
[0090] There should be multiple basic test case templates to meet the organization of different application layer function logic scripts. The aforementioned underlying index code contains a reuse logic framework that may involve some application layer test cases. The logic framework takes into account the content involved in most application layer test cases and includes the initial environmental conditions for verifying the specific test logic of a certain function module, the trigger logic to be verified, and the logical results to be verified. For example, for the test of many application layer modules, the verification on the simulation side is mainly to first simulate the environmental message of the logic trigger on the bus side, and under the condition of meeting the trigger logic, send the bus message of the trigger logic to the corresponding bus network segment of the function to be tested, and after sending the trigger logic message, check the performance of the function logic item. Correspondingly, it is necessary to check the specific relevant messages after the logic trigger is completed from the bus side and compare them with the expected results to confirm whether the verified function logic meets the verification requirements. To implement the sending of the message signal group of the initial environmental conditions and the message signal group related to the trigger logic, the underlying index code provides a service function based on sending a specific signal set. This service function can send the corresponding message to the corresponding bus channel based on the given message signal information to be sent (for example: message ID, signal position, message length, signal name, message period, signal value, and the network segment where it is located); in addition, the underlying index code of this solution also provides a verification service function based on the expected signal result and the current actual signal result. This service function can read the message signal to be verified from the corresponding bus channel based on the given message signal information to be checked (for example: message ID, signal position, message length, signal name, message period, signal value, and the network segment where it is located). To achieve the decoupling of the test script project, the underlying index code contains multiple interface functions that can extract external data of the script. These interface functions can read external data files, including but not limited to reading the content of ini files or csv files; at the same time, various data formats can be covered for the content of the read external files, including but not limited to obtaining various data such as integers, long integers, floating-point numbers, and strings. When running the test project of a specific component, the test project will complete the reading of the internal project parameters of the script based on these interface functions and perform parameter assignment within the script. Subsequently, the script of the subsequent test cases will execute the tests of a specific project based on the project parameters read.
[0091] In one embodiment, the basic test case template includes:
[0092] A use case function template consisting of one or two functions;
[0093] A use case step template for implementing the set test steps;
[0094] A complete use case template including several use case step templates or / and use case function templates for implementing the verification of the complete use case function.
[0095] Specifically, the use case function template is the most basic function template with basic functions and can be applied, which is composed of one or two functions in the underlying index code to achieve the smallest template call. The function of this use case function template is not sufficient to complete the specific function of a certain test step;
[0096] The use case step template is a step function template that can implement a specific test step and is composed of several index codes. With the smallest step template call, this use case step template can be called by various types of use cases;
[0097] The complete use case template is a use case function template composed of several step templates or use case function templates, which can implement the verification of the complete use case function to achieve the call of a single test use case template. Based on the call of this use case template, different use case verifications can be completed by matching different parameter information.
[0098] Step S340, establishing a use case template library based on the basic use case template.
[0099] Import all the basic use case templates into the database to form a use case template library.
[0100] In one embodiment, the automatic script generation method further includes:
[0101] Converting the test use case to convert a specific test use case file into a use case file convenient for extracting use case keywords and key information. That is, converting the test use case into a use case file that can be parsed by the tool software. The input test use case needs to follow a fixed use case file template and format to facilitate the extraction of attribute fields and use case parameters.
[0102] In one embodiment, the test use case is a tabular test use case, and the automatic script generation method further includes: performing a first preprocessing on the tabular test use case, and the first preprocessing includes at least one of the following: checking whether there are merged cells in the test use case and splitting the merged cells when there are merged cells; checking whether there are missing cells in the test use case and filling in the content of the missing cells when there are missing cells. By checking and adjusting the converted use case file, the deviation in the subsequent process can be avoided.
[0103] In one embodiment, the automatic script generation method further includes: performing a second preprocessing on the use case parameters, where the second preprocessing includes at least one of the following: validating the effectiveness of the use case parameters; validating the compliance of the use case parameters; validating the integrity of the use case parameters. By validating the use case parameters, the effectiveness of the process execution during subsequent testing is ensured.
[0104] In one embodiment, the automatic script generation method further includes: organizing the use case data for the use case parameters after the second preprocessing to form a processed use case data format in a fixed form. The use case parameters are organized in a structured manner, such as a JSON file, to achieve correspondence with subsequent use cases or script templates. The processed use case parameters have specific tags required for subsequent matching templates, facilitating the matching of use case content with the corresponding templates.
[0105] Please refer to Figure 4 , Figure 4 which is a flowchart of the automatic script generation method according to an embodiment of the present application. In Figure 4 , if the target basic use case template cannot be matched in the use case template library according to the use case parameter tags, then the method further includes:
[0106] Step S410, determining the basic use case template with the highest similarity to the test case in the use case template library as the target basic use case template according to the similarity between the test case and the basic use case template;
[0107] Step S420, obtaining the same functional modules and different functional modules between the test case and the target basic use case template;
[0108] Step S430, generating a first test script file based on the same functional modules;
[0109] Step S440, generating a second test script file based on the different functional modules;
[0110] Step S450, obtaining a target test script file based on the first test script file and the second test script file.
[0111] When the target basic use case template cannot be matched in the use case template library, the similarity between the test case and the basic use case template can be calculated to obtain multiple similarity values. The basic use case template corresponding to the highest similarity is used as the target basic use case template. Since both the test case and the basic use case template are composed of multiple functional modules, the similarity can be calculated based on the same functional modules between the test case and the basic use case template. For example, the more identical functional modules there are, the greater the similarity value; conversely, the smaller it is. After determining the target basic use case template, obtain the same functional modules and different functional modules between the test case and the target basic use case template. For the parts that are the same between the test case and the target basic use case template, fill in the use case parameters corresponding to the same functional modules, so that the first test script file can be generated based on the file after filling in the use case parameters; for the parts that are different between the test case and the target basic use case template, edit and generate the corresponding second test script file, and finally integrate the first test script file and the second test script file to obtain the target test script file.
[0112] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0113] Figure 5 It is a block diagram of an automated script generation device shown in an embodiment of the present application. As Figure 5 shown, an automated script generation device includes:
[0114] A use case file acquisition module 510, configured to acquire test cases;
[0115] A use case parameter identification module 520, configured to identify multiple attribute fields of the test case and use case parameters corresponding to each attribute field;
[0116] A template label determination module 530, configured to determine use case parameter labels corresponding to the use case parameters;
[0117] A use case template matching module 540, configured to match a target basic use case template in a use case template library according to the use case parameter labels, where multiple basic use case templates are stored in the use case template library;
[0118] A test script generation module 550, configured to generate a target test script based on the use case parameters and the target basic use case template.
[0119] It should be noted that the automated script generation device provided in the above embodiments and the automated script generation method provided in the above embodiments belong to the same concept. The specific manners in which each module and unit perform operations have been described in detail in the method embodiments and will not be elaborated herein. In practical applications, the automated script generation device provided in the above embodiments may, as required, allocate the above functions to different functional modules, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above. This is not limited herein either.
[0120] Embodiments of the present application further provide an automated script generation device, including: one or more processors; and a memory for storing one or more programs, which, when executed by the one or more processors, cause the memory to implement the automated script generation method in the above embodiments.
[0121] Embodiments of the present application further provide one or more machine-readable media, on which instructions are stored, which, when executed by one or more processors, cause the processors to implement the automated script generation method in the above embodiments.
[0122] Figure 6 The structural diagram of a computer system suitable for implementing the memory in the embodiments of the present application is shown. It should be noted that Figure 6 The computer system of the memory shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present application.
[0123] As Figure 6 shown, the computer system includes a central processing unit (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) or the program loaded from the storage part into the random access memory (RAM), such as executing the method in the above embodiments. In the RAM, various programs and data required for system operation are also stored. The CPU, ROM, and RAM are connected to each other through a bus. The input / output (I / O) interface is also connected to the bus.
[0124] The following components are connected to the I / O interface: an input section including a keyboard, a mouse, etc.; an output section including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section including a hard disk, etc.; and a communication section including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as needed. A removable medium such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive as needed so that a computer program read therefrom is installed into the storage section as needed.
[0125] Specifically, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product that includes a computer program carried on a computer-readable medium, the computer program including a computer program for performing the automated script generation method described in the foregoing embodiments. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), various functions defined in the system of the present application are executed.
[0126] It should be noted that the computer-readable medium shown in the embodiments of the present application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable computer program. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. Among them, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0128] The units involved in the embodiments described in this application can be implemented in software or in hardware, and the described units can also be provided in a processor. Among them, the names of these units do not constitute a limitation to the unit itself in some cases.
[0129] Another aspect of this application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer is caused to execute the automated script generation method as described above. The computer-readable storage medium may be included in the memory described in the above embodiments, or may exist alone without being assembled into the memory.
[0130] Another aspect of this application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the automated script generation method provided in the above various embodiments.
[0131] The above embodiments are only used to exemplarily illustrate the principles and effects of this application, rather than to limit this application. Any person familiar with this technology can modify or change the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or changes completed by those with ordinary knowledge in the technical field without departing from the spirit and technical idea disclosed in this application should still be covered by the claims of this application.
Claims
1. An automated script generation method, characterized in that: The automated script generation method comprises: Get test cases; Identify multiple attribute fields of the test case and a test case parameter corresponding to each attribute field; Determine a use case parameter label corresponding to the use case parameter; Matching a target basic use case template in a use case template library according to the use case parameter tag, wherein the use case template library stores a plurality of basic use case templates; A target test script is generated based on the use case parameters and the target basic use case template.
2. The automated script generation method according to claim 1, characterized in that: The matching of the target basic use case template in the use case template library according to the use case parameter tag includes: The use case parameter tag is used as a first tag, and a second tag corresponding to the first tag is obtained according to the first tag and a pre-established first association relationship; the first association relationship indicates a correspondence between the first tag and the second tag; Based on the second tag and the pre-constructed second association relationship, a use case template corresponding to the second tag is determined as the target basic use case template, wherein the second association relationship is stored in a use case template library and is used to represent the correspondence between the second tag and the use case template.
3. The automated script generation method according to claim 2, characterized in that: The establishment of the use case template library includes: Obtain multiple historical test cases, each of which includes multiple functional modules; Grouping the multiple historical test cases to obtain at least one test case group, each test case group including multiple historical test cases; For the same test case group, determine the same functional modules of multiple historical test cases, and strip the test case parameters of the same functional modules to obtain a basic test case template, and determine the template tag of the basic test case template; Establish a use case template library based on the basic use case template.
4. The automated script generation method according to claim 3, characterized in that: The basic use case template includes: A use case function template consisting of one or two functions; Use case step templates that implement the defined test steps; A complete use case template including several use case step templates and / or use case function templates, which is used to implement the complete use case function verification.
5. The automated script generation method according to claim 1, characterized in that: The test case is a tabular test case, and the method further includes: Performing a first preprocessing on the tabular test case, wherein the first preprocessing includes at least one of the following: Check whether there are merged cells in the test case, and split the merged cells if there are merged cells; Check whether there are missing cells in the test case, and complete the content of the missing cells if there are missing cells.
6. The automated script generation method according to claim 3, characterized in that: If the target basic use case template cannot be matched in the use case template library according to the use case parameter tag, the method further includes: According to the similarity between the test case and the basic case template, determining the basic case template with the highest similarity to the test case in the case template library as the target basic case template; Obtain the same functional modules and different functional modules between the test case and the target basic case template; Based on the same functional module, generate a first test script file; Based on the difference function module, generate a second test script file; Based on the first test script file and the second test script file, a target test script file is obtained.
7. The automated script generation method according to claim 1, characterized in that: The method further comprises: Performing a second preprocessing on the use case parameter, wherein the second preprocessing includes at least one of the following: Verifying the validity of the use case parameters; Verify compliance of the use case parameters; Perform integrity verification on the use case parameters.
8. An automatic script generation device, characterized in that: The automatic script generating device comprises: Use case file acquisition module, used to obtain test cases; A test case parameter identification module, used to identify multiple attribute fields of the test case and a test case parameter corresponding to each attribute field; A template tag determination module, used to determine a use case parameter tag corresponding to the use case parameter; A use case template matching module, used to match a target basic use case template in a use case template library according to the use case parameter tag, wherein the use case template library stores a plurality of basic use case templates; A test script generation module is used to generate a target test script based on the use case parameters and the target basic use case template.
9. An automated script generation device, characterized in that: include: one or more processors; and A memory, used to store one or more programs, when the one or more programs are executed by the one or more processors, enables the memory to implement the automatic script generation method as described in any one of claims 1-7.
10. A machine-readable medium, characterized in that Instructions are stored thereon, which, when executed by one or more processors, enable the processors to execute the automatic script generation method as described in any one of claims 1-7.