CN113900956A - Test case generation method and device, computer equipment and storage medium - Google Patents

Test case generation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113900956A
CN113900956A CN202111270512.6A CN202111270512A CN113900956A CN 113900956 A CN113900956 A CN 113900956A CN 202111270512 A CN202111270512 A CN 202111270512A CN 113900956 A CN113900956 A CN 113900956A
Authority
CN
China
Prior art keywords
data table
data
test
initial
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111270512.6A
Other languages
Chinese (zh)
Inventor
张宇奇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202111270512.6A priority Critical patent/CN113900956A/en
Publication of CN113900956A publication Critical patent/CN113900956A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application is applicable to the technical field of data testing, and provides a method and a device for generating a test case, computer equipment and a storage medium, wherein the method comprises the following steps: matching an initial data table from a data table base based on a test requirement, and carrying out blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table; screening the initial data table to obtain a target data table to be tested based on the data source information, generating a link based on the data table, and determining data generation logic corresponding to the target data table; and generating a test case corresponding to the target data table according to the data generation logic based on the data source information. The scheme realizes the automatic generation of the test case, and improves the test efficiency and the test automation performance.

Description

Test case generation method and device, computer equipment and storage medium
Technical Field
The present application belongs to the technical field of data testing, and in particular, to a method and an apparatus for generating a test case, a computer device, and a storage medium.
Background
The existing automation case is basically written and stored by an automation engineer through a test case editing tool. Because the cases of the automatic test are different from the cases of the black box test, each case needs to be operated precisely to each step, and the accuracy of each case is 3-10 times that of the case of the black box, the labor consumed by compiling the automatic test cases is very large. In addition, in the automatic use cases, the repeated detection types are very many, the difference points are only different detection points, and the repeated and fussy test case compiling in the process causes repeated labor of an automatic engineer and low efficiency.
Disclosure of Invention
The embodiment of the application provides a method and a device for generating a test case, computer equipment and a storage medium, and aims to solve the problems that in the prior art, repeated labor of an automatic engineer and low efficiency are caused by repeated and fussy test case compiling.
A first aspect of an embodiment of the present application provides a method for generating a test case, including:
matching an initial data table from a data table base based on a test requirement, and carrying out blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table;
screening the initial data table to obtain a target data table to be tested based on the data source information, generating a link based on the data table, and determining data generation logic corresponding to the target data table;
and generating a test case corresponding to the target data table according to the data generation logic based on the data source information.
Optionally, the performing of blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table includes:
acquiring a script file corresponding to the initial data table, wherein a data processing script for generating the data table is recorded in the script file;
analyzing the script file, and extracting to obtain a data processing object contained in the data processing script and a data processing operation key character corresponding to the data processing object;
determining an upstream data table having a blood relationship with the initial data table based on the data processing operation key characters to obtain a data table generation link containing a data hierarchy calling relationship between the upstream data tables;
and determining upstream source data corresponding to the data in the initial data table based on the data processing object to obtain data source information containing the upstream source data.
Optionally, the determining, based on the data processing operation key character, an upstream data table having a blood relationship with the initial data table to obtain a data table generation link including a data hierarchy call relationship between the upstream data tables includes:
based on the data processing operation key characters, when a first-level upstream data table corresponding to the initial data table is determined, judging whether the initial data table corresponds to a second-level upstream data table or not based on a script file corresponding to the first-level upstream data table until a target-level data table is reached;
and acquiring a data table generation link corresponding to the initial data table based on a data hierarchy calling relationship from the first-hierarchy upstream data table to the target-hierarchy data table.
Optionally, the generating a test case corresponding to the target data table according to the data generation logic based on the data source information includes:
determining upstream source data corresponding to the target data table based on the data source information;
matching a data processing syntax structure corresponding to the data generation logic based on a test language corresponding to the test case;
and embedding the upstream source data into the data processing syntax structure, generating a test execution statement, and obtaining a test case containing the test execution statement.
Optionally, after generating the test case corresponding to the target data table according to the data generation logic based on the data source information, the method further includes:
executing the test case to obtain an execution result;
comparing the execution result with the data content of the target data table to obtain a comparison result;
on the basis of the comparison result, when the execution result is determined to be consistent with the data content of the target data table, determining that the test result is a pass;
and based on the comparison result, when the execution result is determined to be inconsistent with the data content of the target data table, determining that the test result is not passed.
Optionally, the determining, based on the comparison result, that the test result does not pass when it is determined that the execution result is inconsistent with the data content of the target data table, further includes:
locating a difference data item from the execution result that is inconsistent with the data content of the target data table;
generating a link by combining the data table based on the differential data item, and tracing to obtain a problem node corresponding to the differential data item;
and performing problem repairing based on the problem node.
Optionally, the matching the initial data table from the data table library based on the test requirement includes:
analyzing a test requirement document, and extracting test key information from the test requirement document;
and matching the initial data table from the data table base based on the test key information.
A second aspect of the embodiments of the present application provides a device for generating a test case, including:
the analysis module is used for matching an initial data table from a data table base based on test requirements, and performing blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table;
the acquisition module is used for screening the initial data table to obtain a target data table to be tested based on the data source information, generating a link based on the data table and determining data generation logic corresponding to the target data table;
and the generating module is used for generating a test case corresponding to the target data table according to the data generating logic based on the data source information.
A third aspect of embodiments of the present application provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method according to the first aspect when executing the computer program.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, which, when executed by a processor, performs the steps of the method according to the first aspect.
A fifth aspect of the present application provides a computer program product, which, when run on a terminal, causes the terminal to perform the steps of the method of the first aspect described above.
Therefore, in the embodiment of the application, the tracing and the automatic combing of the data table generation link are introduced, the target data table forming test objects are obtained by screening the initial data table of the document meeting the test requirements, the data generation logic and the data source information corresponding to the target data table are obtained, the test cases corresponding to the target data table are generated based on the data generation logic and the data source information, the automatic generation of the test cases is realized, and the test efficiency and the test automation performance are improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a first flowchart of a method for generating a test case according to an embodiment of the present application;
fig. 2 is a second flowchart of a method for generating a test case according to an embodiment of the present application;
fig. 3 is a structural diagram of a test case generation apparatus according to an embodiment of the present application;
fig. 4 is a block diagram of a computer device according to an embodiment of the present disclosure.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
In particular implementations, the terminals described in embodiments of the present application include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers having touch sensitive surfaces (e.g., touch screen displays and/or touch pads). It should also be understood that in some embodiments, the device is not a portable communication device, but is a desktop computer having a touch-sensitive surface (e.g., a touch screen display and/or touchpad).
In the discussion that follows, a terminal that includes a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and/or joystick.
The terminal supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disc burning application, a spreadsheet application, a gaming application, a telephone application, a video conferencing application, an email application, an instant messaging application, an exercise support application, a photo management application, a digital camera application, a web browsing application, a digital music player application, and/or a digital video player application.
Various applications that may be executed on the terminal may use at least one common physical user interface device, such as a touch-sensitive surface. One or more functions of the touch-sensitive surface and corresponding information displayed on the terminal can be adjusted and/or changed between applications and/or within respective applications. In this way, a common physical architecture (e.g., touch-sensitive surface) of the terminal can support various applications with user interfaces that are intuitive and transparent to the user.
It should be understood that, the sequence numbers of the steps in this embodiment do not mean the execution sequence, and the execution sequence of each process should be determined by the function and the inherent logic of the process, and should not constitute any limitation to the implementation process of the embodiment of the present application.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
Referring to fig. 1, fig. 1 is a first flowchart of a method for generating a test case according to an embodiment of the present application. As shown in fig. 1, a method for generating a test case includes the following steps:
step 101, based on the test requirement, matching the initial data table from the data table database, and performing blood relationship analysis on the initial data table to obtain data table generation link and data source information corresponding to the initial data table.
The data table library includes a plurality of data tables, and the data content in the data tables is likely to be the original data content, and the data tables of the original data content are usually the data tables in the pasting layer. Or the data content is the data content after data integration based on other data, for example, the data content is the data content obtained after data screening, data cleaning and data merging based on the data in a plurality of data tables.
The initial data table is not a data table in the source layer, and is specifically a data table generated based on an upstream data table and upstream source data corresponding to the upstream data table.
The test requirements inform the project what needs to be tested currently. Based on the test requirements, it is decided how to test, the test time, how many people are needed, the environment of the test, the skills needed in the test, the tools and the corresponding background knowledge, the risks that may be encountered in the test, etc.
In the whole life cycle of data, various relationships can be formed between data, and these relationships are similar to the relationship of blood relationship of human, so that they are called the relationship of blood relationship of data. The data relationship is hierarchical, in some databases, especially large databases, massive data tables are stored, and each table has a plurality of fields, which are organically combined together to form a complete data relationship.
In this step, after the initial data table is matched from the data table database based on the test requirement, the blood relationship analysis is performed on the initial data table to obtain the data table generation link and the data source information corresponding to the initial data table, so as to realize the automatic combing of the data table link.
When the initial data table is matched from the data table base based on the test requirement, the test requirement document is specifically analyzed, the test key information is extracted from the test requirement document, and the initial data table is matched from the data table base based on the test key information.
The test requirement document includes test requirements, specifically including contents of test objects, test methods, test languages, test result determination requirements, and the like.
The analysis of the test requirement document may be specifically implemented by using a Natural Language Processing (NPL) method. The NLP is an important direction in the fields of computer science and artificial intelligence, can realize language text analysis, and can realize information extraction by combining sentence semantics in a text. Or, the key information of the test requirement document is distinguished and extracted by utilizing the pretrained convolutional neural network.
The process may be based on artificial intelligence techniques to obtain and process relevant data. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The extracted test key information is specifically related description information of a test object.
For example, there are many data tables in a large database, and the current testing requirement is to require data table information verification for individual users with over 100 million fixed funds. Then the key information of the test is analyzed and extracted to be fixed fund, more than 100 ten thousand and individual user based on the test requirement.
Based on the extracted test key information, the current test object can be known to be a data table containing data of more than 100 thousands of fixed funds and containing personal user data attribute data.
After the test key information is obtained by analyzing from the test requirement document, the data table matched with the test key information can be searched from a plurality of data tables in the large database based on the test key information to be used as an initial data table.
Specifically, each data table has information such as its data table name, data summary, etc., so that it can be used to match with the test key information at the parsing site.
However, because the number of data tables in the large database is large, and the similarity between table names and table data digests may be large, a plurality of initial data tables obtained by matching may be obtained, and further screening and determination are required.
Further, in the process of analyzing the blood relationship of the initial data table to obtain a data table generation link, all scripts under the directory can be traversed by python, the data tables related in the scripts are automatically identified, all tables and attempts of non-sub-query and non-temporary tables after from are analyzed by combining the structure of sql, the attempts are output, the attempted operation is repeatedly traversed until the entity table is traced, when the entity table is traced back, an upstream table is confirmed to be found, and the result is output according to the hierarchical relationship to obtain the data table generation link.
Or performing blood-cause relationship analysis on the initial data table to obtain a data table link, wherein in the process of obtaining the data table link, the source tracing to the ODS layer, namely the source pasting layer, specifically, the tracing process needs to continuously repeat the upstream table tracing operation, the upstream table is repeatedly traversed until the ODS layer table is traced, and when the ODS layer table is traced, the result is output according to the hierarchical relationship to obtain a data table generation link.
And 102, screening the initial data table to obtain a target data table to be tested based on the data source information, generating a link based on the data table, and determining data generation logic corresponding to the target data table.
During the analysis of the relationship between the blood relationship and the initial data tables, it is obtained which data table the data of each initial data table originates from, and the data processing logical relationship with the upstream data table.
Therefore, the data source information of each initial data table can be determined through the data table generation link, the data contents in different initial data tables are verified by means of the data source information, so that the initial data tables are further accurately screened on the data content level, and the screened data tables are used as target data tables to be tested.
For example, based on the extracted test key information, it is known that the current test object is a data table containing more than 100 ten thousand of fixed funds and containing personal user data attribute data as an initial data table.
Correspondingly, after the blood relationship analysis is performed on each selected initial data table, it is known that the data source information of the first initial data table indicates that the upstream source data of the first data table is data in an expired upstream data table, or the data source information of the first initial data table indicates that the upstream source data of the first data table is data in data tables under other tasks, the first data table is removed from the initial data table, and the remaining initial data table after the removal is formed into a target data table to be tested.
Further, when a link is generated based on the data table and the data generation logic corresponding to the target data table is determined, specifically, based on the hierarchical relationship and the data reference relationship between the data tables in the data table generation link, the processing relationship and the processing means for the data in each data table of the data table generation link in the generation process of the target data table can be obtained, so as to obtain the data generation logic.
And 103, generating a test case corresponding to the target data table according to the data generation logic based on the data source information.
And obtaining the original data for generating the data table based on the data source information. The test case is specifically based on original data, data generation logic is adopted, and sql statements are organized to be used as test execution statements of the test case.
Specifically, in an embodiment, the generating a test case corresponding to the target data table according to the data generation logic based on the data source information includes:
determining upstream source data corresponding to the target data table based on the data source information; matching a data processing syntax structure corresponding to the data generation logic based on a test language corresponding to the test case; and embedding the upstream source data into a data processing syntax structure, generating a test execution statement, and obtaining a test case containing the test execution statement.
After data source information and data generation logic corresponding to each initial data table are determined based on the data table link, and target data tables to be tested are screened out from the initial data tables, what original data of the target data tables are obtained through processing can be known based on the data source information, and based on the original data, a test case corresponding to the current target data table can be organized and generated according to the data generation logic.
In the embodiment of the application, the tracing and automatic combing of the data table generation link are introduced, the target data table is obtained by screening the initial data table meeting the test requirement document to form a test object, the data generation logic and the data source information corresponding to the target data table are obtained, and the test case corresponding to the target data table is generated based on the data generation logic and the data source information, so that the automatic generation of the test case is realized, and the test efficiency and the test automation performance are improved.
Further, after generating the test case corresponding to the target data table according to the data generation logic based on the data source information, the method further includes:
executing the test case to obtain an execution result; comparing the execution result with the data content of the target data table to obtain a comparison result; based on the comparison result, when the execution result is determined to be consistent with the data content of the target data table, determining that the test result is passed; and based on the comparison result, when the execution result is determined to be inconsistent with the data content of the target data table, determining that the test result is not passed.
The test purpose of the generation of the test case is specifically, for example, performing script running performance test, messy code verification, data loading mode verification, primary key rationality verification and the like on the target data table.
After the test case is executed, the obtained execution result is compared with the data content of the target data table, and the service logic verification and the data processing result verification of the target data table can be realized.
Specifically, when the execution result is compared with the target data table in terms of data content to obtain a comparison result, a temporary table with the same format as the target data table may be created; and inserting an execution result obtained by executing the test case into the temporary table, and comparing the data values of corresponding positions in the same format of the temporary table and the target data table to obtain a comparison result.
Further, based on the comparison result, when it is determined that the execution result is inconsistent with the data content of the target data table, determining that the test result does not pass, further comprising:
locating a difference data item inconsistent with the data content of the target data table from the execution result; generating a link by combining a data table based on the difference data item, and tracing to obtain a problem node corresponding to the difference data item; based on the problem node, problem repair is performed.
Specifically, after the difference data item is obtained, a data processing logic associated with the current difference data item in the link may be generated based on the data table corresponding to the target data table, the related data item in the upstream data table and the data processing logic associated with the related data item are found based on the data processing logic, and each time the related data item in the upstream data table of one layer is found, the related data item is compared with the corresponding data processing result obtained from different data processing nodes in the test case until a problem node causing the deviation is found.
The bug of the problem node may be a code input error when a developer writes a code, for example, an unnecessary punctuation or spelling error is added, and after the problem node is found, the related problem can be repaired.
The processing process greatly avoids repeated and complicated test case writing, and improves the test efficiency and bug repair efficiency.
The embodiment of the application also provides different implementation modes of the test case generation method.
Referring to fig. 2, fig. 2 is a second flowchart of a method for generating a test case according to an embodiment of the present application. As shown in fig. 2, a method for generating a test case includes the following steps:
step 201, based on the test requirement, matching the initial data table from the data table database, and obtaining the script file corresponding to the initial data table.
The script file records therein a data processing script for generating a data table.
The script file is, for example, a job file. Specifically, the different data tables correspond to the jobfile. The generation of one data table needs to be realized by executing a jobfile, the script content in the jobfile records the data processing operation corresponding to the data in the current data table, the script content in the jobfile is executed, and the data table is obtained after the script is executed.
Step 202, analyzing the script file, and extracting a data processing object contained in the data processing script and a data processing operation key character corresponding to the data processing object.
Step 203, based on the key characters of the data processing operation, determining an upstream data table having a blood relationship with the initial data table, and obtaining a data table generation link containing a data hierarchy calling relationship between the upstream data tables.
The data processing operation key characters are, for example, "from", "select", "where", "insert", and the like.
Take the script file as a job file as an example. For example, the script in the jobfile is:
Insert into target_table(Name,Max_price)
(
SELECT temp.name,max(temp.price)as price
FROM(
SELECT user.name,order.price FROM user,order WHERE user.id=order.uid)as temp GROUP BY temp.name);
then we can know that the data table to be generated by the current script file is target _ table, and the data of the data table is from the user table and the order table. Name field is from user, max _ price is from the maximum value after order.
Therefore, all the data tables can be analyzed based on the corresponding script files to obtain the upstream table corresponding to the current data table, and even the data tables are traced back to the source layer to obtain the data source, so that the data table link corresponding to the blood relationship of the data is obtained.
Further, in order to realize the blood relationship analysis by means of the jobfile, script management can be performed on the jobfile.
The job files are uniformly managed in a specified directory, and the directory hierarchy needs to meet the requirements and cannot be changed randomly.
The script code specification in the jobfile may be: the script job naming needs unified rules, for example, naming according to the name of the target table, if the target table is PA _ T _ detail _ TX _ EOD, the script is named PA _ T _ detail _ TX _ eod.sql, if there are multiple target table scripts, naming can be performed by adding name suffix numbers, for example, naming PA _ T _ detail _ TX _ EOD _1.sql, PA _ T _ detail _ TX _ EOD _2. sql.
So as to correctly trace the data table links corresponding to different data tables based on the script in the jobfile.
In a specific implementation, the determining, based on the data processing operation key character, an upstream data table having a blood relationship with the initial data table to obtain a data table generation link including a data hierarchy call relationship between the upstream data tables includes:
based on the data processing operation key characters, when a first-level upstream data table corresponding to the initial data table is determined, judging whether the initial data table corresponds to a second-level upstream data table or not based on a script file corresponding to the first-level upstream data table until a target-level data table is reached;
and acquiring a data table generation link corresponding to the initial data table based on a data hierarchy calling relationship from the first-hierarchy upstream data table to the target-hierarchy data table.
The target level data table is, for example, a source layer data table or a data table with a set number of levels, for example, a tenth level, so as to limit the level tracing operation of the data table generation link, and avoid the excessive data volume.
Specifically, the method, based on the script file corresponding to the first-level upstream data table, determines whether the initial data table corresponds to the second-level upstream data table until the target-level data table is reached, specifically:
analyzing a script file corresponding to a first-level upstream data table, extracting a data processing object contained in a data processing script and data processing operation key characters corresponding to the data processing object, determining an upstream data table having a blood relationship with the first-level upstream data table as a second-level upstream data table corresponding to a target data table based on the data processing operation key characters, and determining that the target-level data table is reached when the second-level upstream data table is judged to be a source layer data table or a level corresponding to the second-level upstream data table reaches a threshold value, so as to obtain a data table generation link containing a data level calling relationship between the second-level upstream data table and the first-level upstream data table. When the second-level upstream data table is judged not to be the source layer data table or the level corresponding to the second-level upstream data table does not reach the threshold value, whether the initial data table corresponds to the third-level upstream data table or not is continuously judged on the basis of the script file corresponding to the second-level upstream data table (the processing process is the same as that of judging whether the initial data table corresponds to the second-level upstream data table or not on the basis of the script file corresponding to the first-level upstream data table), and the like until the target-level data table is reached.
And then, acquiring a data table generation link corresponding to the initial data table based on the data level calling relationship from the first-level upstream data table to the target-level data table.
Step 204, determining the upstream source data corresponding to the data in the initial data table based on the data processing object, and obtaining data source information including the upstream source data.
Because the data processing object in the script file corresponds to the key character of the data processing operation, and the data processing object is formed into a target processing object matched with the key character of the data processing operation, so that the data in the initial data table is generated after the data processing script containing the data processing object and the key character of the data processing operation is executed, and therefore, the upstream source data corresponding to the data in the initial data table can be obtained by tracing back the data processing object contained in the script file layer by layer upwards in the tracing back process of the data table generating link.
The process realizes blood relationship analysis on the initial data table to obtain the data table generation link and data source information corresponding to the initial data table.
Step 205, based on the data source information, a target data table to be tested is screened from the initial data table, and based on the data table generation link, a data generation logic corresponding to the target data table is determined.
The implementation process of this step is the same as that of step 102 in the foregoing embodiment, and is not described here again.
And step 206, generating a test case corresponding to the target data table according to the data generation logic based on the data source information.
The implementation process of this step is the same as the implementation process of step 103 in the foregoing embodiment, and is not described here again.
In the embodiment of the application, the data table generation link is traced and automatically sorted by means of the script file corresponding to the data table, the initial data table meeting the test requirement document is screened to obtain the target data table forming test objects, the data generation logic and the data source information corresponding to the target data table are obtained, the test cases corresponding to the target data table are generated based on the data generation logic and the data source information, the automatic generation of the test cases is realized, and the test efficiency and the test automation performance are improved.
Referring to fig. 3, fig. 3 is a block diagram of a test case generation apparatus according to an embodiment of the present application, and only a part related to the embodiment of the present application is shown for convenience of description.
The test case generation apparatus 300 includes:
the analysis module 301 is configured to match an initial data table from a data table database based on a test requirement, and perform blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table;
an obtaining module 302, configured to screen a target data table to be tested from the initial data table based on the data source information, and determine a data generation logic corresponding to the target data table based on a link generated by the data table;
a generating module 303, configured to generate a test case corresponding to the target data table according to the data generating logic based on the data source information.
Wherein, the analysis module 301 is specifically configured to:
acquiring a script file corresponding to the initial data table, wherein a data processing script for generating the data table is recorded in the script file;
analyzing the script file, and extracting to obtain a data processing object contained in the data processing script and a data processing operation key character corresponding to the data processing object;
determining an upstream data table having a blood relationship with the initial data table based on the data processing operation key characters to obtain a data table generation link containing a data hierarchy calling relationship between the upstream data tables;
and determining upstream source data corresponding to the data in the initial data table based on the data processing object to obtain data source information containing the upstream source data.
Wherein, the analysis module 301 is more specifically configured to:
on the basis of the data processing operation key characters, when a first-layer upstream data table corresponding to the initial data table is determined, judging whether the initial data table corresponds to a second-layer upstream data table or not on the basis of a script file corresponding to the first-layer upstream data table until a target-layer data table is reached;
and acquiring a data table generation link corresponding to the initial data table based on the data hierarchy calling relationship from the first-layer upstream data table to the target-layer data table.
The generation module is specifically configured to:
determining upstream source data corresponding to the target data table based on the data source information;
matching a data processing syntax structure corresponding to the data generation logic based on a test language corresponding to the test case;
and embedding the upstream source data into the data processing syntax structure, generating a test execution statement, and obtaining a test case containing the test execution statement.
The device also includes: a test module to:
executing the test case to obtain an execution result;
comparing the execution result with the data content of the target data table to obtain a comparison result;
on the basis of the comparison result, when the execution result is determined to be consistent with the data content of the target data table, determining that the test result is a pass;
and based on the comparison result, when the execution result is determined to be inconsistent with the data content of the target data table, determining that the test result is not passed.
The device also includes: a problem remediation module to:
locating a difference data item from the execution result that is inconsistent with the data content of the target data table;
generating a link by combining the data table based on the differential data item, and tracing to obtain a problem node corresponding to the differential data item;
and performing problem repairing based on the problem node.
Wherein, the analysis module is further specifically configured to:
analyzing a test requirement document, and extracting test key information from the test requirement document;
and matching the initial data table from the data table base based on the test key information.
The device for generating the test case provided by the embodiment of the application can realize each process of the embodiment of the method for generating the test case, can achieve the same technical effect, and is not repeated here to avoid repetition.
Fig. 4 is a block diagram of a computer device according to an embodiment of the present disclosure. As shown in the figure, the computer apparatus 4 of this embodiment includes: at least one processor 40 (only one shown in fig. 4), a memory 41, and a computer program 42 stored in the memory 41 and executable on the at least one processor 40, the steps of any of the various method embodiments described above being implemented when the computer program 42 is executed by the processor 40.
The computer device 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The computer device 4 may include, but is not limited to, a processor 40, a memory 41. Those skilled in the art will appreciate that fig. 4 is merely an example of a computer device 4 and is not intended to limit computer device 4 and may include more or fewer components than those shown, or some of the components may be combined, or different components, e.g., the computer device may also include input output devices, network access devices, buses, etc.
The Processor 40 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. The memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the computer device 4. The memory 41 is used for storing the computer program and other programs and data required by the computer device. The memory 41 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the above-described apparatus/terminal embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The present application realizes all or part of the processes in the method of the above embodiments, and may also be implemented by a computer program product, when the computer program product runs on a terminal, the steps in the above method embodiments may be implemented when the terminal executes the computer program product.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method for generating a test case is characterized by comprising the following steps:
matching an initial data table from a data table base based on a test requirement, and carrying out blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table;
screening the initial data table to obtain a target data table to be tested based on the data source information, generating a link based on the data table, and determining data generation logic corresponding to the target data table;
and generating a test case corresponding to the target data table according to the data generation logic based on the data source information.
2. The method of claim 1, wherein the performing a blood relationship analysis on the initial data table to obtain data table generation link and data source information corresponding to the initial data table comprises:
acquiring a script file corresponding to the initial data table, wherein a data processing script for generating the data table is recorded in the script file;
analyzing the script file, and extracting to obtain a data processing object contained in the data processing script and a data processing operation key character corresponding to the data processing object;
determining an upstream data table having a blood relationship with the initial data table based on the data processing operation key characters to obtain a data table generation link containing a data hierarchy calling relationship between the upstream data tables;
and determining upstream source data corresponding to the data in the initial data table based on the data processing object to obtain data source information containing the upstream source data.
3. The method of claim 2, wherein determining an upstream data table having a consanguinity relationship with the initial data table based on the data processing operation key characters, resulting in a data table generation link containing a data hierarchy call relationship between the upstream data tables, comprises:
based on the data processing operation key characters, when a first-level upstream data table corresponding to the initial data table is determined, judging whether the initial data table corresponds to a second-level upstream data table or not based on a script file corresponding to the first-level upstream data table until a target-level data table is reached;
and acquiring a data table generation link corresponding to the initial data table based on a data hierarchy calling relationship from the first-hierarchy upstream data table to the target-hierarchy data table.
4. The method according to claim 1, wherein generating the test case corresponding to the target data table according to the data generation logic based on the data source information includes:
determining upstream source data corresponding to the target data table based on the data source information;
matching a data processing syntax structure corresponding to the data generation logic based on a test language corresponding to the test case;
and embedding the upstream source data into the data processing syntax structure, generating a test execution statement, and obtaining a test case containing the test execution statement.
5. The method according to claim 1, wherein after generating the test case corresponding to the target data table according to the data generation logic based on the data source information, the method further comprises:
executing the test case to obtain an execution result;
comparing the execution result with the data content of the target data table to obtain a comparison result;
on the basis of the comparison result, when the execution result is determined to be consistent with the data content of the target data table, determining that the test result is a pass;
and based on the comparison result, when the execution result is determined to be inconsistent with the data content of the target data table, determining that the test result is not passed.
6. The method according to claim 5, wherein the determining that the test result is not passed when the execution result is determined to be inconsistent with the data content of the target data table based on the comparison result further comprises:
locating a difference data item from the execution result that is inconsistent with the data content of the target data table;
generating a link by combining the data table based on the differential data item, and tracing to obtain a problem node corresponding to the differential data item;
and performing problem repairing based on the problem node.
7. The method of claim 1, wherein matching the initial data table from the database of data tables based on the testing requirement comprises:
analyzing a test requirement document, and extracting test key information from the test requirement document;
and matching the initial data table from the data table base based on the test key information.
8. An apparatus for generating a test case, comprising:
the analysis module is used for matching an initial data table from a data table base based on test requirements, and performing blood relationship analysis on the initial data table to obtain a data table generation link and data source information corresponding to the initial data table;
the acquisition module is used for screening the initial data table to obtain a target data table to be tested based on the data source information, generating a link based on the data table and determining data generation logic corresponding to the target data table;
and the generating module is used for generating a test case corresponding to the target data table according to the data generating logic based on the data source information.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202111270512.6A 2021-10-29 2021-10-29 Test case generation method and device, computer equipment and storage medium Pending CN113900956A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111270512.6A CN113900956A (en) 2021-10-29 2021-10-29 Test case generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111270512.6A CN113900956A (en) 2021-10-29 2021-10-29 Test case generation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113900956A true CN113900956A (en) 2022-01-07

Family

ID=79027019

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111270512.6A Pending CN113900956A (en) 2021-10-29 2021-10-29 Test case generation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113900956A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115437966A (en) * 2022-11-03 2022-12-06 平安银行股份有限公司 Test data generation method, terminal device and computer readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115437966A (en) * 2022-11-03 2022-12-06 平安银行股份有限公司 Test data generation method, terminal device and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN110046087B (en) Non-contact test platform
CN109697162B (en) Software defect automatic detection method based on open source code library
US10664505B2 (en) Method for deducing entity relationships across corpora using cluster based dictionary vocabulary lexicon
US9536200B2 (en) Sentiment analysis of data logs
US11797607B2 (en) Method and apparatus for constructing quality evaluation model, device and storage medium
CN107357593A (en) Source code file construction method, device, electric terminal and readable storage medium storing program for executing
EP4030300B1 (en) Test cycle optimization using contextual association mapping
CN111507086A (en) Automatic discovery of translation text location in localized applications
US11922230B2 (en) Natural language processing of API specifications for automatic artifact generation
Majumdar et al. Automated evaluation of comments to aid software maintenance
CN110750297A (en) Python code reference information generation method based on program analysis and text analysis
Attanasio et al. ferret: a Framework for Benchmarking Explainers on Transformers
Yu et al. Localizing function errors in mobile apps with user reviews
CN113900956A (en) Test case generation method and device, computer equipment and storage medium
CN112650673A (en) Method and device for creating test case in transaction tracking system and electronic equipment
Chen et al. Employing a parametric model for analytic provenance
CN116150394A (en) Knowledge extraction method, device, storage medium and equipment for knowledge graph
Wang et al. UISMiner: Mining UI suggestions from user reviews
US11119761B2 (en) Identifying implicit dependencies between code artifacts
CN110018828B (en) Source code checking method and device and terminal equipment
Kleffmann et al. Evaluation of a traceability approach for informal freehand sketches
WO2018060777A1 (en) Method and system for optimizing software testing
Yu et al. Towards automatically localizing function errors in mobile apps with user reviews
CN113761213A (en) Data query system and method based on knowledge graph and terminal equipment
Hsiao et al. Automating the generation of hardware component knowledge bases

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination