Script case automatic generation method and device, terminal and storage medium

An automated tool for generating test scripts from Excel data using keywords and templates addresses the inefficiencies and errors of manual scripting, enhancing the speed and reliability of test case development.

CN119149441AInactive Publication Date: 2024-12-17JIANGSU HUAKU DATA TECH CO LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411667883.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2024-12-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Manual writing of automated test scripts is time-consuming and prone to errors, especially in large numbers and complex test scenarios, with varying formats and structures in Excel files complicating data extraction and requiring complex parsing logic.

Method used

A tool that automatically generates automated test scripts from Excel-based test cases by reading data, determining keywords, and using a mapping relationship configuration file to fill data into a template, thereby simplifying the process and reducing manual intervention.

Benefits of technology

Improves efficiency and accuracy of test script generation by leveraging Excel's readability and editability, reducing human error and enabling quick modification and maintenance of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149441A_ABST
    Figure CN119149441A_ABST
Patent Text Reader

Abstract

The invention provides a script case automatic generation method and device, a terminal and a storage medium, and relates to the field of automatic testing. The method comprises the following steps: reading original data of a target test case in an excel file; determining a plurality of keywords in the original data of the target test case, and writing a mapping relation configuration file by using each keyword; and automatically filling the original data of the target test case into the automatic test script template by utilizing the mapping relationship configuration file to obtain an automatic test script corresponding to the target test case. The generation efficiency of the test script can be improved, and the generation accuracy and reliability of the test script can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing, and in particular to a method, device, terminal and storage medium for automatically generating script use cases. Background Art

[0002] In the process of software testing, the traditional testing process requires manual writing of test text cases according to the specific requirements of the software, and then completing the writing of automated script cases according to the text cases. This is a tedious task that consumes a lot of time and human resources. In addition, manual writing of automated test scripts is prone to errors, especially in a large number of cases and complex test scenarios. At the same time, everyone's coding habits are different, and it is easy for the format and content of the script cases to be difficult to read. Summary of the invention

[0003] The present application provides a method, device, terminal and storage medium for automatically generating script test cases to solve the problem in the prior art that manual writing of automated test cases is time-consuming and prone to errors.

[0004] In a first aspect, the present application provides a method for automatically generating a script use case, comprising: Read the original data of the target test case in the Excel file; Determine multiple keywords in the original data of the target test case, and use each keyword to write a mapping relationship configuration file; The original data of the target test case is automatically filled into the automated test script template by using the mapping relationship configuration file to obtain the automated test script corresponding to the target test case.

[0005] In a second aspect, the present application provides a device for automatically generating script use cases, comprising: Data reading module, used to read the original data of the target test case in the Excel file; A keyword determination module, used to determine multiple keywords in the original data of the target test case, and write a mapping relationship configuration file using each keyword; The script generation module is used to automatically fill the original data of the target test case into the automated test script template by using the mapping relationship configuration file to obtain the automated test script corresponding to the target test case.

[0006] In a third aspect, the present application provides a terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method described in the first aspect or any possible implementation of the first aspect are implemented.

[0007] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the method described in the first aspect or any possible implementation of the first aspect.

[0008] The present application provides a method, device, terminal and storage medium for automatically generating script cases, which reads the original data of the target test case in an Excel file; determines multiple keywords in the original data of the target test case, and uses each keyword to write a mapping relationship configuration file; uses the mapping relationship configuration file to automatically fill the original data of the target test case into the automated test script template to obtain the automated test script corresponding to the target test case. The present application uses an Excel file to hold test cases, and uses the readability and editability of the table to quickly write test cases, modify and maintain test cases; using keywords as mapping relationships, the data in the target test case can be quickly mapped to the automated test script template, which greatly improves the efficiency of test script generation, and the present application does not need to manually edit the script, but automatically generates the test script, which can avoid errors in the manual writing process and improve the accuracy and reliability of test script generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0010] Figure 1 It is a component structure diagram of a tool for an automated script use case provided in an embodiment of the present application; Figure 2 It is a flowchart of the implementation of the method for automatically generating script use cases provided in the embodiment of the present application; Figure 3 It is a structural diagram of a device for automatically generating script use cases provided in an embodiment of the present application; Figure 4 It is a schematic diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION

[0011] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0012] In order to make the purpose, technical solutions and advantages of the present application clearer, specific embodiments will be described below in conjunction with the accompanying drawings.

[0013] The traditional method of generating automated test scripts mainly meets the software testing process by manually writing test text cases. However, there are two main problems in the implementation process: First, the test case data in the Excel file may have different formats and structures, and complex parsing logic needs to be written to extract and normalize the data to handle various possible abnormal situations, such as empty cells, format errors, etc. Second, some test cases may be very complex, containing a large number of steps and conditional branches. Converting these complex test cases into automated scripts requires the design of appropriate algorithms and data structures, as well as efficient generation strategies.

[0014] To solve the above problems, the present invention develops a tool that can automatically generate automated script cases from text test cases, which is applied to the automated script case writing scenarios in the software iteration testing process, optimizes the testing workflow, reduces these repetitive tasks, reduces human errors, and improves the testing quality.

[0015] The tools provided in this application mainly include four components: file parsing, data conversion, template configuration management and script generation. Each component cooperates to complete the analysis and use case generation of this article. Figure 1 ,After parsing the Excel file, data conversion is performed. After the data conversion, keywords are determined and automated test script templates are generated respectively. Keywords and automated test script templates are used together to obtain automated test scripts.

[0016] In order to solve the two problems encountered when developing tools, this application provides the above-mentioned tool, which can automatically parse text test cases in Excel format to generate automated test script cases. For Excel file format and structure problems, a method of converting the original Excel file through configuration is used as the required format. For solving complex test cases into automated scripts, keywords are used to customize the code.

[0017] This application uses this tool in the software testing process. After writing the text test cases required for the test, the software testing team can automatically generate the script cases required for automated testing through the text test cases in Excel format. The value of this technology is reflected in: 1) Traditional automated test script writing usually takes a lot of time and effort, but with text test cases in Excel format, you can quickly write test cases by taking advantage of the readability and editability of the table. Automatically generated scripts can convert these test cases into executable automated test scripts in a short time, greatly improving the work efficiency of the test team.

[0018] 2) Manually writing automated test scripts is prone to errors, especially in a large number of use cases and complex test scenarios. By automatically generating scripts, errors in the manual writing process can be avoided and the accuracy and reliability of test cases can be improved.

[0019] 3) When test cases need to be updated or changed, they can be easily modified and maintained through the text cases in Excel format, and the automatic script generation tool can quickly generate new automated test scripts based on the modified cases, saving a lot of maintenance time.

[0020] 4) The tool for automatically generating scripts has good scalability and can flexibly add new functions and customized requirements as needed. This allows the test team to quickly adjust and expand the test scripts according to project needs and adapt to the ever-changing test environment and requirements.

[0021] 5) Automatic script generation tools can unify the coding standards and testing processes of the testing team, promote team collaboration and communication, and improve the efficiency and accuracy of the entire team.

[0022] For more information about the generation process of automated test scripts, refer to Figure 2 , Figure 2 The implementation flow chart of the method for automatically generating script use cases provided in the embodiment of the present application is described in detail as follows: In step 101, the original data of the target test case in the Excel file is read.

[0023] Among them, the original data read from the Excel file are all strings.

[0024] In an embodiment of the present application, the original data of the target test case is read row by row from the excel file, and the original data of the target test case is saved in the memory database of the terminal, which is convenient for processing the conversion of various cell formats and data types.

[0025] In a possible implementation, reading the original data of the target test case in the Excel file may include: Set the test case template. The test case template is an Excel file containing multiple field types. Import all test cases into the test case template to get an Excel file; Use Python to determine the location information of all test cases in the Excel file. The location information includes the sheet page, column name, and number of rows of each test case in the Excel file. According to the location information of the target test case in the Excel file, the original data of the target test case is obtained.

[0026] Optionally, first set up a test case template containing various excel format files with required field types, and obtain an excel file by importing all the original excel text test cases into the test case template. Then use parsing software to parse the structure of the excel file, that is, use python parsing to determine the location information of all test cases in the excel file, where the location information includes identifying the sheet page, column name, and number of rows of each test case in the excel file. Finally, read the original data of each test case line by line according to the location information of each test case in the excel file.

[0027] The field in the field type means the column name.

[0028] In a possible implementation, the test case template may include field types, and all test cases are imported into the test case template to obtain an Excel file, which may include: Get the field types of all test cases; For each test case, the test case is imported into the location of the test case template that matches the field type of the test case to obtain an Excel file.

[0029] Optionally, obtain the field type of each test case, identify the field type of each test case and the field type configuration in the test case template, and obtain an excel file.

[0030] Among them, the field types of the template need to include fields such as feature name (i.e. function name), test category, test environment, use case title, prerequisites, test steps, prediction results, notes, etc., to ensure that each use case is clear and complete, and is marked with relevant notes or classification information.

[0031] The template also needs to contain formatting.

[0032] In one possible implementation, using Python to determine the location information of all test cases in an Excel file may include: Use the openpyxl library in Python to parse the structure of the Excel file and identify the location information of all test cases in the Excel file.

[0033] Optionally, use file parsing software to parse the Excel file, that is, use the openpyxl library in Python to parse the structure of the Excel file and identify the location information of each test case in the Excel file, that is, the sheet page, column name, and number of rows of each test case in the Excel file.

[0034] In a possible implementation, after reading the original data of the target test case in the Excel file, the method may further include: Use Python to convert the data type of the original data into a target type that can be recognized by the encoding, including dictionaries and lists; Accordingly, multiple keywords in the original data of the target test case may be determined, which may include: Determine multiple keywords in the original data of the target test case converted to the target type.

[0035] A dictionary is an unordered data structure in Python, consisting of key-value pairs. Each key-value pair is separated by a colon, and different key-value pairs are separated by commas. The keys of a dictionary must be unique and must be immutable data types, such as strings, integers, tuples, etc. The values ​​can be any type of data, including strings, integers, lists, dictionaries, etc.

[0036] A list is an ordered data structure in Python that is used to store a set of elements. A list can contain any type of data, including numbers, strings, lists, dictionaries, etc.

[0037] Optionally, after reading the raw data of the target test case, some internal methods in Python are used to convert the data type of the raw data into a target type that is easy to handle inside the program, and the target type includes a dictionary and a list. Then, multiple keywords are obtained from the raw data converted to the target type.

[0038] Target types can also include custom objects, which can be set according to actual needs.

[0039] In a possible implementation, after using Python to convert the data type of the original data into a target type that can be recognized by the encoding, the method may further include: Preprocess the original data converted to the target type, including null value filling, format correction and data deduplication.

[0040] Optionally, after converting the data into a data type that is easy to process, the converted data needs to be preprocessed, cleaned and organized. The preprocessing includes but is not limited to null value filling, format correction and data deduplication to ensure the accuracy and completeness of the data and to splice the information description required in the script.

[0041] In step 102, multiple keywords in the original data of the target test case are determined, and a mapping relationship configuration file is written using each keyword.

[0042] Among them, keywords are synonyms for common operations and are also part of the use case information.

[0043] In the embodiment of the present application, first determine which common operations frequently appear in the target test case, find the corresponding keywords, and then write a mapping relationship configuration file of keywords and codes, so as to use this mapping relationship configuration file to automatically fill the original data of the target test case into the subsequent automated test script template.

[0044] In a possible implementation, before determining a plurality of keywords in the original data of the target test case, the method may further include: Set up an automated test script template. The automated test script template includes multiple running steps, including library information import, use case information description annotation, script pre-check, test execution, log information printing, assertion logic, and script post-cleanup.

[0045] Optionally, first set up an automated test script template, which includes multiple running steps, including library information import, use case information description annotation, script pre-check, test execution, log information printing, assertion logic, script post-cleanup, etc.

[0046] Since some test cases may be very complex, containing a large number of steps and conditional branches, in order to map simple test steps to more complex test logic or operations, thereby simplifying the script writing and maintenance process, specific keywords or identifiers are used to define the behavior of the test code. Therefore, the corresponding keywords are determined according to the content of each running step in the automated test script template.

[0047] In step 103, the original data of the target test case is automatically filled into the automated test script template using the mapping relationship configuration file to obtain the automated test script corresponding to the target test case.

[0048] In the embodiment of the present application, the original data in the target test case is automatically filled into the automated test script template using the mapping relationship configuration file written in step 103, thereby obtaining the automated test script corresponding to the target test case.

[0049] That is, after initially generating the automated test script template, it is necessary to retrieve the keywords in the target test case and fill in the keyword customization code.

[0050] Some test cases may be very complex, containing a large number of steps and conditional branches. In order to map simple test steps to more complex test logic or operations, thereby simplifying the script writing and maintenance process, use specific keywords or identifiers to customize the behavior of the test code. The mapping relationship between keywords and codes exists in the mapping relationship configuration file as a dictionary. After the tool recognizes that there are keywords in the configuration in the test steps, it calls the mapped code as a fill. Arrange the file format, save the generated automated test script to the specified directory, and organize the file name according to the project structure and the naming conventions of the test team.

[0051] For example, if there is a keyword "Step 1: Create table test1" in the original data of the target test case, a mapping code is written in the mapping relationship configuration file, namely: Step 1: Create table test1 create table test1(id serial primary key,name varchar(100),infovarchar(100)) Then enter in the configuration file: log.info("Step 1: Create table test1") sql="""create table test1(id serial primary key,name varchar(100),info varchar(100)""" db_connect.send_sql(sql,expect="") That is {"Create table":"""sql='create table test1(id serial primary key,namevarchar(100),info varchar(100)'db_connect.send_sql(sql,expect='')"""} Automatically generate automated test scripts for target test cases.

[0052] The present application provides a method for automatically generating script cases, which reads the original data of the target test case in an Excel file; determines multiple keywords in the original data of the target test case, and uses each keyword to write a mapping relationship configuration file; uses the mapping relationship configuration file to automatically fill the original data of the target test case into the automated test script template to obtain the automated test script corresponding to the target test case. The present application uses an Excel file to hold test cases, and uses the readability and editability of the table to quickly write test cases and modify and maintain test cases; using keywords as mapping relationships, the data in the target test case can be quickly mapped to the automated test script template, which greatly improves the efficiency of test script generation, and the present application does not need to manually edit the script, but automatically generates the test script, which can avoid errors in the manual writing process and improve the accuracy and reliability of test script generation.

[0053] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0054] The following is an embodiment of the device of the present application. For details not described in detail, please refer to the corresponding method embodiment described above.

[0055] Figure 3 The following is a schematic diagram showing the structure of a script use case automatic generation device provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown, which are described in detail as follows: like Figure 3 As shown, the script use case automatic generation device 3 includes: The data reading module 31 is used to read the original data of the target test case in the excel file; A keyword determination module 32 is used to determine multiple keywords in the original data of the target test case, and to write a mapping relationship configuration file using each keyword; The script generation module 33 is used to automatically fill the original data of the target test case into the automated test script template by using the mapping relationship configuration file, so as to obtain the automated test script corresponding to the target test case.

[0056] The present application provides a device for automatically generating script cases, which reads the original data of the target test case in an excel file; determines multiple keywords in the original data of the target test case, and uses each keyword to write a mapping relationship configuration file; uses the mapping relationship configuration file to automatically fill the original data of the target test case into the automated test script template to obtain the automated test script corresponding to the target test case. The present application uses an excel file to hold test cases, and uses the readability and editability of the table to quickly write test cases and modify and maintain test cases; using keywords as mapping relationships, the data in the target test case can be quickly mapped to the automated test script template, which greatly improves the efficiency of test script generation, and the present application does not need to manually edit the script, but automatically generates the test script, which can avoid errors in the manual writing process and improve the accuracy and reliability of test script generation.

[0057] In a possible implementation, the data reading module may be used to: Set the test case template. The test case template is an Excel file containing multiple field types. Import all test cases into the test case template to get an Excel file; Use Python to determine the location information of all test cases in the Excel file. The location information includes the sheet page, column name, and number of rows of each test case in the Excel file. According to the location information of the target test case in the Excel file, the original data of the target test case is obtained.

[0058] In a possible implementation, the test case template may include a field type.

[0059] In one possible manner, the data reading module can also be used to: Get the field types of all test cases; For each test case, the test case is imported into the location of the test case template that matches the field type of the test case to obtain an Excel file.

[0060] In a possible implementation, the data reading module may also be used for: Use the openpyxl library in Python to parse the structure of the Excel file and identify the location information of all test cases in the Excel file.

[0061] In a possible implementation, the device may further include a type conversion module, which may be used to: Use Python to convert the data type of the original data into a target type that can be recognized by the encoding, including dictionaries and lists; Accordingly, the keyword determination module can be used to: Multiple keywords in the original data of the target test case converted to the target type.

[0062] In a possible implementation, the device may further include a preprocessing module, which may be used to: Preprocess the original data converted to the target type, including null value filling, format correction and data deduplication.

[0063] In a possible implementation, the device may further include a template setting module, and the template setting module may be used to: Set up an automated test script template, which includes multiple running steps, including library information import, use case information description annotation, script pre-check, test execution, log information printing, assertion logic, and script post-cleanup; Identify multiple keywords from each run step of the automated test script template.

[0064] Figure 4 is a schematic diagram of a terminal provided in an embodiment of the present application. Figure 4 As shown, the terminal 4 of this embodiment includes: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer program 42, the steps in the above-mentioned various script use case automatic generation method embodiments are implemented, such as Figure 1 Alternatively, when the processor 40 executes the computer program 42, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Figure 3 The functions of each module are shown.

[0065] Exemplarily, the computer program 42 may be divided into one or more modules / units, which are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 42 in the terminal 4. For example, the computer program 42 may be divided into Figure 3 The modules shown.

[0066] The terminal 4 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal 4 may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 4 It is only an example of terminal 4 and does not constitute a limitation on terminal 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal may also include input and output devices, network access devices, buses, etc.

[0067] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0068] The memory 41 may be an internal storage unit of the terminal 4, such as a hard disk or memory of the terminal 4. The memory 41 may also be an external storage device of the terminal 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the terminal 4. The memory 41 is used to store the computer program and other programs and data required by the terminal. The memory 41 may also be used to temporarily store data that has been output or is to be output.

[0069] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0070] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0071] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0072] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0073] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0074] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0075] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various script use case automatic generation method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practices in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practices, computer-readable media does not include electrical carrier signals and telecommunication signals.

[0076] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for automatically generating script use cases, characterized in that: include: Read the original data of the target test case in the Excel file; Determine multiple keywords in the original data of the target test case, and use each keyword to write a mapping relationship configuration file; The original data of the target test case is automatically filled into the automated test script template by using the mapping relationship configuration file to obtain the automated test script corresponding to the target test case.

2. The method for automatically generating script use cases according to claim 1, characterized in that: The reading of the original data of the target test case in the excel file includes: Set a test case template, which is an Excel file containing multiple field types; Import all test cases into the test case template to obtain an Excel file; Using Python to determine the location information of all test cases in the Excel file, the location information includes the sheet page, column name and number of rows of each test case in the Excel file; According to the location information of the target test case in the Excel file, the original data of the target test case is obtained.

3. The method for automatically generating script use cases according to claim 2, characterized in that: The test case template includes field types, and all test cases are imported into the test case template to obtain an excel file, including: Get the field types of all test cases; For each test case, the test case is imported into the location of the test case template that matches the field type of the test case to obtain the Excel file.

4. The method for automatically generating script use cases according to claim 2, characterized in that: Determining the location information of all test cases in the excel file by using python includes: The openpyxl library in Python is used to parse the structure of the Excel file and identify the location information of all test cases in the Excel file.

5. The method for automatically generating script use cases according to claim 1, characterized in that: After reading the original data of the target test case in the excel file, the method further includes: Using Python, convert the data type of the original data into a target type that can be recognized by the encoding, and the target type includes a dictionary and a list; Accordingly, the determining of multiple keywords in the original data of the target test case includes: A plurality of keywords in the original data of the target test case converted into a target type is determined.

6. The method for automatically generating script use cases according to claim 5, characterized in that: After using Python to convert the data type of the original data into a target type that can be recognized by encoding, the method further includes: The original data converted into the target type is preprocessed, and the preprocessing includes null value supplementation, format correction and data deduplication.

7. The method for automatically generating script use cases according to claim 1, characterized in that: Before determining the multiple keywords in the original data of the target test case, the method further includes: An automated test script template is set up, wherein the automated test script template includes multiple running steps, wherein the running steps include information import of the usage library, information description annotation of the use case, pre-check of the script, test execution, log information printing, assertion logic, and post-cleanup of the script.

8. A script case automatic generation device, characterized in that: include: Data reading module, used to read the original data of the target test case in the Excel file; A keyword determination module, used to determine multiple keywords in the original data of the target test case, and write a mapping relationship configuration file using each keyword; The script generation module is used to automatically fill the original data of the target test case into the automated test script template by using the mapping relationship configuration file to obtain the automated test script corresponding to the target test case.

9. A terminal 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, the steps of the method for automatically generating script use cases as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for automatically generating script use cases as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method, terminal and storage medium for automatically generating test script

    CN109086199A

  • Automatic generation system and method for test case script

    CN112286814A

  • Test code generation method and device, electronic equipment and readable storage medium

    CN115827490A

  • System and Method For Automating Test Automation

    US20130097586A1