Search

CN-115994089-B - Test script generation method, device, computer equipment, storage medium and product

CN115994089BCN 115994089 BCN115994089 BCN 115994089BCN-115994089-B

Abstract

The application provides a test script generation method, a device, computer equipment, a storage medium and a product, which comprise the steps of receiving a test request sent by a test environment, creating a class table according to data types, inserting data features of the data types into the class table to obtain an information table, creating an information linked list according to the information table, inserting service data in a database corresponding to data source information into the information linked list, and converting the information linked list inserted with the service data into the test script, wherein the test script is used for performing software test in the test environment, and the service data in the test script is the test data used for performing software test in the test environment. The application realizes the technical effects of constructing different information tables based on the test requirements of different test environments and automatically generating the test script for carrying out software test on the test environments according to the information tables.

Inventors

  • LIU HUIMIN

Assignees

  • 中国工商银行股份有限公司
  • 工银科技有限公司

Dates

Publication Date
20260508
Application Date
20221205

Claims (13)

  1. 1. A test script generation method, comprising: the method comprises the steps of receiving a test request sent by a test environment, wherein the test request is used for indicating to generate a test script, the test request comprises 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 performing software test and data characteristics in at least one dimension of the data type, and the data source information characterizes a database storing service data required by the software test; Creating a category table according to the data category, and inserting the data characteristics of the data category into the category table to obtain an information table; And creating an information linked list according to the information table, inserting service data in a database corresponding to the data source information into the information linked list, and converting the information linked list inserted with the service data into a test script, wherein the test script is used for performing software test in the test environment, and the service data in the test script is the test data used for performing software test in the test environment.
  2. 2. The test script generation method according to claim 1, wherein after the converting the linked list of information inserted with service data into a test script, the method further comprises: if the test data in the test script reach a preset test threshold, calling the test script to perform basic test in the test environment, wherein the basic test is a test of one or more functional points in the functional test of the software test; if the test script is confirmed to pass the basic test, the test script is reserved in the test environment; and if the test script is confirmed to not pass the basic test, deleting the test script from the test environment.
  3. 3. The test script generation method according to claim 1, wherein after the converting the linked list of information inserted with service data into a test script, the method further comprises: If the quantity of the test data in the test script is confirmed to not reach the test threshold, a new adding request is sent to a test environment; And the newly added data source information characterizes a database which stores service data required by the software test, and the service data in the database corresponding to the newly added data source information is inserted into the test script.
  4. 4. A test script generation method according to any one of claims 1 to 3, wherein after said converting said linked list of information into which service data is inserted into a test script, said method further comprises: and if the test script is confirmed to finish the software test on the test environment, deleting the test data in the test script to obtain an empty script.
  5. 5. The test script generation method according to claim 1, wherein creating a category table from the data category, inserting the data feature of the data category into the category table to obtain an information table, comprises: Creating an empty table, taking the data type as the title information of the empty table, and converting the empty table into a type table; And acquiring the data characteristics of the data types, inserting the data characteristics into the type table, enabling the data characteristics to serve as a table field of the type table, and enabling the type table to be converted into the information table.
  6. 6. The test script generation method of claim 1, wherein after inserting the data features of the data category into the category table to obtain an information table, the method further comprises: determining a main category according to the association relation between the data categories, setting an information table corresponding to the main category as a main table, and taking other information tables except the main table in the information table as slave tables, wherein the association relation is a dependent relation between two or more data categories described in the test requirement information; The method comprises the steps of taking identification information in a master table as a master key constraint of the master table and taking the identification information as an external key constraint of a slave table in the information table, wherein the identification information is a table field which can be used as a service data unique identification in the master table, the master key constraint is used for defining the uniqueness of a data row in the master table, the external key constraint is a table field with the content consistent with the master key constraint, and the external key constraint is used for associating the master table with the slave table.
  7. 7. The test script generation method of claim 6, wherein prior to creating an information linked list from the information table, the method further comprises: Creating test transactions, configuring test quantity and submission quantity in the test transactions, wherein the starting of the test transactions is used for creating an information linked list according to the information table, inserting service data in a database corresponding to the data source information into the information linked list, the submission of the test transactions is used for converting the information linked list inserted with the service data into a test script, the test quantity is a numerical value defining the quantity of test data in the test script, and the submission quantity is a numerical value defining the quantity of test data in the test script when the test script performs one-time warehousing operation in the test environment.
  8. 8. The method for generating test scripts according to claim 7, wherein creating an information linked list according to the information table, and inserting service data in a database corresponding to the data source information into the information linked list, includes: setting a database corresponding to the data source information as a first database; creating a main linked list corresponding to the main table, wherein the main linked list is a storage structure taking a table field in the main table as a node; Acquiring primary key data corresponding to the primary key constraint from the service data of the first database, and assigning values to the primary key constraint in the main chain table according to the primary key data; acquiring main table data corresponding to table fields in the main table and the main key constraint from service data of the first database, and assigning values to table fields in a linked list corresponding to the main table according to the main table data; creating a slave linked list corresponding to the slave table, wherein the slave linked list is a storage structure taking a table field in the slave table as a node; acquiring foreign key data corresponding to the foreign key constraint from the first database, and assigning the foreign key constraint in the slave linked list according to the foreign key data to enable the main chain table and the slave linked list to be associated through the main key constraint and the foreign key constraint; from the business data of the first database, obtaining slave table data corresponding to table fields in the slave table and the foreign key constraint, and assigning values to the table fields in the slave linked list according to the slave table data; And integrating the master chain table and the slave chain table to obtain the information chain table, and taking the master table data corresponding to one master key constraint in the information chain table and the slave table data corresponding to the external key constraint associated with the one master key constraint as one service data in the information chain table.
  9. 9. The test script generation method according to claim 8, wherein the converting the linked list of information inserted with service data into a test script comprises: If the number of the service data in the information linked list is confirmed to reach the submitted number, uploading the information linked list inserted with the service data to a preset test database; and if the number of the service data in the information linked list in the test database is confirmed to reach the test number, converting the information linked list in the test database into the test script.
  10. 10. The test script generation device is characterized by comprising an input module, an information table module and a script generation module, wherein the input module is connected with a test environment, the information table module is connected with the input module, and the script generation module is connected with the information table module; The system comprises an input module, a test script generation module and a data source module, wherein the test script generation module is used for receiving a test request sent by a test environment, the test request comprises test requirement information and data source information, the test requirement information describes at least one data type of data required by the software test of the test environment and data characteristics in at least one dimension of the data type, and the data source information characterizes a database which stores service data required by the software test; The information table module is used for creating a category table according to the data category, and inserting the data characteristics of the data category into the category table to obtain an information table; The script generation module is used for creating an information linked list according to the information table, inserting service data in a database corresponding to the data source information into the information linked list, and converting the information linked list inserted with the service data into a test script, wherein the test script is used for performing software test in the test environment, and the service data in the test script is test data used for performing software test in the test environment.
  11. 11. A computer device includes a processor, and a memory communicatively coupled to the processor; The memory stores computer-executable instructions; the processor executes computer-executable instructions stored in the memory to implement the test script generation method of any of claims 1 to 9.
  12. 12. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the test script generation method of any of claims 1 to 9.
  13. 13. A computer program product comprising a computer program which, when executed by a processor, implements the test script generation method of any of claims 1-9.

Description

Test script generation method, device, computer equipment, storage medium and product Technical Field The present application relates to communications technologies, and in particular, to a test script generating method, apparatus, computer device, storage medium, and product. Background Software Testing (English: software Testing) is a process that is described based on test scripts to facilitate the verification of the correctness, integrity, security, and quality of Software. Test script (TESTING SCRIPT), which is a series of instructions for a particular test, can be executed by an automated test tool. When facing a plurality of different test environments, the present inventors have found that the manual method of acquiring service data required by each test environment and manually inputting the service data into a test template is inefficient, and cannot meet software test scenarios requiring a large amount of test data. Disclosure of Invention The application provides a test script generation method, a device, computer equipment, a storage medium and a product, which are used for solving the problems that the current mode of obtaining a test script is low in efficiency and cannot meet the software test scene requirement of a large amount of test data. In a first aspect, the present application provides a test script generating method, including: The method comprises the steps of receiving a test request sent by a test environment, wherein the test request is used for indicating to generate a test script, the test request comprises 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, and the data source information characterizes a database storing business data required by the software testing. Creating a category table according to the data category, and inserting the data characteristics of the data category into the category table to obtain an information table; And creating an information linked list according to the information table, inserting service data in a database corresponding to the data source information into the information linked list, and converting the information linked list inserted with the service data into a test script, wherein the test script is used for performing software test in the test environment, and the service data in the test script is the test data used for performing software test in the test environment. In the above solution, after the converting the information linked list with the inserted service data into the test script, the method further includes: if the test data in the test script reach a preset test threshold, calling the test script to perform basic test in the test environment, wherein the basic test is a test of one or more functional points in the functional test of the software test; if the test script is confirmed to pass the basic test, the test script is reserved in the test environment; and if the test script is confirmed to not pass the basic test, deleting the test script from the test environment. In the above solution, after the converting the information linked list with the inserted service data into the test script, the method further includes: If the quantity of the test data in the test script is confirmed to not reach the test threshold, a new adding request is sent to a test environment; And the newly added data source information characterizes a database which stores service data required by the software test, and the service data in the database corresponding to the newly added data source information is inserted into the test script. In the above solution, after the converting the information linked list with the inserted service data into the test script, the method further includes: and if the test script is confirmed to finish the software test on the test environment, deleting the test data in the test script to obtain an empty script. In the above aspect, the creating a category table according to the data category, and inserting the data feature of the data category into the category table to obtain an information table includes: Creating an empty table, taking the data type as the title information of the empty table, and converting the empty table into a type table; And acquiring the data characteristics of the data types, inserting the data characteristics into the type table, enabling the data characteristics to serve as a table field of the type table, and enabling the type table to be converted into the information table. In the above solution, after the inserting the data features of the data types into the type table to obtain the information table, the method further includes: determining a main category according to the association relation between the data categories, setting an information table corresponding to