CN114238121A - Test case generation method and server - Google Patents

Test case generation method and server Download PDF

Info

Publication number
CN114238121A
CN114238121A CN202111564228.XA CN202111564228A CN114238121A CN 114238121 A CN114238121 A CN 114238121A CN 202111564228 A CN202111564228 A CN 202111564228A CN 114238121 A CN114238121 A CN 114238121A
Authority
CN
China
Prior art keywords
name
test
result
storage process
data
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
CN202111564228.XA
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202111564228.XA priority Critical patent/CN114238121A/en
Publication of CN114238121A publication Critical patent/CN114238121A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

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 provides a test case generation method and device, which can be applied to the financial field or other fields. The method comprises the following steps: generating a test script for performing the steps of: importing test data, executing a storage process, and asserting a test result based on an expected result; acquiring the name of a storage process, the name of a dependency table and the name of a result table; reading the dependency table and the result table from the database according to the name of the dependency table and the name of the result table; obtaining test data based on the dependency table; calling the storage process according to the name of the storage process, and executing the storage process aiming at the result table to obtain an expected result; based on the test script, the test data, the stored procedure, and the expected results, a test case is obtained. The whole process does not need encoding of testers, the workload of the testers is greatly reduced, and the compiling efficiency and quality of test cases are improved.

Description

Test case generation method and server
Technical Field
The application relates to the field of finance, in particular to a test case generation method and a server.
Background
The storage process is to implement a Structured Query Language (SQL) statement set compiled and stored in a database, and is used to implement some specific functions. The test cases written by the tester for the storage process can be automatically tested in the development process. Wherein the test case comprises test data, expected result, test script, etc. However, a great deal of labor and time are consumed for manually writing the test cases, and the coding levels of the testers are different, so that the writing efficiency of the test cases is low, the quality of the test scripts in the test cases is not high, and the efficient test in the storage process is not facilitated.
Disclosure of Invention
The application provides a test case generation method and a server, so that the time for manually compiling the test case can be reduced, the compiling efficiency and quality of the test case are improved, and the test efficiency in the storage process is further improved.
In a first aspect, the present application provides a method for generating a test case, which may be performed by a server, or may also be performed by a component (e.g., a chip, a system-on-a-chip, etc.) configured in the server, and is not limited in this application.
Illustratively, the method comprises: generating a test script for performing the steps of: importing test data, executing a storage process, and asserting a test result based on an expected result; acquiring the name of the storage process, the name of the dependency table and the name of the result table; reading the dependency table and the result table from a database according to the name of the dependency table and the name of the result table; obtaining the test data based on the dependency table; calling the storage process according to the name of the storage process, and executing the storage process aiming at the result table to obtain the expected result; and obtaining the test case based on the test script, the test data, the storage process and the expected result.
In the technical scheme, the server generates a test script comprising a test step, obtains test data through the obtained name of the dependency table, calls a storage process according to the obtained name of the storage process, executes the storage process aiming at the result table to obtain an expected result, and finally, the server can obtain a test case based on the test data, the expected result, the storage process and the test script.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, the obtaining the name of the storage procedure, the name of the dependency table, and the name of the result table includes: responding to the operation of a tester, and acquiring the name of the storage process; generating and outputting a first template based on the name of the stored process; and acquiring a second template, wherein the second template is obtained based on the updating of the first template by the tester, and the second template comprises the name of the dependency table and the name of the result table.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, the second template further includes one or more of the following: the screening conditions corresponding to the dependency table, the screening conditions corresponding to the result table, the sorting fields corresponding to the result table, and the culling fields corresponding to the result table.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, before the invoking the stored procedure according to the name of the stored procedure, the method further includes: and encapsulating the storage process into an entity class, wherein the entity class is used for calling the storage process according to the name of the storage process.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, the test script is further configured to perform the following steps: backing up the data and recovering the data.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, the backing up data includes: backing up original data of the dependency table and the result table; and the recovering the data comprises: restoring the dependency table and the result table to a state prior to execution of a storage process based on the backed up original data of the dependency table and the result table.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, after the generating the test script, the method further includes: building a plurality of building blocks, the building blocks corresponding to a plurality of steps in the test script one-to-one, each building block providing an interface for invoking the corresponding step to implement the plurality of steps in the test script through the plurality of building blocks.
With reference to the first aspect, in a certain possible implementation manner of the first aspect, the method further includes: and testing the storage process based on the test case.
In a second aspect, the present application provides a server comprising: the device comprises a generating unit, an acquiring unit and a processing unit, wherein the generating unit is used for generating a test script, and the test script is used for executing the following steps: importing test data, executing a storage process, and asserting a test result based on an expected result; the acquisition unit is used for acquiring the name of the storage process, the name of the dependency table and the name of the result table, and reading the dependency table and the result table from a database according to the name of the dependency table and the name of the result table; the processing unit is used for obtaining the test data based on the dependency table, calling the storage process according to the name of the storage process, executing the storage process aiming at the result table to obtain the expected result, and obtaining the test case based on the test script, the test data, the storage process and the expected result.
In a third aspect, the present application provides a server comprising a processor and a memory, the processor and the memory being coupled, the memory being configured to store a computer program, the processor being configured to execute the computer program to cause the server to implement the method described in any one of the possible implementations of the first aspect and the first aspect.
Optionally, the server in the third aspect further comprises a memory.
Optionally, the server in the third aspect further comprises a communication interface, the processor being coupled to the communication interface.
In a fourth aspect, the present application provides a chip system, which includes at least one processor, and is configured to support implementation of functions involved in any one of the possible implementations of the first aspect and the first aspect, for example, receiving or processing data involved in the above methods, and the like.
In one possible design, the system-on-chip further includes a memory to hold program instructions and data, the memory being located within the processor or external to the processor.
The chip system may be formed by a chip, and may also include a chip and other discrete devices.
In a fifth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program (which may also be referred to as code, or instructions), which when executed by a processor, causes the method of any one of the possible implementations of the first aspect and the first aspect described above to be performed.
In a sixth aspect, the present application provides a computer program product comprising: computer program (also called code, or instructions), which when executed, causes the method in any of the possible implementations of the first aspect and the first aspect described above to be performed.
It should be understood that the second aspect to the sixth aspect of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by the aspects and the corresponding possible implementations are similar and will not be described again.
It should also be understood that the test case generation method and the server provided by the application can be applied to the financial field and can also be applied to other fields. This is not a limitation of the present application.
Drawings
FIG. 1 is a schematic diagram of an application scenario suitable for a method provided by an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for generating a test case according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a stored procedure test flow provided by an embodiment of the present application;
FIG. 4 is a schematic diagram of a method for generating a test case according to an embodiment of the present disclosure;
FIG. 5 is a schematic block diagram of a server provided by an embodiment of the present application;
fig. 6 is another schematic block diagram of a server provided in an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
In order to better understand the method for generating the test case provided in the embodiments of the present application, first, the terms referred to in the present application are briefly described.
1. And (3) a storage process: the SQL statement set is an SQL statement set compiled in advance and stored in a database, and is used for implementing some specific functions, such as adding, deleting, modifying, querying and the like to data in a certain table. Each storage process has a corresponding name, so that when a certain storage process needs to be operated, the storage process can be directly called, the working process of an application developer is greatly simplified, and the data processing efficiency is improved.
It should be noted that, in the storage process, before the storage process is put into production, a tester is required to test the storage process so as to check whether the operation result of the storage process is accurate, which is beneficial to improving the quality of the storage process.
2. Test case (test case): the test case may also be referred to as a test case, and refers to a description of a test task performed on a specific software product, and embodies a test scheme, a method, a policy, and the like. The test cases include test data, expected results, test scripts, and the like.
3. Test script (testing script): refers to a series of instructions for a particular test that may be executed by the automated test tool. Test scripts are computer readable instructions that automatically perform a test procedure (part of a test procedure). The test scripts may be written in a programming language manually or generated automatically using automated test tools.
4. The components are as follows: the software system architecture oriented reusable software module is a reusable software component and can be used for constructing other software. It may be an encapsulated object class, a class tree, some function module, a software framework (framework), a software framework (or architecture), a document, a parser, a design pattern (pattern), etc. The building blocks may be in the form of a logically compact package of program code. In embodiments of the present application, a component may be used to provide an interface to invoke its corresponding test step.
In order to facilitate understanding of the method provided by the present application, an application scenario applicable to the method provided by the present application will be described in detail with reference to fig. 1.
Fig. 1 is a schematic view of an application scenario applicable to the method provided in the embodiment of the present application. As shown in fig. 1, a tester may write a test case of a stored procedure through a terminal device 110, where the terminal device 110 may include, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and other devices. Terminal device 110 may be communicatively coupled to server 120, and server 120 may present a user interface through terminal device 110. The user interface provides an interface for the tester to interact with the server 120, and the tester can send data to the server 120 by inputting or selecting the data from the user interface.
In the embodiment of the present application, the server 120 may automatically test the stored procedures of a database (e.g., an Oracle database) based on test cases written by a tester. Where the database may be deployed on server 120. The test cases include test data, expected results, test scripts, and the like. The Oracle database is a relational database developed by Oracle corporation.
It should be understood that the scenario shown in fig. 1 is only an example, and the server 120 may be one physical device or a server cluster formed by multiple physical devices. There may be more terminal devices connected to the server 120. This is not a limitation of the present application.
With the increasing of the code amount and the increasing of the version updating speed in the storage process, the testers write test cases one by one aiming at a large number of storage processes, so that not only is a large amount of labor and time consumed, but also the coding levels of the testers are uneven, so that the problems that the writing efficiency of the test cases is low, the quality of test scripts in the test cases is not high and the like are caused, and the efficient test of the storage process is not facilitated.
In order to solve the above problems, the present application provides a method for generating a test case, in which a server generates a test script including a test step, obtains test data based on an obtained name of a dependency table, calls a storage process according to an obtained name of the storage process, and executes the storage process for a result table to obtain an expected result. The server can obtain the test case based on the test data, the expected result, the storage process and the test script, and the whole process does not need encoding of testers, so that the workload of the testers is greatly reduced, the compiling efficiency and quality of the test case are improved, and the testing efficiency of the storage process is improved.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments.
It should be noted that the embodiments shown below describe the method provided by the embodiments of the present application with a server as an execution subject. It should be understood that the embodiments shown below, although described by taking a server as an example, should not constitute any limitation on the execution subject of the method. The method provided by the embodiment of the present application can be executed as long as it is possible to execute a program in which codes of the method provided by the embodiment of the present application are recorded. For example, the server may be replaced with a component (e.g., a chip system, or other functional modules capable of calling a program and executing the program) configured in the server. The embodiments of the present application do not limit this.
Fig. 2 is a flowchart illustrating a method 200 for generating a test case according to an embodiment of the present application, where the method 200 illustrated in fig. 2 may include steps 210 to 260, and each step in the method 200 will be described in detail below.
In step 210, the server generates a test script.
The test script is used for executing the following steps: importing test data, performing a storage process, and asserting a test result based on an expected result.
The step of importing the test data refers to importing the test data prepared in advance into a database, that is, importing the test data in the test case generated by the server into the database to test the storage process, so that the test data in the test case can be repeatedly used in a plurality of test environments. In addition, the test data used in a plurality of test environments are the same, so that the difference of the test results obtained in different test environments in the storage process can be distinguished conveniently. Executing a stored procedure refers to calling and executing the stored procedure that needs to be tested. Asserting the test result based on the expected result refers to comparing the test result with the expected result to determine whether the test result achieves the expected result.
Illustratively, the server generates a test script, and running the test script may perform the following steps: and importing the test data into a database, calling and executing the tested storage process, comparing the test result with the expected result, and determining whether the expected result is achieved.
Optionally, the test script is further configured to perform the following steps: backing up the data and recovering the data.
The server may also backup data in the test environment before importing the test data, and restore the data in the test environment after asserting a test result based on an expected result. The test environment includes the raw data of the dependency and result tables. The original data of the result table refers to the data of the result table when the storage process is not executed. The data in the test environment is backed up and restored, and the data in the test environment is prevented from being changed in the test process of the storage process, so that the performance of other test activities in the same test environment is not influenced.
Optionally, backing up the data includes: backing up original data of the dependency table and the result table; and recovering the data, including: and restoring the dependency table and the result table to the state before the storage process is executed based on the original data of the backed-up dependency table and result table.
For example, the server may backup the original data for the entire dependency table and the entire results table. For another example, the server may back up the data in the dependency table that needs to be read and the original data in the result table that needs to be modified during the operation of the storage process, in other words, the server may back up only the data that needs to be used without backing up all the data in the dependency table and the result table, which is beneficial to reducing the space occupied by the data.
After the server runs the storage process and obtains the test result, the current dependency table and result table can be replaced by the original data of the backed up dependency table and result table, so that the dependency table and result table are restored to the state before the storage process is run.
Optionally, after generating the test script, the method further includes: and constructing a plurality of building blocks, wherein the plurality of building blocks correspond to a plurality of steps in the test script one by one, and each building block provides an interface for calling the corresponding step so as to realize the plurality of steps in the test script through the plurality of building blocks.
The server may package the steps in the test script into a plurality of building blocks, in other words, one building block for each step. The server tests different stored procedures may invoke the above-described plurality of components.
For example, when the server tests a certain storage process and needs to backup data, a component corresponding to the backup of the data may be called. It will be appreciated that the building blocks provide an interface for invoking the corresponding steps, and that the server may perform the steps of backing up the data upon invoking the building blocks.
In step 220, the server obtains the name of the stored procedure, the name of the dependency table, and the name of the result table.
The dependency table refers to a table on which the stored procedure depends during the operation, that is, a table accessed during the operation of the stored procedure. The result table is a table modified by running the above-described storing process. For example, the data in table 1 is read during the running process of the storage process, and table 2 is modified, table 1 may be referred to as a dependency table, table 2 may be referred to as a result table, and the data in table 2 before being modified is the original data of the result table.
It should be noted that, if the data in table 1 needs to be read and changed during the operation of the storage process, table 1 is both a dependency table and a result table. Therefore, the dependency table and the result table may be the same table or different tables, which is not limited in this embodiment.
Optionally, obtaining the name of the stored procedure, the name of the dependency table, and the name of the result table includes: responding to the operation of a tester, and acquiring the name of a storage process; generating and outputting a first template based on the name of the stored process; and acquiring a second template, wherein the second template is obtained based on the updating of the first template by the tester, and the second template comprises the name of the dependency table and the name of the result table.
Illustratively, the server responds to the operation of a tester, obtains the name of the tested stored process, and generates and outputs a first template according to the name of the stored process. For example, the first template may be an Excel template. The first template is used for indicating a tester to fill in the name of a dependency table and the name of a result table corresponding to the storage process. And filling the name of the dependency table and the name of the result table corresponding to the tested storage process in the first template by a tester to obtain a second template. And responding to the operation of the tester, and acquiring the second template, namely acquiring the name of the dependency table and the name of the result table by the server.
It will be appreciated that the server may also obtain the names of the stored procedures, the names of the dependency tables, and the names of the result tables in other ways. The embodiments of the present application do not limit this. For example, the tester directly inputs the name of the stored procedure, the name of the dependency table and the name of the result table to the server in a file form through the user interface, and in response to the operation of the tester, the server obtains the name of the stored procedure, the name of the dependency table and the name of the result table.
Optionally, the second template further comprises one or more of: the method comprises the steps of screening conditions corresponding to a dependency table, screening conditions corresponding to a result table, sorting fields corresponding to the result table and removing fields corresponding to the result table.
It is understood that only a part of the data in the dependency table may need to be read during the operation of the storage process, or only some data in the result table may need to be modified, so that the server may obtain the filtering condition to determine the data in the dependency table that needs to be read and the data in the result table that needs to be modified. When the test result is compared with the expected result, the sorting field corresponding to the result table is used for indicating the columns used for sorting the comparison result, and the removing field corresponding to the result table is used for indicating the columns needing to be removed.
In step 230, the server reads the dependency table and the result table from the database based on the names of the dependency table and the result table.
One possible design is that the database stores the dependency table and the result table in advance, after the server obtains the name of the dependency table and the name of the result table, the server reads the dependency table from the database according to the name of the dependency table, and reads the result table from the database according to the name of the result table.
Another possible design is that the server obtains the name and the screening condition of the dependency table, and the name and the screening condition of the result table, and then reads part of the data in the dependency table from the database according to the name and the screening condition of the dependency table, and reads part of the data in the result table from the database according to the name and the screening condition of the result table.
Table 1 is an example of a dependency table provided in an embodiment of the present application. As shown in TABLE 1, the name of the dependency TABLE is "destination _ TABLE _ 1", AND the screening condition is "WHERE COLUMN1 ═ DATA1'AND COLUMN2 ═ DATA 2'", which indicates that the COLUMNs including the parameter "DATA 1" AND the parameter "DATA 2" are screened. Whether the table is restored to be 'yes' before the next test activity, namely after the current storage process is executed, the data of the dependent table is restored to the data before the storage process is executed.
TABLE 1
Figure BDA0003421676800000091
Table 2 is an example of a result table provided in the embodiments of the present application. As shown in TABLE 2, the name of the RESULT TABLE is "RESULT _ TABLE _ 1", and the screening condition is "WHERE COLUMN1 ═ DATA 1'", which indicates that the COLUMN containing the parameter "DATA 1" is screened. The sorting fields corresponding to the result table are "COLUMN 2, COLUMN 3", the culling fields corresponding to the result table are "COLUMN 4, COLUMN 5", and whether the backup is "yes".
TABLE 2
Figure BDA0003421676800000092
In step 240, the server obtains test data based on the dependency table.
And the server can obtain the test data according to the obtained dependency table. It should be understood that the dependency table includes data that needs to be read during the operation of the stored procedure. The server may screen out data that needs to be read in the operation process of the storage process as test data, and may also use all data in the dependency table as test data, which is not limited in this embodiment of the application.
It is understood that the server may also fill in the name and the test data of the stored procedure in the data pool file, so as to test the stored procedure subsequently in different testing environments by using the test data in the data pool file.
In step 250, the server calls the stored procedure according to the name of the stored procedure, and executes the stored procedure according to the result table to obtain the expected result.
One possible design is that the server calls the stored procedure according to its name, executes the stored procedure against the result table, and obtains the execution result, which the server can use as the expected result. For example, the storing process may delete a column in the result table, and the result table obtained after the storing process is performed on the result table may be used as the expected result.
Yet another possible design is that the server may respond to the operation of the tester to achieve the desired result. For example, the server executes the storage process for the result table, and after the execution result is obtained, the tester modifies the execution result and takes the modified result as the expected result.
Optionally, before the calling the stored procedure according to the name of the stored procedure, the method further includes: and encapsulating the storage process into an entity class, wherein the entity class is used for calling the storage process according to the name of the storage process.
The server can encapsulate the stored procedures into an entity class, and the entity class is used for calling the stored procedures by the server according to the names of the stored procedures. The storage process is packaged into an entity class, so that a tester can finish the calling of the storage process without considering the data type of the name of the storage process. The data type may be any one of a character string type, a numerical value type, and a cursor type.
For example, the data type of the name of the stored procedure may be a string type and the data type of the expected result may be a cursor type. The embodiments of the present application do not limit this.
In step 260, the server obtains test cases based on the test scripts, test data, stored procedures, and expected results.
And the server can obtain a test case corresponding to the storage process according to the test script, the test data, the storage process and the expected result.
One possible implementation is that the server may populate a data pool file with the names of stored procedures, test data, expected results, and test scripts that may be used for testing the stored procedures in different testing environments.
Optionally, the method further comprises: and testing the storage process based on the test case.
After the server generates the test case, the storage process can be tested in different test environments based on the test case to determine whether the test result reaches the expected result, so that the quality of the storage process is ensured.
Fig. 3 is a schematic diagram of a storage process test flow provided in an embodiment of the present application.
As shown in fig. 3, the server backs up the data in step 310. For example, the server backs up the original data of the dependency and result tables.
In step 320, the server imports the test data. It should be understood that the server generates test cases including test data, and the server imports the test data into the database so that the server can test the stored procedures conveniently.
In step 330, the server invokes and executes the stored procedure. For example, the server may invoke the stored procedure by its name. The data type of the name of the stored procedure may be a character string, a numerical value, and the like, which is not limited in this embodiment of the application.
In step 340, the server compares the test results with expected results. After the server executes the storage process, a test result is generated, and if the storage process deletes data of a certain table, the server can generate the deleted table, compare the table with an expected result, and determine whether the expected result is achieved.
In step 350, the server recovers the data. For example, the server may replace the dependency and result tables after executing the stored procedures with the original data of the backed up dependency and result tables.
Fig. 4 is an example of a method for generating a test case according to an embodiment of the present application. As shown in fig. 4, in step 410, the server generates a first template from the name of the stored procedure. In step 420, the tester fills in the first template, resulting in a second template. In step 430, the tester uploads the second template to the server. For example, the tester may input the second template to the server through the user interface. In step 440, the server generates a stored procedure entity class from the name of the stored procedure. In step 450, the server populates the data pool file with the name of the stored procedure. In step 460, the server reads the dependency table from the database according to the name of the dependency table and retrieves the test data from the dependency table. In step 470, the server invokes and executes the stored procedure, with the desired result. In step 480, the server populates the expected results in a data pool file. In step 490, the server generates a test script.
It should be understood that, in the embodiment shown in fig. 4, the execution sequence of the above steps by the server is only an example, and should not constitute any limitation on the embodiment of the present application. The steps performed by the server shown in fig. 4 may be in other orders. For example, step 490 may precede step 410. As another example, steps 440 and 450 may follow step 460. It should also be understood that the detailed description of each step in fig. 4 can refer to the related description of fig. 2, and is not repeated here.
Based on the technical scheme, the server obtains test data based on the obtained name of the dependency table, executes the storage process on the result table by calling the storage process to obtain an expected result, can also generate a test script comprising the test step, and finally obtains a test case corresponding to the storage process according to the test data, the expected result, the test script and the storage process, so that the whole process does not need encoding of testers, the workload of the testers is greatly reduced, the compiling efficiency and quality of the test case are improved, and the testing efficiency of the storage process is improved.
The server provided by the embodiment of the present application will be described in detail below with reference to fig. 5 and 6.
Fig. 5 is a schematic block diagram of a server 500 provided in an embodiment of the present application. As shown in fig. 5, the server 500 may include: a generating unit 510, an obtaining unit 520 and a processing unit 530. The units in the server 500 may be configured to implement the method according to any one of the embodiments shown in fig. 2 to 4.
Illustratively, the generating unit 510 in the server 500 is configured to generate a test script, the test script being configured to perform the following steps: importing test data, executing a storage process, and asserting a test result based on an expected result; the obtaining unit 520 is configured to obtain a name of the stored procedure, a name of the dependency table, and a name of the result table; the obtaining unit 520 is further configured to read the dependency table and the result table from a database according to the name of the dependency table and the name of the result table; the processing unit 530 is configured to obtain the test data based on the dependency table; the processing unit 530 is further configured to invoke the stored procedure according to the name of the stored procedure, and execute the stored procedure for the result table to obtain the expected result; the processing unit 530 is further configured to obtain the test case based on the test script, the test data, the stored procedure, and the expected result.
Optionally, the obtaining unit 520 is specifically configured to obtain the name of the stored procedure in response to an operation of a tester; generating and outputting a first template based on the name of the stored process; and acquiring a second template, wherein the second template is obtained based on the updating of the first template by the tester, and the second template comprises the name of the dependency table and the name of the result table.
Optionally, the second template further comprises one or more of: the screening conditions corresponding to the dependency table, the screening conditions corresponding to the result table, the sorting fields corresponding to the result table, and the culling fields corresponding to the result table.
Optionally, the processing unit 530 is further configured to encapsulate the stored procedure into an entity class, where the entity class is used to call the stored procedure.
Optionally, the test script is further configured to perform the following steps: backing up the data and recovering the data.
Optionally, the processing unit 530 is specifically configured to backup the original data of the dependency table and the result table; restoring the dependency table and the result table to a state prior to execution of a storage process based on the backed up original data of the dependency table and the result table.
Optionally, the generating unit 510 is specifically configured to construct a plurality of building blocks, where the building blocks correspond to a plurality of steps in the test script one to one, and each building block provides an interface for invoking the corresponding step.
Optionally, the processing unit 530 is further configured to test the stored procedure based on the test case.
It should be understood that the division of the units in the embodiments of the present application is illustrative, and is only one logical function division, and there may be other division manners in actual implementation. In addition, functional units in the embodiments of the present application may be integrated into one processor, may exist alone physically, or may be integrated into one unit from two or more units. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
Fig. 6 is another schematic block diagram of a server 600 provided in an embodiment of the present application. The server 600 may be a chip system, or may also be an apparatus configured with a chip system, so as to implement the method for generating the test case in the foregoing method embodiment. In the embodiment of the present application, the chip system may be composed of a chip, and may also include a chip and other discrete components.
As shown in fig. 6, the server 600 may include a processor 610 and a communication interface 620. Communication interface 620 may be used, among other things, to communicate with other devices over a transmission medium such that the apparatus used in server 600 may communicate with other devices. The communication interface 620 may be, for example, a transceiver, an interface, a bus, a circuit, or a device capable of performing a transceiving function. The processor 610 may utilize the communication interface 620 to input and output data and to implement the method described in any one of the embodiments corresponding to fig. 2-4.
Illustratively, if the server 600 is used to implement the method described in the embodiment shown in fig. 2, the processor 610 may be configured to generate a test script, the test script being configured to perform the following steps: importing test data, executing a storage process, and asserting a test result based on an expected result; acquiring the name of the storage process, the name of the dependency table and the name of the result table; reading the dependency table and the result table from a database according to the name of the dependency table and the name of the result table; obtaining the test data based on the dependency table; calling the storage process according to the name of the storage process, and executing the storage process aiming at the result table to obtain the expected result; and obtaining the test case based on the test script, the test data, the storage process and the expected result. For details, reference is made to the detailed description of the method embodiments, which is not repeated herein.
Optionally, the server 600 further comprises at least one memory 630 for storing program instructions and/or data. A memory 630 is coupled to the processor 610. The coupling in the embodiments of the present application is an indirect coupling or a communication connection between devices, units or modules, and may be an electrical, mechanical or other form for information interaction between the devices, units or modules. The processor 610 may operate in conjunction with the memory 630. The processor 610 may execute program instructions stored in the memory 630. At least one of the at least one memory may be included in the processor.
The specific connection medium between the processor 610, the communication interface 620 and the memory 630 is not limited in the embodiments of the present application. In fig. 6, the processor 610, the communication interface 620, and the memory 630 are connected by a bus 640. The bus 640 is represented by a thick line in fig. 6, and the connection between other components is merely illustrative and not intended to be limiting. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 6, but this is not intended to represent only one bus or type of bus.
The present application further provides a computer program product, the computer program product comprising: a computer program (also referred to as code, or instructions), which when executed, causes a computer to perform the method of any one of the embodiments shown in fig. 2-4.
The present application also provides a computer-readable storage medium having stored thereon a computer program (also referred to as code, or instructions). When executed, cause a computer to perform the method of any one of the embodiments shown in fig. 2-4.
It should be noted that the method and the server for generating the test case provided in the embodiment of the present application may be applied to the financial field, and may also be applied to any field other than the financial field, which is not limited in this application.
It should be understood that the processor in the embodiments of the present application may be an integrated circuit chip having signal processing capability. In implementation, the steps of the above method embodiments may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The processor may be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
It will also be appreciated that the memory in the embodiments of the subject application can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. The non-volatile memory may be a read-only memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an electrically Erasable EPROM (EEPROM), or a flash memory. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), double data rate SDRAM, enhanced SDRAM, SLDRAM, Synchronous Link DRAM (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
As used in this specification, the terms "unit," "module," and the like are intended to refer to a computer-related entity, either hardware, firmware, a combination of hardware and software, or software in execution.
Those of ordinary skill in the art will appreciate that the various illustrative logical blocks and steps (step) 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 several embodiments provided in the present application, it should be understood that the disclosed apparatus, device and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as discrete components may or may not be physically separate, and components displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
In the above embodiments, the functions of the functional units may be fully or partially implemented by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions (programs). The procedures or functions described in accordance with the embodiments of the present application are generated in whole or in part when the computer program instructions (programs) are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a Digital Versatile Disk (DVD)), or a semiconductor medium (e.g., a Solid State Disk (SSD)), among others.
The functions, if implemented in the form of software functional units 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 application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including 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 application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. A method for generating a test case is characterized by comprising the following steps:
generating a test script for performing the steps of: importing test data, executing a storage process, and asserting a test result based on an expected result;
acquiring the name of the storage process, the name of the dependency table and the name of the result table;
reading the dependency table and the result table from a database according to the name of the dependency table and the name of the result table;
obtaining the test data based on the dependency table;
calling the storage process according to the name of the storage process, and executing the storage process aiming at the result table to obtain the expected result;
and obtaining the test case based on the test script, the test data, the storage process and the expected result.
2. The method of claim 1, wherein the obtaining the names of the stored procedures, the names of the dependency tables, and the names of the result tables comprises:
responding to the operation of a tester, and acquiring the name of the storage process;
generating and outputting a first template based on the name of the stored process;
and acquiring a second template, wherein the second template is obtained based on the updating of the first template by the tester, and the second template comprises the name of the dependency table and the name of the result table.
3. The method of claim 2, wherein the second template further comprises one or more of: the screening conditions corresponding to the dependency table, the screening conditions corresponding to the result table, the sorting fields corresponding to the result table, and the culling fields corresponding to the result table.
4. The method of claim 1, wherein prior to said invoking said stored procedure according to a name of said stored procedure, said method further comprises:
and encapsulating the storage process into an entity class, wherein the entity class is used for calling the storage process according to the name of the storage process.
5. The method of claim 1, wherein the test script is further for performing the steps of: backing up the data and recovering the data.
6. The method of claim 5, wherein the backing up data comprises:
backing up original data of the dependency table and the result table; and
the recovering the data comprises:
restoring the dependency table and the result table to a state prior to execution of a storage process based on the backed up original data of the dependency table and the result table.
7. The method of claim 1, 5 or 6, wherein after said generating a test script, the method further comprises: building a plurality of building blocks, the building blocks corresponding to a plurality of steps in the test script one-to-one, each building block providing an interface for invoking the corresponding step to implement the plurality of steps in the test script through the plurality of building blocks.
8. The method of claim 1, wherein the method further comprises:
and testing the storage process based on the test case.
9. A server, comprising:
a generating unit configured to generate a test script, wherein the test script is configured to perform the following steps: importing test data, executing a storage process, and asserting a test result based on an expected result;
the acquisition unit is used for acquiring the name of the storage process, the name of the dependency table and the name of the result table;
the acquisition unit is further used for reading the dependency table and the result table from a database according to the name of the dependency table and the name of the result table;
the processing unit is used for obtaining the test data based on the dependency table;
the processing unit is further configured to call the storage procedure according to the name of the storage procedure, and execute the storage procedure for the result table to obtain the expected result;
the processing unit is further configured to obtain the test case based on the test script, the test data, the stored procedure, and the expected result.
10. A server comprising a processor and a memory, the processor and the memory coupled, the memory for storing a computer program, the processor for executing the computer program to cause the server to implement the method of any one of claims 1 to 8.
11. A computer-readable storage medium, comprising a computer program which, when run on a computer, causes the computer to perform the method of any one of claims 1 to 8.
12. A computer program product, comprising a computer program which, when executed, causes a computer to perform the method of any one of claims 1 to 8.
CN202111564228.XA 2021-12-20 2021-12-20 Test case generation method and server Pending CN114238121A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111564228.XA CN114238121A (en) 2021-12-20 2021-12-20 Test case generation method and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111564228.XA CN114238121A (en) 2021-12-20 2021-12-20 Test case generation method and server

Publications (1)

Publication Number Publication Date
CN114238121A true CN114238121A (en) 2022-03-25

Family

ID=80759477

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111564228.XA Pending CN114238121A (en) 2021-12-20 2021-12-20 Test case generation method and server

Country Status (1)

Country Link
CN (1) CN114238121A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015141616A (en) * 2014-01-29 2015-08-03 株式会社Jvcケンウッド Operation input device, operation input method and program
CN108399130A (en) * 2018-02-28 2018-08-14 平安科技(深圳)有限公司 Method, device and equipment for automatically generating test case and readable storage medium
CN109697161A (en) * 2017-10-24 2019-04-30 中兴通讯股份有限公司 A kind of test method of storing process, storage medium and database server
CN111709384A (en) * 2020-06-22 2020-09-25 北京思特奇信息技术股份有限公司 AR gesture recognition method and device, electronic equipment and storage medium
CN111930617A (en) * 2020-07-31 2020-11-13 中国工商银行股份有限公司 Automatic testing method and device based on data objectification
CN112988601A (en) * 2021-04-29 2021-06-18 中国工商银行股份有限公司 Test script development method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015141616A (en) * 2014-01-29 2015-08-03 株式会社Jvcケンウッド Operation input device, operation input method and program
CN109697161A (en) * 2017-10-24 2019-04-30 中兴通讯股份有限公司 A kind of test method of storing process, storage medium and database server
CN108399130A (en) * 2018-02-28 2018-08-14 平安科技(深圳)有限公司 Method, device and equipment for automatically generating test case and readable storage medium
CN111709384A (en) * 2020-06-22 2020-09-25 北京思特奇信息技术股份有限公司 AR gesture recognition method and device, electronic equipment and storage medium
CN111930617A (en) * 2020-07-31 2020-11-13 中国工商银行股份有限公司 Automatic testing method and device based on data objectification
CN112988601A (en) * 2021-04-29 2021-06-18 中国工商银行股份有限公司 Test script development method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
郭德红;: "自动化测试的测试用例设计", 价值工程, no. 20, 18 July 2012 (2012-07-18) *

Similar Documents

Publication Publication Date Title
US8935575B2 (en) Test data generation
CN110941546A (en) Automatic test method, device, equipment and storage medium for WEB page case
CN112765023B (en) Test case generation method and device
CN111061475B (en) Software code generating method, device, computer equipment and storage medium
US20060059149A1 (en) Generation of anonymized data records from productive application data
CN106557307B (en) Service data processing method and system
CN113312259B (en) Interface testing method and device
CN110990274A (en) Data processing method, device and system for generating test case
JP2017174418A (en) Data structure abstraction for model checking
CN113535141A (en) Database operation code generation method and device
US10678864B2 (en) Analysis model preparing system, programming apparatus, and analysis model preparing method
CN110908870A (en) Resource monitoring method and device for mainframe, storage medium and equipment
CN111367512B (en) Method and device for creating Android library module dependency relationship in application development
CN112559346A (en) Service testing method and device
CN100346308C (en) Automatic test method based on database operation
CN116860636A (en) Unit test code generation method, device, equipment and storage medium
CN114238121A (en) Test case generation method and server
CN114896335B (en) Data dumping method and system of database
CN114416530A (en) Byte code modification method and device, computer equipment and storage medium
CN112527265A (en) Method for automatically injecting logs and computer equipment
CN113342681B (en) Regression testing method and device
CN118193032B (en) Method, apparatus, device, medium and program product for eliminating invalid dependency library
CN113744789B (en) Method, system, equipment and medium for testing SSD stability in research and development stage
CN113778839B (en) Regression testing method and device and electronic equipment
CN116909876A (en) Debugging method, debugging device, computer device, storage medium, and program product

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