Test script generation method and device, computer device, storage medium and product
By receiving test requests, creating category tables and information linked lists, and automatically inserting business data to generate test scripts, the inefficiency problem in existing technologies is solved, and efficient test data generation and management are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2022-12-05
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, manually entering and collecting business data to generate test scripts is inefficient and cannot meet the needs of software testing scenarios that require a large amount of test data.
By receiving test requests from the test environment, creating category tables and information linked lists, automatically inserting business data from the data source, generating test scripts, and performing basic tests after meeting test thresholds, as well as deleting or updating the test scripts.
It enables automatic generation of test scripts, improves the efficiency of test data acquisition, meets the software testing needs of large amounts of test data, and avoids the inefficiency of manual collection and entry.
Smart Images

Figure CN115994089B_ABST
Abstract
Description
Technical Field
[0001] This application relates to communication technology, and more particularly to a test script generation method, apparatus, computer equipment, storage medium, and product. Background Technology
[0002] Software testing is a process based on test scripts used to assess the correctness, integrity, security, and quality of software. A test script is a series of instructions for a specific test that can be executed by automated testing tools.
[0003] Currently, when facing various testing environments, the common practice is to manually collect the business data required for each testing environment and then manually enter this business data into the test template to obtain the test script. However, the inventors have found that this method of manually collecting and entering business data to obtain the test script is inefficient and cannot meet the needs of software testing scenarios that require a large amount of test data. Summary of the Invention
[0004] This application provides a test script generation method, apparatus, computer device, storage medium, and product to solve the problem that current methods of obtaining test scripts are inefficient and cannot meet the needs of software testing scenarios requiring large amounts of test data.
[0005] Firstly, this application provides a method for generating test scripts, including:
[0006] The system receives a test request sent by the testing environment; wherein the test request is used to instruct the generation of a test script; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the testing environment for software testing, and data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for the software testing.
[0007] A category table is created based on the data categories, and the data characteristics of the data categories are inserted into the category table to obtain an information table;
[0008] An information linked list is created based on the information table. Business data from the database corresponding to the data source information is inserted into the information linked list. The information linked list containing the business data is then converted into a test script. The test script is used to perform software testing in the test environment. The business data in the test script is test data used for software testing in the test environment.
[0009] In the above scheme, after converting the information linked list containing business data into a test script, the method further includes:
[0010] If it is confirmed that the test data in the test script reaches the preset test threshold, the test script is invoked to perform basic testing in the test environment; wherein, the basic testing is a test of one or more functional points in the functional testing of the software test;
[0011] If the test script is confirmed to pass the basic test, then the test script will be retained in the test environment;
[0012] If it is confirmed that the test script fails the basic test, then the test script will be removed from the test environment.
[0013] In the above scheme, after converting the information linked list containing business data into a test script, the method further includes:
[0014] If it is confirmed that the number of test data in the test script has not reached the test threshold, a new request is sent to the test environment;
[0015] The test environment receives new data source information sent according to the new request; the new data source information represents a database that stores business data required for the software test, and the business data in the database corresponding to the new data source information is inserted into the test script.
[0016] In the above scheme, after converting the information linked list containing business data into a test script, the method further includes:
[0017] If it is confirmed that the test script has completed the software testing of the test environment, then the test data in the test script is deleted to obtain an empty script.
[0018] In the above scheme, the step of creating a category table based on the data category and inserting the data characteristics of the data category into the category table to obtain an information table includes:
[0019] Create an empty table and use the data categories as the title information of the empty table, thus converting the empty table into a category table;
[0020] Obtain the data characteristics of the data type, insert the data characteristics into the type table, make the data characteristics a table field of the type table, and convert the type table into the information table.
[0021] In the above scheme, after inserting the data features of the data types into the category table to obtain the information table, the method further includes:
[0022] The main category is determined based on the relationships between the data types. The information table corresponding to the main category is set as the main table, and the other information tables in the information table besides the main table are set as subordinate tables. The relationships are the dependencies between two or more data types described in the test requirement information. The main category is the dependent of all other data types in the data type in the relationships.
[0023] The identifier information in the main table is used as the primary key constraint of the main table, and the identifier information is used as the foreign key constraint of the subordinate table in the information table; wherein, the identifier information is a table field in the main table that can serve as a unique identifier for business data; the primary key constraint is used to define the uniqueness of data rows in the main table; the foreign key constraint is a table field whose content is consistent with the primary key constraint, and the foreign key constraint is used to associate the main table with the subordinate table.
[0024] In the above scheme, before creating the information linked list based on the information table, the method further includes:
[0025] A test transaction is created, and the number of tests and the number of commits are configured within the test transaction. The start of the test transaction is used to create an information linked list based on the information table, and to insert business data from the database corresponding to the data source information into the information linked list. The commit of the test transaction is used to convert the information linked list containing the business data into a test script. The number of tests is a numerical value defining the number of test data items in the test script. The number of commits defines the number of test data items in the test script when the test script is used for one database insertion operation in the test environment.
[0026] In the above scheme, the step of creating an information linked list based on the information table and inserting the business data from the database corresponding to the data source information into the information linked list includes:
[0027] Set the database corresponding to the data source information as the first database;
[0028] Create a main linked list corresponding to the main table; wherein the main linked list is a storage structure with table fields in the main table as nodes;
[0029] Obtain the primary key data corresponding to the primary key constraint from the business data of the first database, and assign values to the primary key constraints in the main linked list according to the primary key data;
[0030] From the business data of the first database, obtain the main table data corresponding to the table fields and primary key constraints in the main table, and assign values to the table fields in the linked list corresponding to the main table based on the main table data;
[0031] Create a linked list corresponding to the sub-table; wherein the linked list is a storage structure with the table fields in the sub-table as nodes;
[0032] The foreign key data corresponding to the foreign key constraint is obtained from the first database, and the foreign key constraint in the secondary linked list is assigned a value according to the foreign key data, so that the primary linked list and the secondary linked list are associated through the primary key constraint and the foreign key constraint;
[0033] From the business data of the first database, obtain the sub-table data corresponding to the table fields and foreign key constraints in the sub-table, and assign values to the table fields in the sub-linked list according to the sub-table data;
[0034] The main linked list and the secondary linked list are integrated to obtain the information linked list. The main table data corresponding to a primary key constraint in the information linked list, and the secondary table data corresponding to the foreign key constraint associated with the primary key constraint, are used as business data in the information linked list.
[0035] In the above scheme, converting the information linked list containing business data into a test script includes:
[0036] If it is confirmed that the number of business data in the information chain has reached the submission number, the information chain containing the business data will be uploaded to the preset test database.
[0037] If it is confirmed that the number of business data in the information chain in the test database reaches the test quantity, then the information chain in the test database is converted into the test script.
[0038] Secondly, this application provides a test script generation device, comprising: an input module, an information table module, and a script generation module; the input module is connected to a test environment, the information table module is connected to the input module, and the script generation module is connected to the information table module;
[0039] The input module is used to receive a test request sent by the test environment; wherein the test request is used to instruct the generation of a test script; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment for software testing, and data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for the software testing.
[0040] The information table module is used to create a category table according to the data type, and insert the data characteristics of the data type into the category table to obtain the information table;
[0041] The script generation module is used to create an information linked list based on the information table, insert business data from the database corresponding to the data source information into the information linked list, and convert the information linked list containing the business data into a test script; wherein, the test script is used to perform software testing in the test environment; the business data in the test script is test data used for software testing in the test environment.
[0042] Thirdly, this application provides a computer device, including: a processor and a memory communicatively connected to the processor;
[0043] The memory stores computer-executed instructions;
[0044] The processor executes computer execution instructions stored in the memory to implement the test script generation method as described above.
[0045] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the above-described test script generation method.
[0046] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described test script generation method.
[0047] This application provides a test script generation method, apparatus, computer device, storage medium, and product. By receiving test requests sent by a test environment and creating a category table according to the data types, and inserting the data characteristics of the data types into the category table to obtain an information table, it realizes the construction of an information table describing the data required for software testing in the test environment based on the test requirements of different test environments.
[0048] By creating an information linked list based on the information table, inserting business data from the database corresponding to the data source information into the information linked list, and converting the information linked list containing the business data into a test script, the technical effect of automatically generating test scripts for software testing in this test environment is achieved. This avoids the current problem of low test script generation efficiency caused by manually collecting business data from different test environments and manually entering the business data into the test template, and can meet the needs of software testing scenarios that require a large amount of test data. Attached Figure Description
[0049] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0050] Figure 1This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0051] Figure 2 A flowchart of Embodiment 1 of a test script generation method provided in this application;
[0052] Figure 3 A flowchart of Embodiment 2 of a test script generation method provided in this application;
[0053] Figure 4 A flowchart of Embodiment 3 of a test script generation method provided in this application;
[0054] Figure 5 This is a schematic diagram of a program module for a test script generation device provided by the present invention;
[0055] Figure 6 This is a schematic diagram of the hardware structure of the computer device in the computer device of the present invention.
[0056] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0057] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0058] Please see Figure 1 In a specific application scenario of this application, a server 2 with a test script generation method is connected to a test environment 3. The server 2 receives a test request sent by the test environment 3. The test request is used to instruct the generation of a test script. The test request includes test requirement information and data source information. The test requirement information describes at least one type of data required by the test environment 3 for software testing, as well as data characteristics in at least one dimension of the data type. The data source information represents a database 4 that stores business data required for software testing.
[0059] Server 2 creates a category table based on the data type, and inserts the data characteristics of the data type into the category table to obtain the information table;
[0060] Server 2 creates an information linked list based on the information table, inserts the business data from database 4 corresponding to the data source information into the information linked list, and converts the information linked list containing the business data into a test script. The test script is used for software testing in test environment 3; the business data in the test script is the test data used for software testing in test environment 3. Server 2 is connected to test server 31 in test environment 3, and test server 31 is the test target in test environment 3. Server 2 is also connected to test database 32 in test environment 33, and test database 32 is used to store the test scripts.
[0061] The method for generating test scripts provided in this application is intended to solve the above-mentioned technical problems in the prior art.
[0062] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0063] Example 1:
[0064] Please see Figure 2 This application provides a test script generation method, including:
[0065] S101: Receive a test request sent by the test environment; wherein the test request is used to instruct the generation of test scripts; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment to perform software testing, as well as data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for performing software testing.
[0066] In this example, the test environment refers to the collective computer hardware, software, network equipment, and historical data necessary to complete software testing. Test requests are issued by the test server within the test environment, which includes computer hardware, software, and network equipment.
[0067] Data types describe the categories of information required by the test environment during testing, for example:
[0068] Data characteristics describe the metadata of each data unit under the information category corresponding to the data type.
[0069] For example, the personnel data in a human resources management system needs to include the following data types:
[0070] Personnel basic information, personnel job title and rank information, personnel job title and rank hierarchy information, personnel education information
[0071] The data characteristics in the basic personnel information include: name, gender, and age.
[0072] The data characteristics of personnel position and rank information include: position and rank;
[0073] The data characteristics of personnel job title and rank hierarchy information include: job title hierarchy and rank hierarchy;
[0074] The data characteristics of personnel education information include: academic qualifications, academic degree, and graduating institution.
[0075] Data source information represents a database that stores business data required for software testing.
[0076] If the test environment needs to change the business data for testing, only the data source information needs to be modified. Similarly, if business data from one database needs to be used for software testing in other test environments, only the data source information in those other test environments needs to be modified. Therefore, to address the need to unify test data across multiple test environments, the same test data can be quickly created in different databases simply by modifying the configuration.
[0077] In summary, this technology achieves the effect of mapping multiple data sources between databases and multiple test environments according to requirements, expanding the scope of business data acquisition for test environments and the types of test environments for software testing based on business data.
[0078] For example, / / Data source information for test environment 1:
[0079] mm.hikari.jdbc.driver.class=com.oscar.Driver
[0080] mm.hikari.jdbc.url=jdbc:oscar: / / 01.001.01.01:2003 / OSRDB
[0081] / / Data source information for test environment 2:
[0082] mm.hikari.jdbc.driver.class=com.oscar.Driver
[0083] mm.hikari.jdbc.url=jdbc:oscar: / / 01.001.01.01:2003 / OSRDB
[0084] / / Test environment N data source information:
[0085] mm.hikari.jdbc.driver.class=com.oscar.Driver
[0086] mm.hikari.jdbc.url=jdbc:oscar: / / 01.001.01.01:2003 / OSRDB
[0087] In this embodiment, an Excel-formatted data table is used to maintain the business data in the database, so that the client can adjust and modify the business data. Therefore, the flexible functions of the information editor can be effectively utilized, and only the information file needs to be modified without modifying the code and tools.
[0088] Software testing is a process based on test scripts used to assess the correctness, integrity, security, and quality of software. A test script is a series of instructions for a specific test that can be executed by automated testing tools. Software testing includes user interface testing, functional testing, performance testing, security testing, and documentation testing.
[0089] S102: Create a category table based on the data type, and insert the data characteristics of the data type into the category table to obtain the information table.
[0090] In a preferred embodiment, a category table is created based on data categories, and data characteristics of the data categories are inserted into the category table to obtain an information table, including:
[0091] Create an empty table and use the data category as the title information of the empty table to convert the empty table into a category table;
[0092] Obtain the data characteristics of the data categories, insert the data characteristics into the category table, make the data characteristics table fields of the category table, and convert the category table into an information table.
[0093] In this example, the tables required for testing are determined based on the data type, and the fields to be inserted into each table are determined based on the data characteristics to ensure that business data can be automatically retrieved from the database later. Therefore, after clearly analyzing the data requirements, it is necessary to analyze which related tables are involved in data insertion and the relationships between these tables based on the conditions that the test data needs to meet and the design of the business system database tables.
[0094] In a preferred embodiment, after inserting the data characteristics of the data types into the category table to obtain the information table, the method further includes:
[0095] The main category is determined based on the relationships between data types. The information table corresponding to the main category is set as the main table, and the other information tables in the information table are set as subordinate tables. The relationship is the dependency between two or more data types described in the test requirements information. The main category is the dependent of all other data types in the relationship.
[0096] Use the identifier information in the main table as the primary key constraint of the main table, and use the identifier information as the foreign key constraint of the subordinate table in the information table; where the identifier information is a table field in the main table that can serve as a unique identifier for business data; the primary key constraint is used to define the uniqueness of data rows in the main table; the foreign key constraint is a table field whose content is consistent with the primary key constraint, and the foreign key constraint is used to associate the main table and the subordinate table.
[0097] In this example, the identification information can be a personnel ID. Primary key constraints and foreign key constraints are generated based on the personnel ID, and the main table and the subordinate table are associated through the primary key constraints and foreign key constraints. This ensures that when retrieving business data from the database later, the data corresponding to the fields in the subordinate table will not be missing due to the association between the main table and the subordinate table, thus ensuring the integrity and comprehensiveness of the business data retrieved later.
[0098] For example, a category table is created based on the data type, and the data characteristics of the data type are inserted into the category table to obtain the information table, which includes: personnel basic information table T_PERSON_DTPT, personnel job title and grade table T_PERSON_DUTY_DTPT_REL, job title and grade hierarchy table T_PERSON_POST_DTPT_REL, and personnel education status table T_PERSON_HIGH_EDU_DTPT.
[0099] Based on the relationships between the tables above, the Personnel Basic Information table, which contains Personnel ID (PERSON_ID), is the primary table, with PERSON_ID as its primary key constraint. The other three tables are secondary tables, each with PERSON_ID as its foreign key constraint. This is because, based on the unique PERSON_ID, a single row of PERSON_ID data in the Basic Information table represents a person's basic information data; one or more rows of records corresponding to PERSON_ID in the Job Title / Rank and Job Title / Rank Hierarchy tables represent the same person's job title / rank information; and one or more records in the Education Information table represent the same person's education information.
[0100] S103: Create an information linked list based on the information table, insert the business data from the database corresponding to the data source information into the information linked list, and convert the information linked list with the inserted business data into a test script; wherein, the test script is used to perform software testing in the test environment; the business data in the test script is the test data used to perform software testing in the test environment.
[0101] In this example, the information linked list is a non-contiguous, non-sequential storage structure in physical storage units. The logical order of data elements is achieved through the linking order of pointers within the linked list. The linked list consists of a series of nodes (each element in the linked list is called a node), which can be dynamically generated at runtime. By constructing the information linked list, the technical effect of automatically inserting business data from the database into the information linked list can be achieved.
[0102] In a preferred embodiment, before creating the information linked list based on the information table, the method further includes:
[0103] Create a test transaction and configure the number of tests and the number of commits within it. Starting the test transaction creates an information list based on the information table, inserting the business data from the database corresponding to the data source information into the information list. Committing the test transaction converts the information list containing the inserted business data into a test script. The number of tests defines the number of test data items in the test script. The number of commits defines the number of test data items in the test script when the test script is used for a single database insertion operation in the test environment.
[0104] In this example, by creating a test transaction and leveraging the atomicity of transactions, we create an information linked list based on an information table. We then insert business data from the database corresponding to the data source into this linked list. The linked list containing the inserted business data is then converted into a test script. This ensures that all test data in the final test script can be successfully applied in software testing. Atomicity means that a transaction is an indivisible unit of work; the operations within a transaction either all succeed or all fail. For example, SQL statements within the same transaction must either all execute successfully or all fail.
[0105] In a preferred embodiment, an information linked list is created based on the information table, and business data from the database corresponding to the data source information is inserted into the information linked list, including:
[0106] Set the database corresponding to the data source information as the first database;
[0107] Create a main linked list corresponding to the main table; the main linked list is a storage structure with the table fields in the main table as nodes;
[0108] Retrieve the primary key data corresponding to the primary key constraint from the business data in the first database, and assign values to the primary key constraints in the main linked list based on the primary key data;
[0109] Retrieve the main table data corresponding to the table fields and primary key constraints in the main table from the business data of the first database, and assign values to the table fields in the linked list corresponding to the main table based on the main table data;
[0110] Create a linked list corresponding to the primary table; where the linked list is a storage structure with the table fields in the primary table as nodes;
[0111] Retrieve the foreign key data corresponding to the foreign key constraint from the first database, assign values to the foreign key constraints in the secondary linked list based on the foreign key data, so that the primary linked list and the secondary linked list are associated through primary key constraints and foreign key constraints;
[0112] Retrieve the data of the dependent table corresponding to the table fields and foreign key constraints in the dependent table from the business data of the first database, and assign values to the table fields in the dependent linked list based on the data of the dependent table;
[0113] The main linked list and the secondary linked list are integrated to obtain the information linked list. The main table data corresponding to a primary key constraint in the information linked list, and the secondary table data corresponding to a foreign key constraint associated with a primary key constraint, are used as business data in the information linked list.
[0114] In this example, primary key constraints and foreign key constraints are used to link the main linked list and the secondary linked list. The main table data, corresponding to the table fields and primary key constraints in the main table, is retrieved from the business data in the first database. Values are then assigned to the table fields in the corresponding linked list based on the main table data. Similarly, secondary table data, corresponding to the table fields and foreign key constraints in the secondary table, is retrieved from the business data in the first database. Values are then assigned to the table fields in the secondary linked list based on the secondary table data. This process yields the business data corresponding to the primary key data, achieving the technical effect of automatically extracting the required business data from the database.
[0115] For example, / / Create a new linked list of basic personnel information data
[0116] personInfoMap=new LinkedHashMap<>();
[0117] / / Assign a value to the personnel ID
[0118] personInfoMap.put("PERSON_ID","TEST_d124c434b8cbf2dd");
[0119] / / Assign values to personnel's ID card numbers
[0120] personInfoMap.put("CERT_NO","110110199010171234");
[0121] / / Assign values to personnel names
[0122] personInfoMap.put("NAME","Zhang Xiaosan");
[0123] / / Assign values to personnel's gender, etc.
[0124] / / Create a new linked list of personnel job title and rank information
[0125] dutyInfoMap=new LinkedHashMap<>();
[0126] / / Assign a value to the job title / rank ID
[0127] dutyInfoMap.put("DUTY_ID","");
[0128] / / Related Personnel Basic Information Table PERSON_ID
[0129] dutyInfoMap.put("PERSON_ID","TEST_d124c434b8cbf2dd");
[0130] / / Assign a value to the job title / rank name
[0131] dutyInfoMap.put("DUTY_NAME","Office Director");
[0132] / / Create a new linked list of personnel job title and rank information
[0133] levelInfoMap=new LinkedHashMap<>();
[0134] / / Assign values to personnel job title / rank level IDs
[0135] levelInfoMap.put("POST_ID","");
[0136] / / Related Personnel Basic Information Table PERSON_ID
[0137] levelInfoMap.put("PERSON_ID","TEST_d124c434b8cbf2dd");
[0138] / / Assign values to personnel job titles and ranks
[0139] levelInfoMap.put("POST_TYPE","1");
[0140] / / Create a new linked list of personnel education information data
[0141] eduInfoMap=new LinkedHashMap<>();
[0142] / / Assign a value to the personnel education information ID
[0143] eduInfoMap.put("ID","");
[0144] / / Related Personnel Basic Information Table PERSON_ID
[0145] eduInfoMap.put("PERSON_ID","TEST_d124c434b8cbf2dd");
[0146] / / Assign values to personnel's educational qualifications
[0147] eduInfoMap.put("EDU_CODE_HIGH","2A");
[0148] In a preferred embodiment, converting the information linked list containing business data into a test script includes:
[0149] If the number of business data in the information chain reaches the submission limit, the information chain containing the business data will be uploaded to the preset test database.
[0150] If it is confirmed that the number of business data in the information linked list in the test database has reached the test quantity, then the information linked list in the test database will be converted into a test script.
[0151] In this example, by setting the `batch_count` value in the test transaction as the commit count, and using the `getExecutor()` function, the technical effect of batch inserting business data into the information linked list is achieved. For example, `Transaction.getExecutor().executeBatch(personInfoInsert, batchPersonData)`. Therefore, by batch inserting business data into the information linked list and only committing it to the test database when the number of business data entries reaches the commit count, the communication burden on the test database due to frequent commits is avoided, thus improving the efficiency of business data submission. Specifically, the `batch_count` value represents the specific amount of data to be inserted into the database in one operation. If the data volume is greater than 500, the database insertion operation is performed every 500 data entries, avoiding excessive database resource consumption by performing an insertion operation for each person's data entry, and improving data insertion efficiency.
[0152] In this embodiment, the test database is a database connected to the test server in the test environment and used to store test scripts; or a database connected to the test server in the test environment and used to store test scripts.
[0153] By setting the count value as the number of tests in the test transaction, the technical effect of determining the number of tests in the test script according to requirements can be achieved.
[0154] Example 2:
[0155] Please see Figure 3 This application provides a test script generation method, including:
[0156] S201: Receive a test request sent by the test environment; wherein the test request is used to instruct the generation of test scripts; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment to perform software testing, as well as data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for performing software testing.
[0157] This step is the same as S101 in Example 1, so it will not be described again here.
[0158] S202: Create a category table based on the data type, and insert the data characteristics of the data type into the category table to obtain the information table.
[0159] This step is the same as S102 in Example 1, so it will not be described again here.
[0160] S203: Create an information linked list based on the information table, insert the business data from the database corresponding to the data source information into the information linked list, and convert the information linked list with the inserted business data into a test script; wherein, the test script is used to perform software testing in the test environment; the business data in the test script is the test data used to perform software testing in the test environment.
[0161] This step is the same as S103 in Example 1, so it will not be described again here.
[0162] S204: If it is confirmed that the test data in the test script has reached the preset test threshold, the test script is invoked to perform basic tests in the test environment; wherein, the basic tests are tests of one or more functional points in the functional tests of software testing;
[0163] If the test script passes the basic tests, then keep the test script in the test environment;
[0164] If the test script fails the basic tests, remove the test script from the test environment.
[0165] In this example, basic testing refers to testing one or more functional points in the functional testing of software testing; a functional point refers to the software function of the test server in the test environment, and the functional points of basic testing can be selected as needed.
[0166] If the test script passes the basic test, it means that the test script can perform normal testing on the test server.
[0167] If the test script fails the basic test, it means that there is a data error in the test script and it cannot run normally on the test server, or that the basic test of the test server itself is abnormal. In this case, you only need to delete the test script from the test environment and notify the testers to repair the test script or the test server.
[0168] S205: If it is confirmed that the test script has completed the software testing of the test environment, then delete the test data in the test script to obtain an empty script.
[0169] In this example, a test identifier is added to the primary key data corresponding to the primary key constraint of the test script. For example, the test identifier "TEST_" is added to the primary key data "d124c434b8cbf2dd" corresponding to PERSON_ID, resulting in "TEST_d124c434b8cbf2dd".
[0170] When the test server in the test environment sends a test completion message, it is confirmed that the test environment has completed the software test. Then, the test data with the test identifier is deleted, and an empty script is obtained. This empty script can then be used to directly retrieve business data from the database and obtain a new test script for a new round of software testing in the test environment.
[0171] Example 3:
[0172] Please see Figure 4 This application provides a test script generation method, including:
[0173] S301: Receive a test request sent by the test environment; wherein the test request is used to instruct the generation of test scripts; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment to perform software testing, as well as data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for performing software testing.
[0174] This step is the same as S101 in Example 1, so it will not be described again here.
[0175] S302: Create a category table based on the data type, and insert the data characteristics of the data type into the category table to obtain the information table.
[0176] This step is the same as S102 in Example 1, so it will not be described again here.
[0177] S303: Create an information linked list based on the information table, insert the business data from the database corresponding to the data source information into the information linked list, and convert the information linked list with the inserted business data into a test script; wherein, the test script is used to perform software testing in the test environment; the business data in the test script is the test data used to perform software testing in the test environment.
[0178] This step is the same as S103 in Example 1, so it will not be described again here.
[0179] S304: If it is confirmed that the number of test data in the test script has not reached the test threshold, send an additional request to the test environment;
[0180] The test environment receives new data source information sent by the test environment based on the new request; the new data source information represents the database that stores the business data required for software testing, and the business data in the database corresponding to the new data source information is inserted into the test script.
[0181] In this example, a test threshold is set to determine whether the test data in the test script meets the required quantity. If the amount of test data in the test script is insufficient, business data can be retrieved from a new database by requesting the test environment to ensure the final quantity of test data, thereby ensuring the reliability of software testing.
[0182] S305: If it is confirmed that the test script has completed the software testing of the test environment, then delete the test data in the test script to obtain an empty script.
[0183] In this example, a test identifier is added to the primary key data corresponding to the primary key constraint of the test script. For example, the test identifier "TEST_" is added to the primary key data "d124c434b8cbf2dd" corresponding to PERSON_ID, resulting in "TEST_d124c434b8cbf2dd".
[0184] When the test server in the test environment sends a test completion message, it is confirmed that the test environment has completed the software test. Then, the test data with the test identifier is deleted, and an empty script is obtained. This empty script can then be used to directly retrieve business data from the database and obtain a new test script for a new round of software testing in the test environment.
[0185] Example 4:
[0186] Please see Figure 5 This application provides a test script generation device 1, including: an input module 11, an information table module 12 and a script generation module 13; the input module 11 is connected to the test environment, the information table module 12 is connected to the input module 11, and the script generation module 13 is connected to the information table module 12.
[0187] Input module 11 is used to receive test requests sent by the test environment; wherein, the test request is used to instruct the generation of test scripts; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment to perform software testing, as well as data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for performing software testing.
[0188] Information table module 12 is used to create a category table based on the data type, and insert the data characteristics of the data type into the category table to obtain the information table;
[0189] The script generation module 13 is used to create an information linked list based on the information table, insert business data from the database corresponding to the data source information into the information linked list, and convert the information linked list with inserted business data into a test script. The test script is used to perform software testing in the test environment. The business data in the test script is test data used for software testing in the test environment.
[0190] Optionally, the test script generation device 1 may also include: a script management module 14;
[0191] The script management module 14 is used to call the test script to perform basic tests in the test environment if it is confirmed that the test data in the test script has reached the preset test threshold. The basic tests are tests of one or more functional points in the functional tests of software testing. If the test script passes the basic tests, the test script is kept in the test environment. If the test script fails the basic tests, the test script is deleted from the test environment.
[0192] Optionally, the test script generation device 1 may also include: a new data module 15;
[0193] The newly added data module 15 is used to send a new request to the test environment if it is confirmed that the amount of test data in the test script has not reached the test threshold; to receive the new data source information sent by the test environment according to the new request; the new data source information represents the database that stores the business data required for software testing, and to insert the business data in the database corresponding to the new data source information into the test script.
[0194] Optionally, the test script generation device 1 may also include: a data clearing module 16;
[0195] The data clearing module 16 is used to delete the test data in the test script to obtain an empty script if it is confirmed that the test script has completed the software testing of the test environment.
[0196] Example 5:
[0197] To achieve the above objectives, this application also provides a computer device 5, including: a processor and a memory communicatively connected to the processor; the memory stores computer-executed instructions;
[0198] The processor executes computer execution instructions stored in the memory to implement the aforementioned test script generation method. The components of the test script generation device can be distributed across different computer devices. Computer device 5 can be a smartphone, tablet, laptop, desktop computer, rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple application servers), etc. The computer device in this embodiment includes, but is not limited to, a memory 51 and a processor 52 that can communicate with each other via a system bus. Figure 6 As shown. It should be noted that, Figure 6 Only computer devices with components are shown; however, it should be understood that it is not required to implement all of the shown components, and more or fewer components may be implemented instead. In this embodiment, memory 51 (i.e., readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, memory 51 may be an internal storage unit of the computer device, such as the hard disk or memory of the computer device. In other embodiments, memory 51 may also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device. Of course, memory 51 may also include both internal storage units and external storage devices of the computer device. In this embodiment, memory 51 is typically used to store the operating system and various application software installed on the computer device, such as the program code of the test script generation device in Embodiment 3. In addition, the memory 51 can also be used to temporarily store various types of data that have been output or will be output. In some embodiments, the processor 52 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 52 is typically used to control the overall operation of the computer device. In this embodiment, the processor 52 is used to run program code stored in the memory 51 or process data, for example, to run a test script generation device to implement the test script generation method of the above embodiments.
[0199] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this application. It should be understood that the processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor. The memory may include high-speed RAM, and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk, or optical disk, etc.
[0200] To achieve the above objectives, this application also provides a computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, App application store, etc., which stores computer-executable instructions, and the program implements corresponding functions when executed by processor 52. The computer-readable storage medium of this embodiment is used to store computer-executable instructions for implementing the test script generation method, and when executed by processor 52, it implements the test script generation method of the above embodiment.
[0201] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0202] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.
[0203] This application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described test script generation method.
[0204] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0205] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0206] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for generating test scripts, characterized in that, include: The test environment receives a test request; wherein the test request is used to instruct the generation of a test script; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment for software testing, and data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for the software testing. A category table is created based on the data categories, and the data characteristics of the data categories are inserted into the category table to obtain an information table; An information linked list is created based on the information table. Business data from the database corresponding to the data source information is inserted into the information linked list. The information linked list containing the business data is then converted into a test script. The test script is used to perform software testing in the test environment. The business data in the test script is test data used for software testing in the test environment.
2. The test script generation method according to claim 1, characterized in that, After converting the information linked list containing business data into a test script, the method further includes: If it is confirmed that the test data in the test script reaches the preset test threshold, the test script is invoked to perform basic testing in the test environment; wherein, the basic testing is a test of one or more functional points in the functional testing of the software test; If the test script is confirmed to pass the basic test, then the test script will be retained in the test environment; If it is confirmed that the test script fails the basic test, then the test script will be removed from the test environment.
3. The test script generation method according to claim 1, characterized in that, After converting the information linked list containing business data into a test script, the method further includes: If it is confirmed that the amount of test data in the test script has not reached the test threshold, a new request is sent to the test environment; The test environment receives new data source information sent according to the new request; the new data source information represents a database that stores business data required for the software test, and the business data in the database corresponding to the new data source information is inserted into the test script.
4. The test script generation method according to any one of claims 1-3, characterized in that, After converting the information linked list containing business data into a test script, the method further includes: If it is confirmed that the test script has completed the software testing of the test environment, then the test data in the test script is deleted to obtain an empty script.
5. The test script generation method according to claim 1, characterized in that, The step of creating a category table based on the data category and inserting the data characteristics of the data category into the category table to obtain an information table includes: Create an empty table and use the data categories as the title information of the empty table, thus converting the empty table into a category table; Obtain the data characteristics of the data type, insert the data characteristics into the type table, make the data characteristics a table field of the type table, and convert the type table into the information table.
6. The test script generation method according to claim 1, characterized in that, After inserting the data features of the data types into the category table to obtain the information table, the method further includes: The main category is determined based on the relationships between the data types. The information table corresponding to the main category is set as the main table, and the other information tables in the information table besides the main table are set as subordinate tables. The relationships are the dependencies between two or more data types described in the test requirement information. The main category is the dependent of all other data types in the data type in the relationships. The identifier information in the main table is used as the primary key constraint of the main table, and the identifier information is used as the foreign key constraint of the subordinate table in the information table; wherein, the identifier information is a table field in the main table that can serve as a unique identifier for business data; the primary key constraint is used to define the uniqueness of data rows in the main table; the foreign key constraint is a table field whose content is consistent with the primary key constraint, and the foreign key constraint is used to associate the main table with the subordinate table.
7. The test script generation method according to claim 6, characterized in that, Before creating the information linked list based on the information table, the method further includes: A test transaction is created, and the number of tests and the number of commits are configured within the test transaction. The start of the test transaction is used to create an information linked list based on the information table, and to insert business data from the database corresponding to the data source information into the information linked list. The commit of the test transaction is used to convert the information linked list containing the business data into a test script. The number of tests is a numerical value defining the number of test data items in the test script. The number of commits defines the number of test data items in the test script when the test script is used for one database insertion operation in the test environment.
8. The test script generation method according to claim 7, characterized in that, The step of creating an information linked list based on the information table and inserting the business data from the database corresponding to the data source information into the information linked list includes: Set the database corresponding to the data source information as the first database; Create a main linked list corresponding to the main table; wherein the main linked list is a storage structure with table fields in the main table as nodes; Obtain the primary key data corresponding to the primary key constraint from the business data of the first database, and assign values to the primary key constraints in the main linked list according to the primary key data; From the business data of the first database, obtain the main table data corresponding to the table fields and primary key constraints in the main table, and assign values to the table fields in the linked list corresponding to the main table based on the main table data; Create a linked list corresponding to the sub-table; wherein the linked list is a storage structure with the table fields in the sub-table as nodes; The foreign key data corresponding to the foreign key constraint is obtained from the first database, and the foreign key constraint in the secondary linked list is assigned a value according to the foreign key data, so that the primary linked list and the secondary linked list are associated through the primary key constraint and the foreign key constraint; From the business data of the first database, obtain the sub-table data corresponding to the table fields and foreign key constraints in the sub-table, and assign values to the table fields in the sub-linked list according to the sub-table data; The main linked list and the secondary linked list are integrated to obtain the information linked list. The main table data corresponding to a primary key constraint in the information linked list, and the secondary table data corresponding to the foreign key constraint associated with the primary key constraint, are used as business data in the information linked list.
9. The test script generation method according to claim 8, characterized in that, The step of converting the information linked list containing business data into a test script includes: If it is confirmed that the number of business data in the information chain has reached the submission number, the information chain containing the business data will be uploaded to the preset test database. If it is confirmed that the number of business data in the information chain in the test database reaches the test quantity, then the information chain in the test database is converted into the test script.
10. A test script generation device, characterized in that, include: Input module, information table module, and script generation module; The input module is connected to the test environment, the information table module is connected to the input module, and the script generation module is connected to the information table module; The input module is used to receive a test request sent by the test environment; wherein the test request is used to instruct the generation of a test script; the test request includes test requirement information and data source information; the test requirement information describes at least one data type of data required by the test environment to perform software testing, and data characteristics in at least one dimension of the data type; the data source information represents a database that stores business data required for performing the software testing; The information table module is used to create a category table according to the data type, and insert the data characteristics of the data type into the category table to obtain the information table. The script generation module is used to create an information linked list based on the information table, insert business data from the database corresponding to the data source information into the information linked list, and convert the information linked list containing the business data into a test script; wherein, the test script is used to perform software testing in the test environment; the business data in the test script is test data used for software testing in the test environment.
11. A computer device, comprising: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the test script generation method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the test script generation method as described in any one of claims 1 to 9.
13. A computer program product comprising a computer program that, when executed by a processor, implements the test script generation method of any one of claims 1-9.
Citation Information
Patent Citations
Global service data driven automatic test method, device, equipment and medium
CN111813661A
Test case processing method and device
CN113778886A