CN114896161A - File construction method and device based on artificial intelligence, computer equipment and medium - Google Patents

File construction method and device based on artificial intelligence, computer equipment and medium Download PDF

Info

Publication number
CN114896161A
CN114896161A CN202210582596.5A CN202210582596A CN114896161A CN 114896161 A CN114896161 A CN 114896161A CN 202210582596 A CN202210582596 A CN 202210582596A CN 114896161 A CN114896161 A CN 114896161A
Authority
CN
China
Prior art keywords
test
file
data
field value
template
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
CN202210582596.5A
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 CN202210582596.5A priority Critical patent/CN114896161A/en
Publication of CN114896161A publication Critical patent/CN114896161A/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/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Landscapes

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

Abstract

The application is applicable to the technical field of artificial intelligence, and particularly relates to a file construction method and device based on artificial intelligence, computer equipment and a medium. The method comprises the steps of respectively matching interface parameters of an interface to be tested with an existing file template and an existing number making rule, determining a test file template and a test data number making rule, generating an inquiry statement of a number making database according to the test data number making rule, extracting test data from the number making database, identifying a blank field in the test file template by using a target identifier, determining an object to be written in the test file template, extracting a field value interval of the object to be written, writing a data object of the field value in the test data in the field value interval into the test file template to obtain a test file, realizing automatic construction of the test file, avoiding manual number making and file integration, reducing file number making difficulty, improving file number making efficiency and further effectively improving test efficiency.

Description

File construction method and device based on artificial intelligence, computer equipment and medium
Technical Field
The application is applicable to the technical field of artificial intelligence, and particularly relates to a file construction method and device based on artificial intelligence, computer equipment and a medium.
Background
At present, in the testing process of software development, test files need to be used, and a corresponding number of test files generally need to be prepared and then input to a local terminal for manual or automatic testing. In order to improve the testing efficiency, the whole testing project needs to be split into a plurality of small testing tasks, a corresponding number of testing personnel are used for preparing a testing file for each small testing task and executing the testing, when the testing file is prepared, different testing scenes need to be summarized by each testing personnel to integrate the corresponding testing file, the testing data inserted into the testing file is manually numbered by being distributed to each testing personnel, and the efficiency of integrating the testing file and the number of the test data is low, so that how to effectively improve the automatic generation of the testing file becomes the problem to be solved urgently.
Disclosure of Invention
In view of this, embodiments of the present application provide a file construction method and apparatus, a computer device, and a medium based on artificial intelligence, so as to solve the problem of how to effectively improve the automatic generation of a test file.
In a first aspect, an embodiment of the present application provides a file construction method based on artificial intelligence, where the file construction method includes:
acquiring interface parameters of an interface to be tested, respectively matching the interface parameters with an existing file template and an existing number making rule, and determining the matched file template and number making rule as a test file template and a test data number making rule corresponding to the interface to be tested;
generating an inquiry statement of a data structure database according to the test data structure rule, and extracting test data from the data structure database by using the inquiry statement, wherein the test data comprises N data objects and field values corresponding to each data object, and N is an integer greater than zero;
identifying a null field in the test file template by using a target identifier, determining the null field as an object to be written in the test file template, and extracting a field value interval of the object to be written;
and writing the data object with the field value in the field value interval into the test file template to obtain a test file so as to test the interface to be tested.
In a second aspect, an embodiment of the present application provides an artificial intelligence-based file constructing apparatus, including:
the template and rule determining module is used for acquiring interface parameters of an interface to be tested, respectively matching the interface parameters with an existing file template and an existing number making rule, and determining the matched file template and number making rule as a test file template and a test data number making rule corresponding to the interface to be tested;
the test data extraction module is used for generating an inquiry statement of a manufacture database according to the test data manufacture rule and extracting test data from the manufacture database by using the inquiry statement, wherein the test data comprises N data objects and field values corresponding to the data objects, and N is an integer larger than zero;
a field value interval extraction module, configured to identify a null field in the test file template by using a target identifier, determine that the null field is an object to be written in the test file template, and extract a field value interval of the object to be written;
and the test file generation module is used for writing the data object with the field value in the field value interval into the test file template to obtain a test file so as to test the interface to be tested.
In a third aspect, an embodiment of the present application provides a computer device, where the computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the file construction method according to the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the file constructing method according to the first aspect.
Compared with the prior art, the embodiment of the application has the advantages that: according to the method, interface parameters of an interface to be tested are matched with an existing file template and an existing number rule respectively, a test file template and a test data number rule corresponding to the interface to be tested are determined, query statements of a number database are generated according to the test data number rule, test data are extracted from the number database, a target identifier is used for identifying a blank field in the test file template, the blank field is determined to be an object to be written in the test file template, a field value interval of the object to be written is extracted, a data object of the field value in the test data in the field value interval is written in the test file template to obtain a test file, automatic construction of the test file is achieved, manual number and file integration are not needed, file number difficulty is reduced, file number efficiency is improved, and test efficiency can be effectively 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 based on these drawings without inventive exercise.
FIG. 1 is a schematic diagram of an application environment of a file construction method based on artificial intelligence according to an embodiment of the present application;
FIG. 2 is a schematic flowchart of a file construction method based on artificial intelligence according to a second embodiment of the present application;
FIG. 3 is a schematic flowchart of a file construction method based on artificial intelligence according to a third embodiment of the present application;
FIG. 4 is a schematic structural diagram of an artificial intelligence-based file constructing apparatus according to a fifth embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a computer device according to a sixth embodiment of the present application.
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 should also be 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" determining "or" in response to detecting ". 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 ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. 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.
It should be understood that, the sequence numbers of the steps in the following embodiments 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 embodiments of the present application.
In order to explain the technical means of the present application, the following description will be given by way of specific examples.
The file construction method based on artificial intelligence provided by the embodiment of the application can be applied to the application environment shown in fig. 1, wherein a client communicates with a server. The client includes, but is not limited to, a palm top computer, a desktop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cloud computing device, a Personal Digital Assistant (PDA), and other computing devices. The server can be implemented by an independent server or a server cluster composed of a plurality of servers.
Referring to fig. 2, a flowchart of a file construction method based on artificial intelligence according to a second embodiment of the present application is shown, where the file construction method may be applied to the client in fig. 1, and a computer device corresponding to the client connects to a corresponding database to obtain corresponding data in the database. As shown in fig. 2, the file construction method may include the steps of:
step S201, obtaining interface parameters of the interface to be tested.
In the application, the computer equipment is provided with corresponding component products such as a control, a plug-in and the like to be tested, an object to be tested in the component products to be tested is an interface, the content to be tested comprises contents such as an interface function and an interface logic, and test data needs to be sent to the interface when the interface is tested so as to obtain a result fed back by the interface. The test data required by different interfaces may be different, and different interfaces have different interface parameters, because, in order to distinguish the interfaces to be tested, the computer device obtains the interface parameters of the interfaces to be tested through corresponding test software. For example, for the test of the HTTP interface, the obtained interface parameter is a parameter of the HTTP interface to be tested, and the parameter of the HTTP interface includes information such as an interface name and an interface type.
In an embodiment, when the browser in the computer device is used to perform a front-end test on the interface to be tested, the interface parameters of the interface to be tested are obtained, where the interface parameters of the interface to be tested may be an interface name, a template Identity mark (ID), a test environment, a test date, and the like, where if the interface to be tested is a web interface, the interface name may represent that the interface to be tested is the web interface, the template ID may represent that the interface to be tested needs a test case template corresponding to the ID, and the test may represent that the interface to be tested needs the data volume of the test case, and the like.
In an embodiment, when the client in the computer device is used to perform a front-end test on an Interface to be tested, Interface parameters of the Interface to be tested are obtained, at this time, if the Interface to be tested is an Application Programming Interface (API), and the like, an Interface name in the Interface parameters may represent that the Interface to be tested requires an API test, a template ID in the Interface parameters may represent that the Interface to be tested requires a test case template corresponding to the ID, and a test environment in the Interface parameters may represent a data volume of a test case required by the Interface to be tested, and the like.
Step S202, the interface parameters are respectively matched with the existing file template and the existing number making rule, and the matched file template and the number making rule are determined to be a test file template and a test data number making rule corresponding to the interface to be tested.
In the application, the computer device is connected with a corresponding template database, a file template and a test data manufacture rule are stored in the database, and the test file template and the test data manufacture rule required by the interface to be tested can be matched from the template database according to the acquired interface parameters.
The obtained interface parameters have a mapping relation with the existing file template and the existing number making rule in the template database, wherein the template ID in the interface parameters can be matched with the file template corresponding to the template ID, and the testing environment parameters in the interface parameters can be matched with the corresponding testing data number making rule. The file template is a template file with a certain file format, the file format can be set according to requirements, and the manufacturing rule is a rule for manufacturing test data, such as test scene requirements, data volume, data intervals and the like.
After the test file template is determined, the test file template needs to be downloaded, and downloading the test file template may refer to downloading a file from a template database, of course, only file template information is stored in the template database, and the file template is not stored in the template database.
For example, for the test of the HTTP interface, parameters of the HTTP interface to be tested are acquired, where the parameters include a test environment, a test template requirement, a test data requirement, and the like, where the test template requirement may be identification information such as an ID or a name, the identification information such as the ID or the name is sent to the cloud server to download the template, the cloud server responds to a download instruction to send a file template corresponding to the identification information such as the ID or the name to the computer device, and the test data requirement may include a scene of data required for the test and a data amount of the data required for the test, so that a corresponding manufacture rule may be determined accordingly.
In one embodiment, the computer device provides template services such as file template editing and uploading, and a user creates a file template using a template creation interface provided by the computer device and uploads the created file template to a cloud server and a database or stores the created file template to a local server and a database through a corresponding uploading or storing function. Further, the computer device provides an upload or storage interface through which the user uploads or stores the file template. Further, when uploading or storing the file template, it is also necessary to provide identification information of the file template, such as an ID or a name, and map the uploaded file template with the corresponding identification information in the server or the database.
Step S203, generating an inquiry statement of the manufacture number database according to the test data manufacture number rule, and extracting the test data from the manufacture number database by using the inquiry statement.
The test data comprises N data objects and a field value corresponding to each data object, wherein N is an integer larger than zero.
The test data manufacturing rule may include a manufacturing quantity, a manufacturing scene, a manufacturing interval, and the like, so that the manufacturing quantity, the manufacturing scene, and the manufacturing interval are parameters representing the manufacturing rule, and corresponding test data may be obtained according to the parameters.
In one embodiment, the computer device is connected to a data base, which may be an SQL database, a MySQL database, or the like, and the data base stores test data, which includes data objects and corresponding field values, which are field attributes of the data objects, such as field assignments in the data base.
The computer device needs to query and acquire corresponding test data from the database through a query statement, and therefore, the corresponding query statement needs to be automatically constructed according to parameters such as the number of manufactured items, the number of manufactured items scene, the number of manufactured items and the like, the query statement is sent to the number of manufactured items database, and the number of manufactured items database responds to the query statement and feeds back corresponding test data to the computer device.
For example, the number rule is 2 data in a scene a, an SQL query statement is automatically generated according to the number rule, 2 pieces of test data meeting the scene a can be called from an SQL database, including test data 1 and test data 2, where the test data 1 includes a data object 1 and a field value 1, and the test data 2 includes a data object 2 and a field value 2, and first, an SQL query statement template is obtained, and then, the scene a and the group B are filled in the SQL query statement template, and the SQL query statement is automatically generated.
In an embodiment, the above-mentioned number database is arranged in a computer device, and the corresponding test data can be directly obtained through query statements.
Optionally, after the test data is extracted from the manufacture database by using the query statement, the method further includes:
checking the field value of each data object in the test data;
if the field value which is not verified is detected to exist, outputting an error prompt;
if no field value which is not verified is detected, the step of writing the data object with the field value in the field value interval into the test file template is executed.
The field values are matched according to a preset check rule, if the matching is successful, the check is passed, and if the matching is failed, the check is not passed, and the check rule can be parity check, CRC check, LRC check, Gray code check and the like. For the case that the verification fails, it is described that the manufacture error may be due to an error of the query statement or the manufacture rule, and therefore, an error prompt needs to be output to remind the user to view.
Step S204, using the target identifier to identify the empty field in the test file template, determining the empty field as the object to be written in the test file template, and extracting the field value interval of the object to be written.
In the present application, after the test file template is determined, the test file template is analyzed, and the analysis process includes using the target identifier to identify an empty field in the test file template, where the empty field is a field to be filled, for example, the test file template is a file in a list format, and a cell marked as empty in a form is a cell to be filled, and the empty cell is an object to be written.
After all objects to be written in the test file template are determined, the field value interval required by the objects to be written in is obtained, and only data of the field value in the field interval can be written in the objects to be written in.
The field value interval may be a rule preset in an object to be written in the file template, for example, the rule for the object to be written 1 is that the field value interval is [ 200- & 400 ], the data object 1 with the field value of 300 belongs to the object to be written 1, and the data object 2 with the field value of 500 does not belong to the object to be written 1.
In one embodiment, when a file template uploading operation is performed on a computer device, the file template is parsed, and a template detail table is generated, which stores the mapping relationship between the object to be written and the corresponding field value interval of each file template, so that after the test file template is determined, the field value interval corresponding to each object to be written in the test file template is determined from the template detail table.
Optionally, after extracting the field value interval of the object to be written, the method further includes:
matching the field value of the data object in the test data with the field value interval of the object to be written;
saving data objects with field values not in the field value interval and testing data structure rule, and sending the saved contents to the preset address.
Therefore, if the data object does not belong to any object to be written, the data object and the test data manufacture rule need to be sent to a preset address to prompt corresponding personnel to pay attention to the data object and the test data manufacture rule so as to judge whether the test data manufacture rule is correct or not, so that whether the manufacture function has defects or not is judged, and the condition that the subsequent test is inaccurate due to the manufacture function defects is reduced.
Step S205, writing the data object with the field value in the field value interval into the test file template to obtain the test file so as to test the interface to be tested.
In the method, after the field value interval of the object to be written is determined, the field value of each data object in the test data is matched with the field value interval, and the data object belonging to the field value interval is determined. And writing the data objects into the test file template by using an automatic filling function to obtain a test file, and traversing the whole test file template during filling if a plurality of objects to be written exist in the test file template. For example, when the test file template is a table, writing may refer to filling the data objects into the corresponding cells, respectively.
For example, for the test of the HTTP interface, a test template requirement and a test data requirement of the HTTP interface to be tested are obtained, where the test template requirement may be identification information such as an ID of the test template, and accordingly, a corresponding file template 1 may be determined, and the test data requirement may include a scene a of data and a required data amount of 2, and accordingly, a corresponding number rule may be determined; the method comprises the steps that an artifact rule is 2 data in a scene A, an SQL query statement is automatically generated according to the artifact rule, 2 test data meeting the scene A can be called from an SQL database, the test data comprises a data object 1, a field value 1, a data object 2 and a field value 2, 2 objects to be written in a file template are extracted, the field value interval of the object 1 to be written can be determined to be an interval 1 and the field value interval of the object 2 to be written can be an interval 2 from a template detailed table, when the field value 1 belongs to the interval 1, the data object 1 is written into the object 1 to be written, when the field value 2 belongs to the interval 2, the data object 2 is written into the object 2 to be written, and the test template and the test data form a complete test file, namely the test file.
Optionally, after obtaining the interface parameters of the interface to be tested, the method further includes:
determining a first test date according to the interface parameters;
after the data object with the field value in the field value interval is written into the test file template to obtain the test file, the method further comprises the following steps:
the test files are named according to a first test date.
The interface parameters include a test date, that is, a date for testing the interface to be tested, and the interface to be tested can only test on the corresponding test date. In order to improve the automatic degree of the test, a corresponding automatic test function is set, and an automatic call command is used for calling a naming file with a file name of a test date on a corresponding test date, so that the test file is named by the test date and is used for automatically calling an interface to be tested on the test date, and the automatic test is realized. Further, storing the named test file, obtaining a test file storage address, mapping the storage address with the test date to form associated data, and when the time reaches the test date, obtaining the storage address from the associated data according to the test date by the computer equipment, and then calling the test file corresponding to the storage address.
For example, according to the interface parameters of the interface to be tested, the test date of the interface to be tested is determined to be 10, month and 21 days in 2021, so that the obtained test file is named as 10, month and 21 days in 2021 and is stored, and the file named as 10, month and 21 days in 2021 can be directly called by the subsequent interface to be tested during testing, so that manual operation is not needed, and automatic testing is realized.
In one embodiment, when a plurality of test files need to be generated in batch, the generated test files are packaged into a file package, the file package is named according to the test date, and the file package is called to perform automatic test when the test date of the interface to be tested is reached.
Optionally, after extracting the field value interval of the object to be written, the method further includes:
detecting whether a data object with at least two field values in a field value interval of a local writing object exists in the test file;
writing the data object with the field value in the field value interval into a test file template to obtain a test file, wherein the test file comprises the following steps:
and if the data objects with at least two field values in the field value interval of the ground writing object exist in the test file, selecting any data object from the at least two data objects, and writing the data object into the test file template to obtain the test file.
When the field values of two or more data objects in the N data objects are in the field value interval, the object to be written can be written into one of the two data objects, so that the test randomness is increased, and the human intervention degree is reduced.
According to the method and the device, interface parameters of the interface to be tested are matched with an existing file template and an existing number rule respectively, a test file template and a test data number rule corresponding to the interface to be tested are determined, query statements of a number database are generated according to the test data number rule, test data are extracted from the number database, a target identifier is used for identifying a blank field in the test file template, the blank field is determined to be an object to be written in the test file template, a field value interval of the object to be written is extracted, a data object of a field value in the test data in the field value interval is written in the test file template to obtain the test file, automatic construction of the test file is achieved, manual number and file integration are not needed, file number difficulty is reduced, file number efficiency is improved, and test efficiency can be effectively improved.
Referring to fig. 3, which is a schematic flowchart of a file constructing method based on artificial intelligence according to a third embodiment of the present application, as shown in fig. 3, the file constructing method may include the following steps:
step S301, obtaining interface parameters of the interface to be tested.
Step S302, the interface parameters are respectively matched with the existing file template and the existing number making rule, and the matched file template and the number making rule are determined to be a test file template and a test data number making rule corresponding to the interface to be tested.
The contents of steps S301 to S302 are the same as those of steps S201 to S202, and the descriptions of steps S201 to S202 can be referred to, and are not repeated herein.
Step S303, determining the required number of the required test files according to the interface parameters.
In the application, the test requirements of the interface to be tested may require batch tests, that is, more than one test file is required for testing, and the interface parameters include a batch number, which is the required number of the test files required for testing.
Step S304, generating query sentences of the number making database according to the test data number making rules, repeatedly calling the query sentences, and extracting test data from the number making database to obtain M groups of test data.
The number of repeated calls is the required number, and M is equal to the required number.
In the application, the manufacture rule of one test data in the manufacture database may correspond to multiple groups of test data, and the query statement generated according to the manufacture rule of the test data has the function of random query, so that the query statement can be repeatedly used to query multiple groups of test data, and the contents of any two test data in the multiple groups of test data can be the same or different.
Step S305, using the target identifier to identify the empty field in the test file template, determining the empty field as the object to be written in the test file template, and extracting the field value interval of the object to be written.
The content of step S305 is the same as that of step S203, and reference may be made to the description of step S203, which is not repeated herein.
Step S206, respectively writing the data objects with the field values in the field value interval in each group of test data into a test file template to obtain M test files.
In the application, a group of test data corresponds to a test file template, and finally, M test files are formed by M groups of test data and the test file template, and batch tests can be realized by using the M test files.
Optionally, after obtaining the interface parameters of the interface to be tested, the method further includes:
determining a second test date according to the interface parameters;
after the data objects with the field values in the field value intervals in each group of test data are respectively written into a test file template to obtain M test files, the method further comprises the following steps:
packaging the M test files into a file package;
the package of files is named according to the second test date.
Similarly, in order to realize the automatic batch test of the interfaces to be tested, all test files are packaged into a file package and named according to the test date for the condition of a plurality of test files. And setting a corresponding automatic test function, and calling the file packet with the file name as the test date on the corresponding test date by using an automatic calling command so as to realize automatic test. Further, the named file package is stored, a file package storage address is obtained, the storage address is mapped with the test date to form associated data, and when the time reaches the test date, the computer equipment obtains the storage address from the associated data according to the test date, and then calls the file newspaper corresponding to the storage address.
For example, for the test of the HTTP interface, parameters of the HTTP interface to be tested are obtained, where the parameters include 2 test files, a test environment, a test template requirement, a test data requirement, and the like, where the test template requirement may be identification information such as an ID of the test template, and accordingly, a corresponding file template may be determined, the test data requirement may include data of a required scene and a required data amount, and accordingly, a corresponding configuration rule may be determined, the configuration rule is 1 data in a scene a, an SQL query statement is automatically generated according to the configuration rule, 1 test data satisfying the scene a may be called from an SQL database to obtain a test data 1, 1 test data satisfying the scene a is repeatedly called to obtain a test data 2, the test data 1 includes a data object 1 and a field value 1, the test data 2 includes data objects 2 and field values 2, providing a first test file template, extracting 1 object to be written in the template, determining a field value interval of the object 1 to be written as an interval 1 from the template specification table, writing the data object 1 into the object 1 to be written when the field value 1 belongs to the interval 1 to obtain a first test file, providing a second test file template, extracting 1 object to be written in the template, determining a field value interval of the object 1 to be written as the interval 1 from the template specification table, writing the data object 2 into the object 2 to be written when the field value 2 belongs to the interval 1 to obtain a second test file, and obtaining the two test files.
The embodiment of the application matches the interface parameters of the interface to be tested with the existing file template and the existing number rule respectively, determines the test file template and the test data number rule corresponding to the interface to be tested, determines the required number of the required test files according to the interface parameters, generates the query statement of the number database according to the test data number rule, and repeatedly calls the query statement, extracts the test data from the number database to obtain M groups of test data, identifies the empty field in the test file template by using the target identifier, determines the empty field as the object to be written in the test file template, extracts the field value interval of the object to be written in, writes the data object of the field value in the field value interval in each group of test data into one test file template respectively to obtain M test files, and realizes the automatic construction of batch test files, manual numbering and file integration are not needed, and the efficiency of batch testing is effectively improved.
Corresponding to the file construction method in the foregoing embodiment, fig. 4 shows a block diagram of a file construction apparatus based on artificial intelligence according to a fifth embodiment of the present application, where the file construction apparatus can be applied to the client in fig. 1, and a computer device corresponding to the client connects to a corresponding database to obtain corresponding data. For convenience of explanation, only portions related to the embodiments of the present application are shown.
Referring to fig. 4, the document constructing apparatus includes:
the template and rule determining module 41 is configured to obtain interface parameters of the interface to be tested, match the interface parameters with an existing file template and an existing number rule, and determine that the matched file template and number rule are a test file template and a test data number rule corresponding to the interface to be tested;
a test data extracting module 42, configured to generate an inquiry statement of the manufacture database according to the test data manufacture rule, and extract test data from the manufacture database by using the inquiry statement, where the test data includes N data objects and a field value corresponding to each data object, and N is an integer greater than zero;
a field value interval extracting module 43, configured to identify an empty field in the test file template by using the target identifier, determine the empty field as an object to be written in the test file template, and extract a field value interval of the object to be written;
the test file generating module 44 is configured to write the data object with the field value within the field value interval into the test file template, so as to obtain a test file for testing the interface to be tested.
Optionally, the file constructing apparatus further includes:
the first date acquisition module is used for determining a first test date according to the interface parameters after acquiring the interface parameters of the interface to be tested;
the above document construction apparatus further includes:
the first naming module is used for naming the test file according to a first test date after the data object with the field value in the field value interval is written into the test file template to obtain the test file.
Optionally, the file constructing apparatus further includes:
the required quantity acquisition module is used for determining the required quantity of the required test files according to the interface parameters after acquiring the interface parameters of the interfaces to be tested;
the test data extraction module 42 includes:
the test data extraction unit is used for repeatedly calling the query statement and extracting test data from the number database to obtain M groups of test data, the number of repeated calling is the required number, and M is equal to the required number;
the test file generation module 44 includes:
and the first file generation unit is used for respectively writing the data objects with the field values in the field value intervals in each group of test data into a test file template to obtain M test files.
Optionally, the file constructing apparatus further includes:
the second date acquisition module is used for determining a second test date according to the interface parameters after acquiring the interface parameters of the interface to be tested;
the above document construction apparatus further includes:
the packaging module is used for writing data objects with field values in the field value interval in each group of test data into a test file template respectively to obtain M test files, and then packaging the M test files into a file package;
and the second naming module is used for naming the file package according to a second test date.
Optionally, the file constructing apparatus further includes:
the field value matching module is used for matching the field value of the data object in the test data with the field value interval of the object to be written after the field value interval of the object to be written is extracted;
and the error data storage module is used for storing the data objects with the field values not in the field value interval and the test data manufacture rule and sending the stored contents to the preset address.
Optionally, the file constructing apparatus further includes:
the field value checking module is used for checking the field value of each data object in the test data after the test data is extracted from the number database by using the query statement;
the error prompt module is used for outputting an error prompt if the field value which cannot be verified is detected;
and the writing execution module is used for executing the step of writing the data object with the field value in the field value interval into the test file template if the field value which is not verified is detected to be not existed.
Optionally, the file constructing apparatus further includes:
the detection module is used for detecting whether data objects with at least two field values in the field value interval of the local writing object exist in the test file after the field value interval of the object to be written is extracted;
the test file generation module 44 includes:
and the second file generating unit is used for selecting any data object from the at least two data objects and writing the data object into the test file template to obtain the test file if detecting that the test file has data objects with at least two field values in the field value interval of the ground writing object.
It should be noted that, because the contents of information interaction, execution process, and the like between the modules are based on the same concept as that of the embodiment of the method of the present application, specific functions and technical effects thereof may be specifically referred to a part of the embodiment of the method, and details are not described here.
Fig. 5 is a schematic structural diagram of a computer device according to a sixth embodiment of the present application. As shown in fig. 5, the computer apparatus of this embodiment includes: at least one processor (only one shown in fig. 5), a memory, and a computer program stored in the memory and executable on the at least one processor, the processor implementing the steps of any of the various file construction method embodiments described above when executing the computer program.
The computer device may include, but is not limited to, a processor, a memory. It will be appreciated by those skilled in the art that fig. 5 is merely an example of a computer device and is not intended to be limiting, and that a computer device may include more or fewer components than those shown, or some components may be combined, or different components may be included, such as a network interface, a display screen, and input devices, etc.
The Processor may be a CPU, or 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, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory includes readable storage media, internal memory, etc., wherein the internal memory may be the internal memory of the computer device, and the internal memory provides an environment for the operating system and the execution of the computer-readable instructions in the readable storage media. The readable storage medium may be a hard disk of the computer device, and in other embodiments may also be an external storage device of the computer device, 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, provided on the computer device. Further, the memory may also include both internal and external storage units of the computer device. The memory is used for storing an operating system, application programs, a BootLoader (BootLoader), data, and other programs, such as program codes of a computer program, and the like. The memory 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, so as to perform all or part of the functions described above. 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 above-mentioned apparatus may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method of the embodiments described above can be implemented by a computer program, which can be stored in a computer readable storage medium and can implement 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 at least: any entity or device capable of carrying computer program code, recording medium, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, and software distribution media. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
When the computer program product runs on a computer device, the computer device is enabled to implement the steps in the method embodiments.
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/computer device and method may be implemented in other ways. For example, the above-described apparatus/computer device embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logical function, and may be implemented in other ways, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. 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.
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.
The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit 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 file construction method based on artificial intelligence is characterized by comprising the following steps:
acquiring interface parameters of an interface to be tested, respectively matching the interface parameters with an existing file template and an existing number making rule, and determining the matched file template and number making rule as a test file template and a test data number making rule corresponding to the interface to be tested;
generating an inquiry statement of a data structure database according to the test data structure rule, and extracting test data from the data structure database by using the inquiry statement, wherein the test data comprises N data objects and field values corresponding to each data object, and N is an integer greater than zero;
identifying a null field in the test file template by using a target identifier, determining the null field as an object to be written in the test file template, and extracting a field value interval of the object to be written;
and writing the data object with the field value in the field value interval into the test file template to obtain a test file so as to test the interface to be tested.
2. The file construction method according to claim 1, further comprising, after the obtaining interface parameters of the interface to be tested:
determining a first test date according to the interface parameters;
after the data object with the field value in the field value interval is written into the test file template to obtain a test file, the method further includes:
and naming the test file according to the first test date.
3. The file construction method according to claim 1, further comprising, after the obtaining interface parameters of the interface to be tested:
determining the required number of the files to be tested according to the interface parameters;
the extracting test data from the syndrome database using the query statement comprises:
repeatedly calling the query statement, extracting test data from the number database to obtain M groups of test data, wherein the number of repeated calling is the required number, and M is equal to the required number;
writing the data object with the field value in the field value interval into the test file template to obtain the test file comprises:
and respectively writing the data objects of the field values in the field value intervals in each group of test data into a test file template to obtain M test files.
4. The file construction method according to claim 3, further comprising, after the obtaining interface parameters of the interface to be tested:
determining a second test date according to the interface parameters;
after the data objects with the field values in the field value intervals in each group of test data are written into a test file template respectively to obtain M test files, the method further includes:
packaging the M test files into a file package;
and naming the file package according to the second test date.
5. The file construction method according to claim 1, further comprising, after extracting field value intervals of the object to be written:
matching the field value of the data object in the test data with the field value interval of the object to be written;
and saving the data objects with the field values not in the field value interval and the test data identification rule, and sending the saved contents to a preset address.
6. The file construction method according to claim 1, further comprising, after said extracting test data from said manufacture database using said query statement:
checking the field value of each data object in the test data;
if the field value which is not verified is detected to exist, outputting an error prompt;
and if the field value which is not verified is detected to be absent, writing the data object with the field value in the field value interval into the test file template.
7. The file construction method according to any one of claims 1 to 6, further comprising, after said extracting field value intervals of the object to be written:
detecting whether there are data objects in the test file with at least two field values within a field value interval of the write target;
writing the data object with the field value in the field value interval into the test file template to obtain the test file comprises:
and if the data objects with at least two field values in the field value interval of the written object exist in the test file, selecting any data object from the at least two data objects, and writing the data object into the test file template to obtain the test file.
8. An artificial intelligence based document construction apparatus, characterized in that the document construction apparatus comprises:
the template and rule determining module is used for acquiring interface parameters of an interface to be tested, respectively matching the interface parameters with an existing file template and an existing number making rule, and determining the matched file template and number making rule as a test file template and a test data number making rule corresponding to the interface to be tested;
the test data extraction module is used for generating an inquiry statement of a manufacture database according to the test data manufacture rule and extracting test data from the manufacture database by using the inquiry statement, wherein the test data comprises N data objects and field values corresponding to the data objects, and N is an integer larger than zero;
a field value interval extraction module, configured to identify an empty field in the test file template by using a target identifier, determine that the empty field is an object to be written in the test file template, and extract a field value interval of the object to be written;
and the test file generation module is used for writing the data object with the field value in the field value interval into the test file template to obtain a test file so as to test the interface to be tested.
9. A computer device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, the processor implementing the file construction method according to any one 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, implements a file construction method according to any one of claims 1 to 7.
CN202210582596.5A 2022-05-26 2022-05-26 File construction method and device based on artificial intelligence, computer equipment and medium Pending CN114896161A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210582596.5A CN114896161A (en) 2022-05-26 2022-05-26 File construction method and device based on artificial intelligence, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210582596.5A CN114896161A (en) 2022-05-26 2022-05-26 File construction method and device based on artificial intelligence, computer equipment and medium

Publications (1)

Publication Number Publication Date
CN114896161A true CN114896161A (en) 2022-08-12

Family

ID=82726353

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210582596.5A Pending CN114896161A (en) 2022-05-26 2022-05-26 File construction method and device based on artificial intelligence, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN114896161A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117130946A (en) * 2023-10-27 2023-11-28 北京世冠金洋科技发展有限公司 Test scene generation method and device, electronic equipment and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117130946A (en) * 2023-10-27 2023-11-28 北京世冠金洋科技发展有限公司 Test scene generation method and device, electronic equipment and readable storage medium
CN117130946B (en) * 2023-10-27 2024-01-26 北京世冠金洋科技发展有限公司 Test scene generation method and device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN110532107B (en) Interface calling method, device, computer equipment and storage medium
CN113448862B (en) Software version testing method and device and computer equipment
CN114416877A (en) Data processing method, device and equipment and readable storage medium
CN110688315A (en) Interface code detection report generation method, electronic device, and storage medium
CN115391439A (en) Document data export method, device, electronic equipment and storage medium
CN114896161A (en) File construction method and device based on artificial intelligence, computer equipment and medium
CN114465937A (en) Network card testing method, device, server, medium, and computer program product
CN114116108A (en) Dynamic rendering method, device, equipment and storage medium
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN117493309A (en) Standard model generation method, device, equipment and storage medium
CN112083925A (en) Data acquisition method, device, equipment and storage medium based on H5 page development
CN116414689A (en) Interface parameter verification method and system based on reflection mechanism
CN115757174A (en) Database difference detection method and device
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN111400245B (en) Art resource migration method and device
CN111881234A (en) Land planning method and device, terminal equipment and storage medium
CN116010349B (en) Metadata-based data checking method and device, electronic equipment and storage medium
CN114205276B (en) Performance test method and device for product management system and electronic equipment
CN111581207B (en) File generation method and device of Azkaban project and terminal equipment
CN117349267B (en) Database migration processing method and system
CN117370203B (en) Automatic test method, system, electronic equipment and storage medium
CN117725766B (en) Verification method, device and equipment of geometric modeling model
CN114116724A (en) Data verification method, device and equipment and readable storage medium
CN113553258A (en) Test data generation method, extraction strategy test method and related device
CN115687082A (en) Method and device for testing assembly environment

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