CN112286783A - Method and device for generating database insertion statement and performing system test - Google Patents

Method and device for generating database insertion statement and performing system test Download PDF

Info

Publication number
CN112286783A
CN112286783A CN201910668132.4A CN201910668132A CN112286783A CN 112286783 A CN112286783 A CN 112286783A CN 201910668132 A CN201910668132 A CN 201910668132A CN 112286783 A CN112286783 A CN 112286783A
Authority
CN
China
Prior art keywords
data
test
generating
test data
preset format
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
CN201910668132.4A
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.)
Beijing Zhongguancun Kejin Technology Co Ltd
Original Assignee
Beijing Zhongguancun Kejin Technology 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 Beijing Zhongguancun Kejin Technology Co Ltd filed Critical Beijing Zhongguancun Kejin Technology Co Ltd
Priority to CN201910668132.4A priority Critical patent/CN112286783A/en
Publication of CN112286783A publication Critical patent/CN112286783A/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/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a method and a device for generating database insertion sentences and performing system test. The method for carrying out the system test comprises the following steps: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.

Description

Method and device for generating database insertion statement and performing system test
Technical Field
The present application relates to the field of computer and software testing, and in particular, to a method and an apparatus for generating database insertion statements and performing system testing.
Background
With the rapid development of the mobile phone software industry, background systems on which mobile phone applications depend are more and more complex. When testing a background system, a tester usually needs to construct a large amount of complex database test data to verify whether the background system functions normally. However, in the prior art, the construction of a large number of database insertion sentences is mainly completed manually, the data logic represented by each piece of data needs to be designed manually by a tester, if the number of database fields is large, the insertion sentences are long in length and poor in readability, and the designed sentences are very easy to cause problems. Furthermore, if the amount of configuration data required is too large (e.g., ten thousand), the tester will spend a lot of time on the mechanically repetitive job, and it is easy to repeatedly execute statements resulting in repetitive data.
Aiming at the technical problems that the readability is poor and problems are easy to occur due to the fact that a large amount of test data are manually designed in the prior art, and time and labor are wasted in repeated mechanical work, an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for generating database insertion sentences and performing system test, which at least solve the technical problems that the readability of test sentences is poor and the time and labor are wasted in the repeated work of machinery when a large number of test sentences are manually designed to perform the system test in the prior art.
According to an aspect of the embodiments of the present disclosure, there is provided a method of performing system test, including: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.
According to another aspect of the embodiments of the present disclosure, there is also provided a method for generating a database insert statement, including: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data.
According to another aspect of the embodiments of the present disclosure, there is also provided a storage medium including a stored program, wherein the method of any one of the above is performed by a processor when the program is run.
According to another aspect of the embodiments of the present disclosure, there is also provided an apparatus for performing system test, including: the data generating module is used for generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and the test module is used for generating corresponding database insertion statements according to the generated test data and carrying out system test by using the generated database insertion statements.
According to another aspect of the embodiments of the present disclosure, there is also provided an apparatus for generating a database insert statement, including: the first generation module is used for generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and the second generation module is used for generating a corresponding database insertion statement according to the generated test data.
According to another aspect of the embodiments of the present disclosure, there is also provided an apparatus for performing system test, including: a first processor; and a first memory coupled to the first processor for providing instructions to the first processor to process the following processing steps: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.
According to another aspect of the embodiments of the present disclosure, there is also provided an apparatus for generating a database insert statement, including: a second processor; and a second memory coupled to the second processor for providing instructions to the second processor to process the following processing steps: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data.
In the embodiment of the present disclosure, test data for system testing is generated in batch through a data template and an expression in a predetermined format, then a database insertion statement is generated according to the test data, and finally the system testing is performed by using the database insertion statement. The data template can adopt a JSON format, for example, and the operation process can adopt a script mode to perform operations such as data addition, modification, deletion and the like on the JSON data template through an expression. Therefore, compared with the traditional manual test statement compiling and system test process, the method ensures that testers only pay attention to the collection of JSON data templates and the compiling of expressions, gets rid of the step of compiling complicated database statements, ensures that the data construction becomes intuitive, efficient and reliable, and achieves the aim of automatically constructing test data in batches. Therefore, the method for simplifying the data construction is realized, the accuracy of the test data is improved, and the technical effects of saving time and labor cost by avoiding a large amount of repeated work are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the disclosure and together with the description serve to explain the disclosure and not to limit the disclosure. In the drawings:
fig. 1 is a hardware configuration block diagram of a [ computer terminal (or mobile device) ] for implementing the method according to embodiment 1 of the present disclosure;
fig. 2 is a schematic flow chart of a method for performing system testing according to a first aspect of embodiment 1 of the present disclosure;
FIG. 3 is a functional block diagram corresponding to a process of making database insert statements according to embodiment 1 of the present disclosure;
fig. 4 is a schematic diagram of a JSON data template according to embodiment 1 of the present disclosure;
fig. 5 is a flowchart illustrating a method for generating a database insert statement according to a second aspect of embodiment 1 of the present disclosure;
fig. 6 is a schematic diagram of an apparatus for performing system testing according to a first aspect of embodiment 2 of the present disclosure;
fig. 7 is a schematic diagram of an apparatus for generating a database insert statement according to a second aspect of embodiment 2 of the present disclosure;
fig. 8 is a schematic diagram of an apparatus for performing system testing according to the first aspect of embodiment 3 of the present disclosure; and
fig. 9 is a schematic diagram of an apparatus for generating a database insert statement according to the second aspect of embodiment 3 of the present disclosure.
Detailed Description
In order to make those skilled in the art better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure. It is to be understood that the described embodiments are merely exemplary of some, and not all, of the present disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
In accordance with the present embodiment, there is provided an embodiment of a method for generating database insertion statements and performing system tests, it being noted that the steps illustrated in the flowchart of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than presented herein.
The method provided by the embodiment can be executed in a mobile terminal, a computer terminal or a similar operation device. Fig. 1 shows a hardware block diagram of a computer terminal (or mobile device) for implementing the method for generating database insertion statements and performing system test. As shown in fig. 1, the computer terminal 10 (or mobile device 10) may include one or more (shown as 102a, 102b, … …, 102 n) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, the computer terminal 10 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuit may be a single stand-alone processing module, or incorporated in whole or in part into any of the other elements in the computer terminal 10 (or mobile device). As referred to in the disclosed embodiments, the data processing circuit acts as a processor control (e.g., selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the method for generating a database insertion statement and performing a system test in the embodiment of the present disclosure, and the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the method for generating a database insertion statement and performing a system test of an application program is implemented. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computer terminal 10 (or mobile device).
It should be noted here that in some alternative embodiments, the computer device (or mobile device) shown in fig. 1 described above may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that fig. 1 is only one example of a particular specific example and is intended to illustrate the types of components that may be present in the computer device (or mobile device) described above.
In the above operating environment, according to a first aspect of the present embodiment, a method for performing system testing is provided. Fig. 2 shows a flow diagram of the method, which, with reference to fig. 2, comprises:
s202: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
s204: and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.
As described in the background, background systems on which mobile phone applications depend are becoming more and more complex with the rapid development of the mobile phone software industry. When testing a background system, a tester usually needs to construct a large amount of complex database test data to verify whether the background system functions normally. However, in the prior art, the construction of a large number of database insertion sentences is mainly completed manually, the data logic represented by each piece of data needs to be designed manually by a tester, if the number of database fields is large, the insertion sentences are long in length and poor in readability, and the designed sentences are very easy to cause problems. Furthermore, if the amount of configuration data required is too large (e.g., ten thousand), the tester will spend a lot of time on the mechanically repetitive job, and it is easy to repeatedly execute statements resulting in repetitive data.
Specifically, for the technical problems in the background art, the technical solution of the present embodiment provides a method for performing system test, and the specific flow of the method is as follows:
firstly, test data in a preset format is generated according to a data template in the preset format and a corresponding expression. For example, and without limitation, the data template is in JSON format (or XML format, XML constructor is designed to implement field search and assignment, and array addition and deletion. The data template (i.e., JSON data template) records test fields contained in the test data, such as: the JSON data template comprises fields of name, age, generator and the like. The expression is used for generating test data in a predetermined format according to the data template, wherein the number of the expression can be multiple, for example: the expression of the name field is a name used to define each piece of test data. Thus, a batch of test data can be constructed according to the data template with the preset format and the corresponding expression.
Further, a corresponding database insertion statement is generated according to the generated test data (that is, the constructed test data is converted into a statement that can be recognized by database software), and then a system test is performed according to the database insertion statement.
In actual operation, the JSON data template is in a text file form, selected data are manually written into the data template, then an expression processing file is opened to fill in the range where the expression and the expression take effect, an expression script file is operated to generate a test data file in the JSON format, then a database is opened and operated to insert sentences to generate a file, batch insert sentences are generated, and finally system test is completed. The process can write and run the corresponding script file by Eclipse software.
In this way, test data for system test is generated in batch through a data template and an expression in a preset format, then a database insert statement is generated according to the test data, and finally the system test is carried out by using the database insert statement. The data template can adopt a JSON format, for example, and the operation process can adopt a script mode to perform operations such as data addition, modification, deletion and the like on the JSON data template through an expression. Therefore, compared with the traditional system test process, the method ensures that testers only pay attention to the collection of the JSON data template and the writing of the expression, gets rid of the step of writing complicated database statements, ensures that the data construction becomes intuitive, efficient and reliable, and achieves the aim of automatically constructing test data in batches. Therefore, the method for simplifying the data construction is realized, the accuracy of the test data is improved, and the technical effects of saving time and labor cost by avoiding a large amount of repeated work are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
It should be added that, in the above operation process, an expression parser and a database statement generator are needed, fig. 3 shows a functional block diagram corresponding to a process of constructing a database insertion statement, where the database batch test data in the diagram corresponds to the database insertion statement described in this embodiment. The design of the expression parser comprises an expression analysis module, a JSON processing module and a construction module (not specifically shown in the figure). The expression analysis module is responsible for searching the processing method corresponding to the expression keywords. The JSON processing module contains the search and setting of fields, addition and deletion of array items. The construction module is responsible for combining the expression analysis module and the JSON processing module, firstly calls the expression analysis module to obtain a required processing method, and then calls the JSON processing module to apply the processing method to generate construction data. The design of the database statement generator comprises two modules, namely a JSON decomposition module and a statement splicing and executing module. The JSON decomposition module decomposes JSON into arrays. The statement splicing module is responsible for splicing the arrays into a target database, inserting statements and running, and can expand and support various databases including MySQL, MongoDB, HBase and the like.
Optionally, constructing the expression according to the following rule: the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or a second test field of at least a portion of the test data contains a predetermined character.
Specifically, the expression is constructed according to rules, and the constructed expression is placed in a txt text file. This file contains the JSON template name, where the first rule may be that the value of the first test field of at least a portion of the test data is within a predetermined range of values, such as: copying ten thousand pieces of data according to the template, wherein the first 5000 pieces of column values are in the range of 30-50, and the corresponding expression is as follows: generate 10000; set 30< age <50, 0-4999. The second rule may be that a second test field of at least a portion of the test data contains predetermined characters, such as: the last 5000 name column values contain the character 'zhangsan', and the corresponding expression is: string, contacts (name, "zhang san"), 5000-. It should be added that the number of the expressions, such as but not limited to the two mentioned above, can be constructed according to the conditions required by the actual test process. Therefore, by the mode, the condition and the range of the required construction data are controlled by the expression, the data construction process is simpler and more intuitive, and the readability is greatly improved.
Optionally, constructing a data template in a predetermined format by: querying data by running a conditional query statement in a database; and editing the inquired data according to a preset format to construct a data template of the preset format.
Specifically, in the operation of constructing a data template (JSON data template), the JSON data template is generated by collecting a field template of a database, and data is firstly queried by running a conditional query statement in the database. For example: the data queried are: name Zhang III, age 18, geneder Man, height 175, weight 65.2, addressxx City xx area, class language, score 85.5. Then, the inquired data is edited according to a preset format to construct a data template of the preset format. The JSON data format is an array format, an array name represents the name of a data table, a field name represents the column name of the data table, and a field value represents the value of the data table. FIG. 4 shows JSON data templates corresponding to the inquired data, and the data is saved as a txt text file after the template collection is completed. In addition, the generated test data can be modified and/or deleted according to the data template. Therefore, based on the addition, deletion or change of data of the data template, a tester only needs to pay attention to the field needing to be changed without paying attention to all the fields, so that the data construction process is simplified, and the construction process is simpler and easier.
Therefore, according to the first aspect of the embodiment, compared with the conventional system testing method, the provided method for performing system testing allows testers to focus on the collection of the JSON data templates and the writing of the expressions, gets rid of the complicated step of writing database statements, allows data construction to be intuitive, efficient and reliable, and achieves the purpose of automatically constructing test data in batches. Therefore, the method for simplifying the data construction is realized, the accuracy of the test data is improved, and the technical effects of saving time and labor cost by avoiding a large amount of repeated work are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
Further, according to a second aspect of the present embodiment, there is provided a method of generating a database insert statement. Fig. 5 shows a flow diagram of the method, which, with reference to fig. 5, comprises:
s502: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
s504: and generating a corresponding database insertion statement according to the generated test data.
Specifically, test data in a predetermined format is generated according to a data template in the predetermined format and a corresponding expression. For example, and without limitation, the data template is in JSON format (or XML format, XML constructor is designed to implement field search and assignment, and array addition and deletion. The data template (i.e., JSON data template) records test fields contained in the test data, such as: the JSON data template comprises fields of name, age, generator and the like. The expression is used for generating test data in a predetermined format according to the data template, wherein the number of the expression can be multiple, for example: the expression of the name field is a name used to define each piece of test data. Thus, a batch of test data can be constructed according to the data template with the preset format and the corresponding expression.
Further, corresponding database insertion statements are generated from the generated test data (i.e., the constructed test data is converted into statements recognizable by the database software).
In this way, test data for system testing is generated in batches through data templates and expressions in a predetermined format, and then corresponding database insert statements are generated according to the test data. The data template may adopt, for example, a JSON format, and the operation process may adopt a script mode to perform operations such as data addition, modification, deletion and the like on the JSON data template through parsing an expression. Therefore, compared with the traditional manual compiling of test statements, the method enables testers to pay attention to the collection of JSON data templates and the compiling of expressions only, gets rid of the step of compiling complicated database statements, enables data construction to be visual, efficient and reliable, and achieves the purpose of automatically constructing test data in batches. Therefore, the method for simplifying the data construction is realized, the accuracy of the test data is improved, and the technical effects of saving time and labor cost by avoiding a large amount of repeated work are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
Optionally, constructing an expression according to the following rule: the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or a second test field of at least a portion of the test data contains a predetermined character.
Specifically, the expression is constructed according to rules, and the constructed expression is placed in a txt text file. This file contains the JSON template name, where the first rule may be that the value of the first test field of at least a portion of the test data is within a predetermined range of values, such as: copying ten thousand pieces of data according to the template, wherein the first 5000 pieces of column values are in the range of 30-50, and the corresponding expression is as follows: generate 10000; set 30< age <50, 0-4999. The second rule may be that a second test field of at least a portion of the test data contains predetermined characters, such as: the last 5000 name column values contain the character 'zhangsan', and the corresponding expression is: string, contacts (name, "zhang san"), 5000-. It should be added that the number of the expressions, such as but not limited to the two mentioned above, can be constructed according to the conditions required by the actual test process. Therefore, by the mode, the condition and the range of the required construction data are controlled by the expression, the data construction process is simpler and more intuitive, and the readability is greatly improved.
Optionally, constructing a data template in a predetermined format by: querying data by running a conditional query statement in a database; and editing the inquired data according to a preset format to construct a data template of the preset format.
Specifically, in the operation of constructing a data template (JSON data template), the JSON data template is generated by collecting a field template of a database, and data is firstly queried by running a conditional query statement in the database. For example: the data queried are: name Zhang III, age 18, geneder Man, height 175, weight 65.2, addressxx City xx area, class language, score 85.5. Then, the inquired data is edited according to a preset format to construct a data template of the preset format. The JSON data format is an array format, an array name represents the name of a data table, a field name represents the column name of the data table, and a field value represents the value of the data table. FIG. 4 shows JSON data templates corresponding to the inquired data, and the data is saved as a txt text file after the template collection is completed. In addition, the generated test data can be modified and/or deleted according to the data template. Therefore, based on the addition, deletion or change of data of the data template, a tester only needs to pay attention to the field needing to be changed without paying attention to all the fields, so that the data construction process is simplified, and the construction process is simpler and easier.
Further, referring to fig. 1, according to a third aspect of the present embodiment, there is provided a storage medium 104. The storage medium 104 comprises a stored program, wherein the method of any of the above is performed by a processor when the program is run.
Therefore, according to the embodiment, testers only pay attention to the collection of the JSON data templates and the compiling of the expressions, the step of compiling complicated database statements is eliminated, the data construction becomes visual, efficient and reliable, the purpose of automatically constructing the test data in batches is achieved, the mode of simplifying the data construction is achieved, the accuracy of the test data is improved, and the technical effects that a large amount of repeated work is avoided, and the time and the labor cost are saved are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 2
Fig. 6 shows an apparatus 600 for performing a system test according to the first aspect of the present embodiment, the apparatus 600 corresponding to the method according to the first aspect of embodiment 1. Referring to fig. 6, the apparatus 600 includes: a data generating module 610, configured to generate test data in a predetermined format according to a data template in the predetermined format and a corresponding expression, where the data template records test fields included in the test data, and the expression is used to generate the test data in the predetermined format according to the data template; and a test module 620, configured to generate a corresponding database insertion statement according to the generated test data, and perform a system test using the generated database insertion statement.
Optionally, the method further comprises: an expression construction module for constructing an expression according to the following rules: the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or a second test field of at least a portion of the test data contains a predetermined character.
Optionally, the data template generating module is further included for generating a data template in a predetermined format by: querying data by running a conditional query statement in a database; and editing the inquired data according to a preset format to construct a data template of the preset format.
Furthermore, fig. 7 shows an apparatus 700 for generating a database insertion statement according to the second aspect of the present embodiment, which apparatus 700 corresponds to the method according to the second aspect of the embodiment 1. Referring to fig. 7, the apparatus 700 includes: a first generating module 710, configured to generate test data in a predetermined format according to a data template in the predetermined format and a corresponding expression, where the data template records a test field included in the test data, and the expression is used to generate the test data in the predetermined format according to the data template; and a second generating module 720, configured to generate a corresponding database insert statement according to the generated test data.
Optionally, the method further comprises: a first constructing module for constructing an expression according to the following rules: the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or a second test field of at least a portion of the test data contains a predetermined character.
Optionally, the method further comprises: a second constructing module for constructing a data template of a predetermined format by: querying data by running a conditional query statement in a database; and editing the inquired data according to a preset format to construct a data template of the preset format.
Therefore, according to the embodiment, by the device 700 for generating the database insert statement and the device 600 for performing the system test, a tester can focus on the collection of the JSON data template and the writing of the expression, so that the complicated step of writing the database statement is eliminated, the data construction becomes intuitive, efficient and reliable, and the purpose of automatically constructing the test data in batch is achieved. Therefore, the method for simplifying the data construction is realized, the accuracy of the test data is improved, and the technical effects of saving time and labor cost by avoiding a large amount of repeated work are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
Example 3
Fig. 8 shows an apparatus 800 for performing system testing according to the first aspect of the present embodiment, the apparatus 800 corresponding to the method according to the first aspect of embodiment 1. Referring to fig. 8, the apparatus 800 includes: a first processor 810; and a first memory 820 coupled to the first processor 810 for providing instructions to the first processor 810 to process the following process steps: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.
Optionally, the first memory 820 is further configured to provide the first processor 810 with instructions for processing the following processing steps: an expression is constructed according to the following rules: the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or a second test field of at least a portion of the test data contains a predetermined character.
Optionally, the first memory 820 is further configured to provide the first processor 810 with instructions for processing the following processing steps: constructing a data template of a predetermined format by: querying data by running a conditional query statement in a database; and editing the inquired data according to a preset format to construct a data template of the preset format.
Furthermore, fig. 9 shows an apparatus 900 for generating a database insertion statement according to the second aspect of the present embodiment, the apparatus 900 corresponding to the method according to the second aspect of the embodiment 1. Referring to fig. 9, the apparatus 900 includes: a second processor 910; and a second memory 920, coupled to the second processor 910, for providing instructions to the second processor 910 to process the following steps: generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and generating a corresponding database insertion statement according to the generated test data.
Optionally, the second memory 920 is further configured to provide the second processor 910 with instructions to process the following processing steps: an expression is constructed according to the following rules: the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or a second test field of at least a portion of the test data contains a predetermined character.
Optionally, the second memory 920 is further configured to provide the second processor 910 with instructions to process the following processing steps: constructing a data template of a predetermined format by: querying data by running a conditional query statement in a database; and editing the inquired data according to a preset format to construct a data template of the preset format.
Therefore, according to the embodiment, by the device 900 for generating the database insert statement and the device 800 for performing the system test, a tester can focus on the collection of the JSON data template and the writing of the expression, so that the complicated step of writing the database statement is eliminated, the data construction becomes intuitive, efficient and reliable, and the purpose of automatically constructing the test data in batch is achieved. Therefore, the method for simplifying the data construction is realized, the accuracy of the test data is improved, and the technical effects of saving time and labor cost by avoiding a large amount of repeated work are achieved. And then solved the use artifical manual design a large amount of test data that exist among the prior art, not only the readability is poor and the problem appears easily, but also the technical problem on the repeated work of time of wasting time and manpower in machinery.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, 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, units or modules, and may be in an electrical 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 invention 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 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, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A method of performing system testing, comprising:
generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.
2. The method of claim 1, further comprising constructing the expression according to the following rules:
the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or
The second test field of at least a portion of the test data contains a predetermined character.
3. The method of claim 1, further comprising constructing the data template in the predetermined format by:
querying data by running a conditional query statement in a database; and
editing the inquired data according to the preset format to construct a data template of the preset format.
4. A method of generating a database insert statement, comprising:
generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
and generating a corresponding database insertion statement according to the generated test data.
5. The method of claim 4, further comprising constructing the expression according to the following rules:
the value of the first test field of at least a portion of the test data is within a predetermined range of values; and/or
The second test field of at least a portion of the test data contains a predetermined character.
6. A storage medium comprising a stored program, wherein the method of any one of claims 1 to 5 is performed by a processor when the program is run.
7. An apparatus for performing system testing, comprising:
the data generating module is used for generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
and the test module is used for generating a corresponding database insertion statement according to the generated test data and carrying out system test by using the generated database insertion statement.
8. An apparatus for generating a database insert statement, comprising:
the test data processing system comprises a first generation module, a second generation module and a processing module, wherein the first generation module is used for generating test data in a preset format according to a data template in the preset format and a corresponding expression, the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
and the second generation module is used for generating a corresponding database insertion statement according to the generated test data.
9. An apparatus for performing system testing, comprising:
a first processor; and
a first memory coupled to the first processor for providing instructions to the first processor to process the following process steps:
generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
and generating a corresponding database insertion statement according to the generated test data, and performing system test by using the generated database insertion statement.
10. An apparatus for generating a database insert statement, comprising:
a second processor; and
a second memory coupled to the second processor for providing instructions to the second processor to process the following process steps:
generating test data in a preset format according to a data template in the preset format and a corresponding expression, wherein the data template records test fields contained in the test data, and the expression is used for generating the test data in the preset format according to the data template; and
and generating a corresponding database insertion statement according to the generated test data.
CN201910668132.4A 2019-07-23 2019-07-23 Method and device for generating database insertion statement and performing system test Pending CN112286783A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910668132.4A CN112286783A (en) 2019-07-23 2019-07-23 Method and device for generating database insertion statement and performing system test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910668132.4A CN112286783A (en) 2019-07-23 2019-07-23 Method and device for generating database insertion statement and performing system test

Publications (1)

Publication Number Publication Date
CN112286783A true CN112286783A (en) 2021-01-29

Family

ID=74418669

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910668132.4A Pending CN112286783A (en) 2019-07-23 2019-07-23 Method and device for generating database insertion statement and performing system test

Country Status (1)

Country Link
CN (1) CN112286783A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102637214A (en) * 2012-04-28 2012-08-15 中国工商银行股份有限公司 Method and system for synchronizing general data among database services
CN102760096A (en) * 2011-04-27 2012-10-31 阿里巴巴集团控股有限公司 Test data generation method, unit testing method and unit testing system
US20140006459A1 (en) * 2012-06-29 2014-01-02 Hewlett-Packard Development Company, L.P. Rule-based automated test data generation
CN104615667A (en) * 2015-01-13 2015-05-13 联动优势电子商务有限公司 Basic data generation method and device and test data generation method and device
CN105512042A (en) * 2015-12-22 2016-04-20 广东金赋信息科技有限公司 Automatic generation method and device for testing data of database and testing system
CN106897205A (en) * 2015-12-18 2017-06-27 阿里巴巴集团控股有限公司 A kind of test data generating method and device
CN106980617A (en) * 2016-01-15 2017-07-25 航天信息股份有限公司 A kind of method and system based on JSON sentence operating databases
CN109522228A (en) * 2018-11-15 2019-03-26 深圳乐信软件技术有限公司 Interface automatic test data configuration method, apparatus, platform and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760096A (en) * 2011-04-27 2012-10-31 阿里巴巴集团控股有限公司 Test data generation method, unit testing method and unit testing system
CN102637214A (en) * 2012-04-28 2012-08-15 中国工商银行股份有限公司 Method and system for synchronizing general data among database services
US20140006459A1 (en) * 2012-06-29 2014-01-02 Hewlett-Packard Development Company, L.P. Rule-based automated test data generation
CN104615667A (en) * 2015-01-13 2015-05-13 联动优势电子商务有限公司 Basic data generation method and device and test data generation method and device
CN106897205A (en) * 2015-12-18 2017-06-27 阿里巴巴集团控股有限公司 A kind of test data generating method and device
CN105512042A (en) * 2015-12-22 2016-04-20 广东金赋信息科技有限公司 Automatic generation method and device for testing data of database and testing system
CN106980617A (en) * 2016-01-15 2017-07-25 航天信息股份有限公司 A kind of method and system based on JSON sentence operating databases
CN109522228A (en) * 2018-11-15 2019-03-26 深圳乐信软件技术有限公司 Interface automatic test data configuration method, apparatus, platform and storage medium

Similar Documents

Publication Publication Date Title
CN108197114B (en) Method and device for detecting table data, storage medium and electronic device
CN106598612B (en) Operation method and system for data table in database
CN107015804B (en) Method and system for rapidly developing project by configuring API
CN114741070B (en) Code generation method, device, electronic equipment and storage medium
US9195456B2 (en) Managing a catalog of scripts
CN106681903B (en) Method and device for generating test case
CN106844772A (en) The update method and device of application database
CN111158656B (en) Test code generation method and device based on fruit tree method
CN107451112B (en) Form tool data checking method, device, terminal equipment and storage medium
CN109710631A (en) Auxiliary generates method, apparatus, equipment and the computer storage medium of SQL code
CN110209378A (en) Page generation method, device, terminal and storage medium
CN111143228B (en) Test code generation method and device based on decision table method
CN114090671A (en) Data import method and device, electronic equipment and storage medium
CN117493158A (en) Test method and device, electronic equipment and storage medium
CN114579118A (en) Programming method and system, equipment, storage medium
CN112988758B (en) Target object positioning method and device, electronic equipment and storage medium
CN110647371A (en) Multi-language resource file analysis method and system based on service configuration
CN108664505B (en) Method and device for exporting database table structure
CN112948264A (en) Test task execution method, device, system, storage medium and electronic device
CN112286783A (en) Method and device for generating database insertion statement and performing system test
CN111859863A (en) Document structure conversion method and device, storage medium and electronic equipment
CN111488368A (en) Data query method and device and electronic equipment
CN112306843A (en) Test method, test device and storage medium
CN106648618B (en) Text information generation method and device for virtual application
CN116431517A (en) Intelligent keyword prompting method and device for automatic test platform

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