CN110727582B - Program testing method and device, computer equipment and storage medium - Google Patents
Program testing method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110727582B CN110727582B CN201910841746.8A CN201910841746A CN110727582B CN 110727582 B CN110727582 B CN 110727582B CN 201910841746 A CN201910841746 A CN 201910841746A CN 110727582 B CN110727582 B CN 110727582B
- Authority
- CN
- China
- Prior art keywords
- test case
- judging
- value
- standard
- test
- 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.)
- Active
Links
- 238000003860 storage Methods 0.000 title claims abstract description 14
- 238000012360 testing method Methods 0.000 claims abstract description 258
- 238000000034 method Methods 0.000 claims abstract description 36
- 238000013507 mapping Methods 0.000 claims abstract description 19
- 230000006870 function Effects 0.000 claims description 35
- 238000004590 computer program Methods 0.000 claims description 16
- 238000000605 extraction Methods 0.000 claims description 5
- 238000010561 standard procedure Methods 0.000 claims description 5
- 230000009191 jumping Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 238000010998 test method Methods 0.000 description 3
- 238000009825 accumulation Methods 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test 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 invention discloses a program testing method, a program testing device, computer equipment and a storage medium, which are applied to the field of program testing and are used for improving the accuracy and the testing precision of a testing result. The method provided by the invention comprises the following steps: inquiring a standard value of the operation element stored corresponding to the classification identifier attached to the test case according to a preset mapping relation between the classification identifier and the operation element; extracting the mapped value of the operation element from the test case; judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if so, judging that the value of the operation element of the test case is correct; otherwise, judging that the value of the running element of the test case is wrong; when judging that the value of the operation element of the test case is correct, acquiring an expected result set corresponding to the test case, and operating the test case; judging whether the expected result is consistent with the operation result, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
Description
Technical Field
The present invention relates to the field of program testing technologies, and in particular, to a program testing method, apparatus, computer device, and storage medium.
Background
At present, the version in the internet mode is basically iterated once in two weeks, during the test, a tester needs to look at a required document, write test cases according to the required document or a product prototype or UI design, and other works, but the test time is usually only about one week, and under the version of quick iteration, the regression test is manually performed, so that the test efficiency is low, functional points can be omitted and neglected, and serious production problems are caused.
In order to realize the automation of regression testing, the currently popular automatic testing tools have Loadrunner, jmeter and the like, but the general tools have poor expandability and can only adapt to program testing of simple scenes, are not suitable for the flow testing of system functions, multi-post flow circulation testing and scene testing with particularly complex service interaction, and in the traditional automatic testing tools, the accuracy of testing results cannot be ensured due to the uncertainty of data sources of testing cases.
Disclosure of Invention
The embodiment of the invention provides a program testing method, a program testing device, computer equipment and a storage medium, which are used for solving the problems of low accuracy and low testing precision of the testing result of the existing testing method.
A program testing method, the method comprising:
Inquiring a standard value of the operation element stored corresponding to the classification identifier attached to the test case according to a preset mapping relation between the classification identifier and the operation element;
Extracting the value of the corresponding operation element from the test case according to the operation element obtained by mapping with the classification identifier of the test case;
Judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if so, judging that the value of the operation element of the test case is correct; otherwise, judging that the value of the running element of the test case is wrong;
when judging that the value of the operation element of the test case is correct, acquiring an expected result set corresponding to the test case, and operating the test case to acquire an operation result of the test case;
Judging whether the expected result is consistent with the running result, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
A program testing apparatus, the apparatus comprising:
The query module is used for querying the standard value of the operation element stored corresponding to the classification identifier attached to the test case according to the preset mapping relation between the classification identifier and the operation element;
the element value extraction module is used for extracting the value of the corresponding operation element from the test case according to the operation element obtained by mapping with the classification identifier of the test case;
The first judging module is used for judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if so, judging that the value of the operation element of the test case is correct; otherwise, judging that the value of the running element of the test case is wrong;
The operation module is used for acquiring an expected result set corresponding to the test case when judging that the value of the operation element of the test case is correct, and operating the test case to acquire an operation result of the test case;
the second judging module is used for judging whether the expected result is consistent with the running result, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the program test method described above when executing the computer program.
A computer readable storage medium storing a computer program which when executed by a processor implements the program test method described above.
According to the program testing method, the device, the computer equipment and the storage medium, whether the operation result of the test case accords with the expectation is further judged by judging whether the operation elements of the test case are correct before the operation of the test case and primarily judging the reasons of program errors and operating the test case after each operation element of the test case is correct, so that whether program branches corresponding to the test case are in error is judged. The application can judge whether the running element of the program is correct according to the standard value of the running element, and further judges whether the corresponding program branch is correct according to the running result of the program, thereby realizing the accurate positioning of the error test case. The test method for the test case relates to whether each operation element of the program is correct or not, and simultaneously relates to whether the operation result of the test case is correct or not, so that the accuracy of the test result is greatly improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments of the present invention will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an application environment of a program testing method according to an embodiment of the invention;
FIG. 2 is a flow chart of a program testing method according to an embodiment of the invention;
FIG. 3 is a flow chart of a program testing method according to another embodiment of the invention;
FIG. 4 is a flow chart of a program testing method according to another embodiment of the invention;
FIG. 5 is a flow chart of a program testing method according to another embodiment of the invention;
FIG. 6 is a schematic diagram of a program testing apparatus according to an embodiment of the invention;
FIG. 7 is a schematic diagram of a computer device in accordance with an embodiment of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The program testing method provided by the application can be applied to an application environment as shown in fig. 1, wherein computer equipment can communicate with a server through a network. The computer device may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, etc.
In a first embodiment, as shown in fig. 2, a program testing method is provided, and the method is applied to the server in fig. 1, and is described as an example, and includes the following steps S101 to S105:
s101, inquiring a standard value of the operation element stored corresponding to the classification identifier attached to the test case according to a preset mapping relation between the classification identifier and the operation element.
In one embodiment, the categorization identification is defined according to actual service requirements, and the categorization identification is used for calibrating the category of the test case and can be a policy number.
In one embodiment, the standard values of the run elements are stored in an original database.
S102, extracting the value of the corresponding operation element from the test case according to the operation element obtained through mapping with the classification identification of the test case.
In one embodiment, the running element is preset according to the data call condition and the processing condition of the program, where the running element includes, but is not limited to, an address and a table name of a data table called by the test case, a field, a function name, a method name, and the like, and packaging a plurality of functions into a program segment with a certain function can be understood as the method in this embodiment.
In one embodiment, the values of the run elements in the test cases are also stored in the original database.
S103, judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if so, judging that the value of the operation element of the test case is correct; otherwise, judging that the value of the running element of the test case is wrong.
The step judges whether the running element of the program is in error or not by comparing the standard value of the running element with the value of the running element of the program in the test case.
S104, when judging that the value of the operation element of the test case is correct, acquiring an expected result set corresponding to the test case, and operating the test case to acquire an operation result of the test case.
S105, judging whether the expected result is consistent with the operation result, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
On the one hand, the standard value of the running element for testing is directly obtained from the database, and compared with the data obtained from other places such as an Excel table, the method can avoid inaccurate testing results caused by distortion after the data is processed or transferred. The distortion condition may include that when the Excel table is manually input, error data is input, or error conditions such as accumulation of the data, calculation through a specific formula and the like are input, and the value of an operation element in the test case is directly called from the original database, so that the distortion condition can be well avoided, and the accuracy of a test result is improved.
On the other hand, the embodiment judges whether the operation elements of the test case are correct before the test case is operated, primarily judges the reasons of program errors, operates the test case after each operation element of the test case is correct, and further judges whether the operation result of the test case meets the expectations or not, so as to judge whether program branches corresponding to the test case are in error or not. The application can judge whether the running element of the program is correct according to the standard value of the running element, and further judges whether the corresponding program branch is correct according to the running result of the program, thereby realizing the accurate positioning of the error test case. The test method for the test case relates to whether each operation element of the program is correct or not, and simultaneously relates to whether the operation result of the test case is correct or not, so that the accuracy of the test result is greatly improved.
Fig. 3 is a flowchart of a program testing method according to another embodiment of the present invention, and the program testing method according to the present embodiment is described in detail below with reference to fig. 3, and according to a second embodiment of the present invention, as shown in fig. 3, the standard values include a first standard value corresponding to a test scene and a second standard value stored in a shared file, and the program testing method further includes the following steps S1011 and S1012 on the basis of steps S104 and S105:
S1011, acquiring a test scene corresponding to the classifying identifier through a preset mapping relation;
S1012, acquiring the first standard value of the first standard element from the test scene, and acquiring the second standard value of the second standard element from the shared file.
In one embodiment, the run element includes, but is not limited to, an address of a data table called by the test case, a table name, a field, a method name called by the test case, and a function name. Wherein the first standard element is an element related to a service, and the first standard element includes, but is not limited to, an address, a table name and a field of a data table; the second standard element is a generic element that is not related to the service. The second standard element includes, but is not limited to, a method name, a function name, and the like. That is, the table names and the fields are first standard elements corresponding to the test scene, and the function names and the method names are second standard elements stored in the shared file.
In this embodiment, the step S102 is further the following step S1021:
s1021, extracting the value of the first standard element and the value of the second standard element from the test case according to the operation element obtained through mapping with the classification identification of the test case.
In this embodiment, the above step S103 is further the following step S1031:
S1031, judging whether the values of the first standard element and the first standard value and the values of the second standard element and the second standard value are the same, if so, judging that the values of the running elements of the test case are correct; otherwise, judging that the value of the running element of the test case is wrong.
In this embodiment, the value of the first standard element extracted may be compared with the first standard value to determine whether the value of the first standard element of the test case is correct, and then the value of the second standard element extracted may be compared with the second standard value to determine whether the value of the second standard element of the test case is correct.
In this embodiment, the test scenario includes, but is not limited to, refund, right-keeping and adding, newly-built policy, and the like.
According to the embodiment, the elements are classified, the elements related to the service are divided under the test scene, and the elements related to the non-service are divided in the shared file, so that when the test template is required to be modified, only the element parameter values in the test scene are modified, and the applicability and the expandability of the method are improved.
In the third embodiment, the running element includes, but is not limited to, an address, a table name, and a field of the data table called by the test case, and the step S103 further includes:
judging whether the address and the table name of the data table called by the test case are the same as the address and the table name of the standard data table;
If the fields are the same, judging that the data table called by the test case is correct, further judging whether the fields of the data table called by the test case are the same as the preset standard fields, if so, judging that the fields called by the test case are correct; otherwise, judging the field error called by the test case;
otherwise, judging the error of the data table called by the test case.
The embodiment provides an implementation method for accurately positioning errors of the address, the table name and the field of the call data table of the test case by judging whether the address, the table name and the field of the call data table of the test case are correct or not, and improves the test precision.
In the fourth embodiment, the running element includes a function name, and the step S103 further includes:
judging whether the function name called by the test case is the same as the standard function name, if so, judging that the function called by the test case is correct, otherwise, judging that the function called by the test case is wrong.
The embodiment provides an implementation method for accurately positioning whether the calling function of the test case is wrong or not by judging whether the calling function name of the test case is correct or not, and further improves the test precision.
In the fifth embodiment, the operation element includes a method name, and the step S103 further includes:
judging whether the name of the method called by the test case is the same as the name of the standard method, if so, judging that the method called by the test case is correct, otherwise, judging that the method called by the test case is wrong.
The embodiment provides an implementation method for accurately positioning whether the calling method of the test case is wrong or not by judging whether the calling method name of the test case is correct or not, and further improves the test precision.
The third, fourth and fifth embodiments may be combined to obtain the sixth embodiment of the present application, or one or two of them may be selected to be implemented, and the combination method thereof is referred to the sixth embodiment of the present application and will not be described herein.
The third, fourth and fifth embodiments are described below as a combined embodiment, and the combined third, fourth and fifth embodiments are performed in one order without any sequence, as shown in fig. 3, and the program testing method includes the following steps S101 to S4053:
S101, inquiring a standard value of an operation element stored corresponding to a classification identifier attached to a test case according to a preset mapping relation between the classification identifier and the operation element;
S4021, according to the address, table name, standard field, standard function name and standard method name of the call standard data table obtained by mapping with the classifying identification of the test case, extracting the address, table name, field, function name and method name of the corresponding data table from the test case;
s4031, judging whether the address and the table name of the data table called by the test case are the same as those of the standard data table, if yes, jumping to the step S4032, otherwise, executing the step S4131;
s4131, judging that the data table called by the test case is wrong;
S4032, judging whether the fields of the data table called by the test case are the same as the preset standard fields, if yes, jumping to the step S4033, otherwise, executing the step S4132;
s4132, judging the field error called by the test case;
S4033, judging whether the function name called by the test case is the same as the standard function name, if yes, executing the step S4034, otherwise, executing the step S4133;
s4133, judging the function error called by the test case;
s4034, judging whether the method name called by the test case is the same as the standard method name, if so, executing S404, otherwise, executing S4134;
s4134, judging that the method called by the test case is wrong;
S404, obtaining an expected result set corresponding to the test case, and operating the test case to obtain an operation result of the test case;
S4051, judging whether the number of the expected results is the same as the number of the operation results, if yes, jumping to the step S4052, otherwise, jumping to the step S4151;
S4151, judging program branch missing corresponding to the missing operation result;
s4052, judging whether the value of each expected result is the same as the value of the corresponding operation result, if so, jumping to the step S4053, otherwise, jumping to the step S4152;
S4152, judging that a branch corresponding to the error operation result has logic error;
s4053, passing the test.
The embodiment can judge whether the data value and the calculation method of the test case are correct or not by comparing the value of the operation element of the test case with the standard value of the operation element, and then compare the operation result of the test case with the preset expected result, so as to further judge whether the program branch of the test case is missing or not, and further accurately position the specific position of the program error when the test case is in error.
Fig. 5 is a flowchart of a program testing method according to another embodiment of the present invention, and the program testing method according to the present embodiment is described in detail below with reference to fig. 5, and according to a seventh embodiment of the present invention, as shown in fig. 5, the program testing method includes steps S101 to S104, and step S105 further includes steps S5051 to S5053:
S5051, judging whether the number of the expected results is the same as the number of the operation results;
S5052, if the expected result values are the same as the corresponding operation result values, judging whether the test case passes the test, if not, judging that the branch corresponding to the error operation result has logic error;
s5053, if the program branches are different, judging that program branches corresponding to the missing running result are missing.
Wherein, each expected result in the test scene has a corresponding relation with a branch node of the test program, M obtained expected results set corresponding to the test scene are set, N obtained running results of the test case are set, and the step S105 further includes:
Judging whether the number M of the expected results is the same as the number N of the operation results, if so, judging whether the value of each expected result is the same as the value of the corresponding operation result, if so, judging that the test of the test case passes, otherwise, judging that a branch corresponding to the error operation result has logic errors; otherwise, judging that the branch corresponding to the missing operation result is missing.
According to one usage scenario of the present embodiment, for example, the code logic of the standard program has ten branches, there is an expected result executed corresponding to each branch, if the test result of the test case has only eight branches, it may be determined that the code logic of the test case lacks two branches, and it is explained that writing a part of code by less test case causes the corresponding logic branch to be missing.
Because each logic branch corresponds to an expected result, when the expected result of one logic branch is different from the operation result, the logic branch corresponding to the test case can be directly positioned, so that the corresponding programming code is positioned, and the program code with errors is directly positioned.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present invention.
In an embodiment, a program testing device is provided, where the program testing device corresponds to the program testing method in the above embodiment one by one. Fig. 6 is a schematic structural diagram of a program testing apparatus according to an embodiment of the present invention, and as shown in fig. 6, the program testing apparatus 100 includes a query module 11, an element value extraction module 12, a first judgment module 13, an operation module 14, and a second judgment module 15. The functional modules are described in detail as follows:
The query module 11 is configured to query a standard value of an operation element stored corresponding to a classification identifier attached to a test case according to a preset mapping relationship between the classification identifier and the operation element;
an element value extraction module 12, configured to extract a value of a corresponding running element from the test case according to the running element mapped to the classification identifier of the test case;
The first judging module 13 is configured to judge whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if yes, then judge that the value of the operation element of the test case is correct; otherwise, judging that the value of the running element of the test case is wrong;
The operation module 14 is configured to obtain an expected result set corresponding to the test case when the value of the operation element of the test case is determined to be correct, and operate the test case to obtain an operation result of the test case;
The second judging module 15 is configured to judge whether the expected result matches the running result, if yes, judge that the test of the test case passes; otherwise, judging that the program test of the test case fails.
In one embodiment, the standard values of the run elements are stored in an original database, and the values of the run elements in the test cases are also stored in the original database.
In one embodiment, the standard values include a first standard value corresponding to a test scenario and a second standard value stored in a shared file, and the element value extraction module 12 includes:
the scene acquisition unit is used for acquiring a test scene corresponding to the classification identifier through a preset mapping relation;
The standard value acquisition module is used for acquiring the first standard value of the first standard element from the test scene and acquiring the second standard value of the second standard element from the shared file.
In one embodiment, the element value extracting module 12 is specifically configured to extract the value of the first standard element and the value of the second standard element from the test case.
The first judging module 13 is specifically configured to:
Comparing the extracted value of the first standard element with the first standard value, and judging whether the value of the first standard element of the test case is correct or not;
And comparing the extracted value of the second standard element with the second standard value to judge whether the value of the second standard element of the test case is correct or not.
In one embodiment, the running element includes an address, a table name and a field of a data table called by the test case, and the first determining module 13 specifically includes:
The first judging unit is used for judging whether the address and the table name of the data table called by the test case are the same as those of the standard data table, if so, judging that the data table called by the test case is correct, and further judging whether the field of the data table called by the test case is the same as a preset standard field, if so, judging that the field called by the test case is correct, otherwise, judging that the field called by the test case is wrong; otherwise, judging the error of the data table called by the test case.
In one embodiment, the running element includes a function name, and the first determining module 13 further includes:
And the second judging unit is used for judging whether the function name called by the test case is the same as the standard function name, if so, judging that the function called by the test case is correct, and if not, judging that the function called by the test case is wrong.
In one embodiment, the running element includes a method name, and the first determining module 13 further includes:
And the third judging unit is used for judging whether the name of the method called by the test case is the same as the name of the standard method, if so, judging that the method called by the test case is correct, and if not, judging that the method called by the test case is wrong.
In one embodiment, the second determining module 15 includes:
the result number judging unit is used for judging whether the number of the expected results is the same as the number of the running results, if so, further judging whether the value of each expected result is the same as the value of the corresponding running result, or else, judging that the program branch corresponding to the missing running result is missing;
And the operation result judging unit is used for judging that the test of the test case passes when the value of each expected result is identical to the value of the corresponding operation result, and judging that a branch corresponding to the error operation result has logic errors if the test of the test case passes.
In this embodiment, the "first", "second" and "third" of the first, second, and third judging units are only limited to differentiating different judging units, and are not limited to limiting the execution priorities of the judging units, but have no other limiting meaning, and the execution priorities of the first, second, and third judging units may be set differently according to the test requirements.
On one hand, the program testing device selects to directly obtain the standard value of the running element for testing from the database, and compared with the data obtained from other places such as an Excel table, the program testing device can avoid inaccurate testing results caused by distortion after the data is processed or transferred. The distortion condition may include that when the Excel table is manually input, error data is input, or error conditions such as accumulation of the data, calculation through a specific formula and the like are input, and the value of an operation element in the test case is directly called from the original database, so that the distortion condition can be well avoided, and the accuracy of a test result is improved.
On the other hand, in the embodiment, before the test case is run, whether the running elements of the test case are correct is judged through the first judging module, the reason of program error is primarily judged, after each running element of the test case is correct, the test case is run through the running module, whether the running result of the test case accords with the expectation is further judged through the second judging module, and therefore whether program branches corresponding to the test case are in error is judged. The application can judge whether the running element of the program is correct according to the standard value of the running element, and further judges whether the corresponding program branch is correct according to the running result of the program, thereby realizing the accurate positioning of the error test case.
The test method for the test case relates to whether each operation element of the program is correct or not, and simultaneously relates to whether the operation result of the test case is correct or not, so that the accuracy of the test result is greatly improved.
For specific limitations of the program testing device, reference may be made to the above limitations of the program testing method, and no further description is given here. The respective modules in the program testing device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is for communicating with an external server via a network connection. The computer program is executed by a processor to implement a program test method.
In one embodiment, a computer device is provided that includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the program testing method of the above embodiments when the processor executes the computer program, such as steps 101 through 105 shown in fig. 2. Or the processor, when executing a computer program, implements the functions of the modules/units of the program testing apparatus in the above embodiments, such as the functions of the query modules 11 to 15 shown in fig. 6. In order to avoid repetition, a description thereof is omitted.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the program testing method of the above embodiment, such as steps 101 to 105 shown in fig. 2. Or the computer program when executed by a processor implements the functions of the modules/units of the program testing apparatus in the above embodiments, such as the functions of the query modules 11 to 15 shown in fig. 6. In order to avoid repetition, a description thereof is omitted.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SYNCHLINK) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.
Claims (8)
1. A program testing method, the method comprising:
Inquiring a standard value of the operation element stored corresponding to the classification identifier attached to the test case according to a preset mapping relation between the classification identifier and the operation element;
The standard values comprise first standard values corresponding to the test scenes and second standard values stored in the shared file;
Acquiring a test scene corresponding to the classifying identifier through a preset mapping relation;
acquiring the first standard value of a first standard element from the test scene, and acquiring the second standard value of a second standard element from the shared file;
extracting a value of a corresponding operation element from the test case according to the operation element obtained by mapping with the classification identifier of the test case;
judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if so, judging that the value of the operation element of the test case is correct; otherwise, judging that the value of the operation element of the test case is wrong;
When judging that the value of the operation element of the test case is correct, acquiring an expected result set corresponding to the test case, and operating the test case to acquire an operation result of the test case;
Judging whether the number of the expected results is the same as the number of the running results;
If the values of the expected results are the same as the values of the corresponding operation results, judging whether the test cases pass the test, if not, judging that the program branches corresponding to the error operation results have logic errors;
if the program branches are different, judging that program branches corresponding to the missing running result are missing.
2. The program testing method according to claim 1, wherein the step of extracting the value of the corresponding run element from the test case comprises:
extracting the values of the first standard element and the values of the second standard element from the test case;
the step of judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element comprises the following steps:
comparing the extracted value of the first standard element with the first standard value, and judging whether the value of the first standard element of the test case is correct or not;
And comparing the extracted value of the second standard element with the second standard value, and judging whether the value of the second standard element of the test case is correct or not.
3. The program testing method according to claim 1, wherein the running element includes an address, a table name, and a field of a data table called by the test case, and the step of judging whether the extracted value of the running element is identical to a standard value of a corresponding running element includes:
Judging whether the address and the table name of the data table called by the test case are the same as the address and the table name of the standard data table;
if the fields are the same, judging that the data table called by the test case is correct, further judging whether the fields of the data table called by the test case are the same as the preset standard fields, and if yes, judging that the fields called by the test case are correct; otherwise, judging the field error called by the test case;
Otherwise, judging that the data table called by the test case is wrong.
4. The program testing method according to claim 1, wherein the run element includes a function name, and the step of judging whether the extracted value of the run element is identical to a standard value of a corresponding run element includes:
judging whether the function name called by the test case is the same as the standard function name, if so, judging that the function called by the test case is correct, otherwise, judging that the function called by the test case is wrong.
5. The program test method according to claim 1, wherein the run element includes a method name, and the step of judging whether the extracted value of the run element is identical to a standard value of a corresponding run element includes:
judging whether the name of the method called by the test case is the same as the name of the standard method, if so, judging that the method called by the test case is correct, otherwise, judging that the method called by the test case is wrong.
6. A program testing apparatus, the apparatus comprising:
The query module is used for querying the standard value of the operation element stored corresponding to the classification identifier attached to the test case according to the preset mapping relation between the classification identifier and the operation element; the standard values comprise first standard values corresponding to the test scenes and second standard values stored in the shared file;
The acquisition module is used for acquiring a test scene corresponding to the classification identifier through a preset mapping relation; acquiring the first standard value of a first standard element from the test scene, and acquiring the second standard value of a second standard element from the shared file;
The element value extraction module is used for extracting the value of the corresponding operation element from the test case according to the operation element obtained by mapping with the classification identifier of the test case;
the first judging module is used for judging whether the extracted value of the operation element is the same as the standard value of the corresponding operation element, if so, judging that the value of the operation element of the test case is correct; otherwise, judging that the value of the operation element of the test case is wrong;
The operation module is used for acquiring an expected result set corresponding to the test case when judging that the value of the operation element of the test case is correct, and operating the test case to acquire an operation result of the test case;
The second judging module is used for judging whether the number of the expected results is the same as the number of the running results; if the values of the expected results are the same as the values of the corresponding operation results, judging whether the test cases pass the test, if not, judging that the program branches corresponding to the error operation results have logic errors; if the program branches are different, judging that program branches corresponding to the missing running result are missing.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the program testing method according to any of claims 1 to 5 when executing the computer program.
8. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the program testing method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910841746.8A CN110727582B (en) | 2019-09-06 | 2019-09-06 | Program testing method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910841746.8A CN110727582B (en) | 2019-09-06 | 2019-09-06 | Program testing method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110727582A CN110727582A (en) | 2020-01-24 |
CN110727582B true CN110727582B (en) | 2024-07-05 |
Family
ID=69217926
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910841746.8A Active CN110727582B (en) | 2019-09-06 | 2019-09-06 | Program testing method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110727582B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107515819A (en) * | 2016-06-16 | 2017-12-26 | 平安科技(深圳)有限公司 | Medicare system method of testing and device |
CN109324961A (en) * | 2018-08-14 | 2019-02-12 | 中国平安人寿保险股份有限公司 | System automatic test approach, device, computer equipment and storage medium |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107015903B (en) * | 2016-01-27 | 2021-08-10 | 菜鸟智能物流控股有限公司 | Interface test program generation method and device and electronic equipment |
CN109344048A (en) * | 2018-08-17 | 2019-02-15 | 中国平安人寿保险股份有限公司 | A kind of test method, storage medium and server |
CN109753428A (en) * | 2018-12-13 | 2019-05-14 | 浙江数链科技有限公司 | Service test method, device, computer equipment and readable storage medium storing program for executing |
CN109684210A (en) * | 2018-12-18 | 2019-04-26 | 宁夏隆基宁光仪表股份有限公司 | A kind of website automation test method, device, equipment and readable storage medium storing program for executing |
-
2019
- 2019-09-06 CN CN201910841746.8A patent/CN110727582B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107515819A (en) * | 2016-06-16 | 2017-12-26 | 平安科技(深圳)有限公司 | Medicare system method of testing and device |
CN109324961A (en) * | 2018-08-14 | 2019-02-12 | 中国平安人寿保险股份有限公司 | System automatic test approach, device, computer equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110727582A (en) | 2020-01-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109474578B (en) | Message checking method, device, computer equipment and storage medium | |
CN109446068B (en) | Interface test method, device, computer equipment and storage medium | |
CN110941546A (en) | Automatic test method, device, equipment and storage medium for WEB page case | |
CN108427613B (en) | Abnormal interface positioning method and device, computer equipment and storage medium | |
CN110109897A (en) | Database script generation method, device, computer equipment and storage medium | |
CN110765001B (en) | Modularized automatic test method and device for application system | |
CN110928802A (en) | Test method, device, equipment and storage medium based on automatic generation of case | |
CN112395202B (en) | Interface automation test method and device, computer equipment and storage medium | |
CN113282513B (en) | Interface test case generation method and device, computer equipment and storage medium | |
CN111615688A (en) | Assertion verification code binding method and device | |
CN112052182A (en) | Interface automation test method and device, computer equipment and storage medium | |
CN104021072A (en) | Machine and methods for evaluating failing software programs | |
CN109408309B (en) | Multi-terminal testing method and device | |
CN111797026A (en) | Test case generation method and device, computer equipment and storage medium | |
CN111191079A (en) | Document content acquisition method, device, equipment and storage medium | |
CN110502362A (en) | Error code based on micro services framework defines method, apparatus and computer equipment | |
CN114610635A (en) | Interface test case generation method and device, computer equipment and storage medium | |
CN110750443A (en) | Webpage testing method and device, computer equipment and storage medium | |
CN114510536A (en) | Data verification method and device, computer equipment and storage medium | |
WO2021036681A1 (en) | Data verification method and apparatus, computer device and storage medium | |
CN110727582B (en) | Program testing method and device, computer equipment and storage medium | |
CN117391306A (en) | Homeland space planning result examination method, device, equipment and storage medium | |
CN112612706A (en) | Automated testing method, computer device and storage medium | |
CN111274128A (en) | Test method, test device, computer equipment and computer readable storage medium | |
CN114971926A (en) | Premium calculation model test method, system, device and storage medium |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |