CN110727582A - Program testing method and device, computer equipment and storage medium - Google Patents

Program testing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN110727582A
CN110727582A CN201910841746.8A CN201910841746A CN110727582A CN 110727582 A CN110727582 A CN 110727582A CN 201910841746 A CN201910841746 A CN 201910841746A CN 110727582 A CN110727582 A CN 110727582A
Authority
CN
China
Prior art keywords
test case
value
judging
test
standard
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
CN201910841746.8A
Other languages
Chinese (zh)
Inventor
赵建存
邱辉
石万里
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Health Insurance Company of China Ltd
Original Assignee
Ping An Health Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Health Insurance Company of China Ltd filed Critical Ping An Health Insurance Company of China Ltd
Priority to CN201910841746.8A priority Critical patent/CN110727582A/en
Publication of CN110727582A publication Critical patent/CN110727582A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Landscapes

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

Abstract

The 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 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 which is 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 values of the mapped operation elements from the test cases; judging whether the value of the extracted 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 the value of the operation element of the test case is judged to be 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 or not, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.

Description

Program testing method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of program testing technologies, and in particular, to a program testing method and apparatus, a computer device, and a storage medium.
Background
At present, the version in the internet mode is iterated once in two weeks, during the testing period, testers need to see a demand document, need to write test cases according to the demand document or a product prototype or UI design and other works, the testing time of the testers is only about one week, and in the version with rapid iteration, the manual regression testing is carried out, so that the testing efficiency is low, and functional points are omitted and neglected, so that a major production problem is caused.
In order to realize automation of regression testing, currently popular automated testing tools include Loadrunner, Jmeter and the like, but these general tools have poor expandability and can only adapt to program testing in a simple scene, and are not suitable for testing in scenes in which the flow test of system functions, multi-position flow circulation test and service interaction are particularly complex, and in the traditional automated testing tool, the accuracy of a testing result cannot be guaranteed due to uncertainty of a data source of a test case.
Disclosure of Invention
The embodiment of the invention provides a program testing method, a program testing device, computer equipment and a storage medium, and aims to solve the problems of low accuracy and low testing precision of a testing result of an existing testing method.
A method of program testing, the method comprising:
inquiring a standard value of the operation element which is 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 operation element of the test case is wrong;
when the value of the operation element of the test case is judged to be correct, acquiring an expected result set corresponding to the test case, operating the test case and acquiring an operation result of the test case;
judging whether the expected result is consistent with the operation result or not, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
A program test apparatus, the apparatus comprising:
the query module is used for querying the standard value of the operation element which is 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 judgment 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 or not, and 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 the value of the operation element of the test case is judged to be correct, operating the test case and acquiring the operation result of the test case;
the second judgment module is used for judging whether the expected result is consistent with the operation result or not, and 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 said memory and executable on said processor, said processor implementing the program testing method described above when executing said computer program.
A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the program testing method described above.
According to the program testing method, the device, the computer equipment and the storage medium, whether the operation elements of the test case are correct or not is judged before the test case is operated, the cause of the program error is preliminarily judged, the test case is operated after each operation element of the test case is correct, whether the operation result of the test case meets the expectation or not is further judged, and therefore whether the program branch corresponding to the test case is in error or not is judged. According to the method and the device, whether the operation element of the program is correct can be judged according to the standard value of the operation element, and whether the corresponding program branch is correct is further judged according to the operation result of the program subsequently because each operation result of the program corresponds to the branch of the corresponding program one by one, so that the accurate positioning of the test case with the error is realized. The method for testing the test case of the invention 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 needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a diagram illustrating an application environment of a program testing method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a program testing method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a program testing method according to another embodiment of the present invention;
FIG. 4 is a flowchart of a program testing method according to another embodiment of the present invention;
FIG. 5 is a flowchart of a program testing method according to another embodiment of the present invention;
FIG. 6 is a schematic diagram of a program testing apparatus according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The program testing method provided by the application can be applied to the application environment shown in fig. 1, wherein the computer equipment can communicate with the server through the network. The computer device may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and the like.
In a first embodiment, as shown in fig. 2, a program testing method is provided, which is described by taking the application of the method to the server in fig. 1 as an example, and includes the following steps S101 to S105:
s101, inquiring a standard value of the operation element, which is 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 classification identifier is defined according to actual service requirements, and the classification identifier is used for calibrating the category of the test case, and may be a policy number.
In one embodiment, the standard values of the operating elements are stored in a raw database.
And S102, 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.
In one embodiment, the operation elements are preset according to the data calling condition and the processing condition of the program, and the operation elements include, but are not limited to, addresses and table names, fields, function names, method names, and the like of a data table called by a test case, where a plurality of functions are packaged into a program segment with a certain function may be understood as the method in the embodiment.
In one embodiment, the values of the run elements in the test case are also stored in the raw 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 operation element of the test case is wrong.
The step compares the standard value of the operation element with the value of the operation element of the program in the test case, so as to judge whether the operation element of the program is wrong.
And S104, when the value of the operation element of the test case is judged to be correct, obtaining an expected result set corresponding to the test case, operating the test case, and obtaining an operation result of the test case.
S105, judging whether the expected result is consistent with the operation result or not, and if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
On one hand, the standard value of the operation element for testing is directly obtained from the database, and compared with data obtained from other places such as an Excel table, inaccuracy of the test result caused by distortion after the data is processed or transferred can be avoided. The distortion condition may include that when an Excel table is manually entered, wrong data is entered, or errors occur when the data is accumulated and calculated through a specific formula, and the like, and the distortion condition can be well avoided by directly calling the values of the operation elements in the test case from the original database, so that the accuracy of the test result is improved.
On the other hand, in the embodiment, whether the operation element of the test case is correct is judged before the test case is operated, the cause of the program error is preliminarily judged, the test case is operated after each operation element of the test case is correct, whether the operation result of the test case meets the expectation is further judged, and therefore whether the program branch corresponding to the test case has the error is judged. According to the method and the device, whether the operation element of the program is correct can be judged according to the standard value of the operation element, and whether the corresponding program branch is correct is further judged according to the operation result of the program subsequently because each operation result of the program corresponds to the branch of the corresponding program one by one, so that the accurate positioning of the test case with the error is realized. The method for testing the test case of the invention 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, which is described in detail below with reference to fig. 3, wherein 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 scenario and a second standard value stored in a shared file, the program testing method further includes the following steps S1011 and S1012 in the step S101 based on the steps S104 and S105:
s1011, acquiring a test scene corresponding to the classification identifier through a preset mapping relation;
s1012, obtain the first standard value of the first standard element from the test scenario, and obtain the second standard value of the second standard element from the shared file.
In one embodiment, the run elements include, but are not limited to, the address, table name, field, name of the method and name of the function called by the test case of the data table called by the test case. 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 general element that is not related to the service. The second standard elements include, but are not limited to, method names, function names, and the like. That is, the table name and the field are first standard elements corresponding to the test scenario, and the function name and the method name are second standard elements stored in the shared file.
In this embodiment, the step S102 is further a step S1021:
and 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 by mapping with the classification identifier of the test case.
In this embodiment, the above step S103 is further a step S1031 of:
s1031, judging whether the value of the first standard element is the same as the first standard value and the value of the second standard element is the same as the second standard value, 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.
In this embodiment, the extracted value of the first standard element 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 extracted value of the second standard element 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, a refund, a security right holder, a new policy, and the like.
In the embodiment, the elements are classified, the elements related to the service are divided in the test scene, and the elements related to the non-service are divided in the shared file, so that when the test template needs to be modified, only the parameter values of the elements in the test scene are modified, and the applicability and the expandability of the application are improved.
In a third embodiment, the operation 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 those of the standard data table or not;
if the data tables are the same, judging that the data tables called by the test cases are correct, further judging whether the fields of the data tables called by the test cases are the same as the preset standard fields, and if so, judging that the fields called by the test cases are 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.
According to the embodiment, the method for realizing the error of the address, the table name and the field of the test case calling data table is accurately positioned by judging whether the address, the table name and the field of the test case calling data table are correct or not, and the test precision is improved.
In a fourth embodiment, the operation element includes a function name, and the step S103 further includes:
and 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 otherwise, judging that the function called by the test case is wrong.
According to the embodiment, whether the calling function name of the test case is correct or not is judged, so that the implementation method for accurately positioning whether the calling function of the test case is wrong or not is provided, and the test precision is further improved.
In a fifth embodiment, the operation element includes a method name, and the step S103 further includes:
and judging whether the method name called by the test case is the same as the standard method name, if so, judging that the method called by the test case is correct, and otherwise, judging that the method called by the test case is wrong.
According to the embodiment, whether the calling method name of the test case is correct or not is judged, so that the realization method for accurately positioning whether the calling method of the test case is wrong or not is provided, and the test precision is further improved.
The third, fourth, and fifth embodiments may be implemented in combination to obtain the sixth embodiment of the present application, or one or two of the third, fourth, and fifth embodiments may be implemented selectively.
The third, fourth, and fifth embodiments are combined as an example, the order of the third, fourth, and fifth embodiments after combination is not sequential, and the combination implementation in one order is shown in fig. 3, where the program testing method includes the following steps S101 to S4053:
s101, inquiring a standard value of the operation element, which is 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;
s4021, obtaining an address, a table name, a standard field, a standard function name and a standard method name of a calling standard data table according to the mapping with the classification identifier of the test case, and extracting the address, the table name, the field, the function name and the 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 so, jumping to S4032, otherwise, executing S4131;
s4131, judging the error of the data table called by the test case;
s4032, judging whether the field of the data table called by the test case is the same as a preset standard field, if so, jumping to S4033, otherwise, executing 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 so, executing a step S4034, otherwise, executing a step S4133;
s4133, judging a 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 step S4134;
s4134, judging the method error called by the test case;
s404, obtaining an expected result set corresponding to the test case, operating the test case, and obtaining 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 so, jumping to S4052, otherwise, jumping to S4151;
s4151, judging that the program branch corresponding to the missing operation result is missing;
s4052, judging whether the value of each expected result is the same as the value of the corresponding running result, if so, jumping to the step S4053, otherwise, jumping to the step S4152;
s4152, judging that a part corresponding to the error operation result has a logic error;
s4053, the test is passed.
In the embodiment, the value of the operation element of the test case is compared with the standard value of the operation element, so that whether the data value and the calculation method of the test case are correct or not can be judged, and then the operation result of the test case is compared with the preset expected result, so that whether the program branch of the test case is missing or not can be further judged, and further, when the error of the test case occurs, the specific position of the error of the program can be accurately positioned.
Fig. 5 is a flowchart of a program testing method according to another embodiment of the present invention, which 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 present embodiment further includes the following steps S5051 to S5053 on the basis of including the above steps S101 to S104 in the above step S105:
s5051, judging whether the number of the expected results is the same as that of the running results or not;
s5052, if the expected result values are the same as the corresponding operation result values, judging whether the expected result values are the same as the corresponding operation result values, if so, judging that the test of the test case passes, otherwise, judging that a logical error exists in the score corresponding to the error operation result;
s5053, if the operation result is different, judging that the program branch corresponding to the missing operation result is missing.
Wherein, there is a corresponding relationship between each expected result in the test scenario and a branch node of the test program, there are M expected results set corresponding to the test scenario and obtained, and there are N operation results of the test case obtained, 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 part corresponding to the error operation result has a logic error; otherwise, judging the branch lack corresponding to the missing operation result.
According to a usage scenario of this embodiment, for example, if the coding logic of the standard program has ten branches, there is an expected result executed corresponding to each branch, and if the test result of the test case has only eight branches, it can be determined that the coding logic of the test case lacks two branches, which indicates that the test case writes a part of code less and causes a 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 running 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 which makes a fault is directly positioned, thereby greatly improving the test precision of the test case.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In an embodiment, a program testing apparatus is provided, which corresponds to the program testing methods in the above embodiments one to one. Fig. 6 is a schematic structural diagram of a program testing apparatus in 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 explained in detail as follows:
the query module 11 is configured to query, according to a preset mapping relationship between the classification identifier and the operation element, a standard value of the operation element, which is stored in correspondence with the classification identifier attached to the test case;
the element value extraction module 12 is configured to extract a value of a corresponding operation element from the test case according to the operation 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, and if so, judge 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 running module 14 is configured to, when the value of the running element of the test case is determined to be correct, obtain an expected result set corresponding to the test case, run the test case, and obtain a running result of the test case;
the second judging module 15 is used for judging whether the expected result is consistent with the operation result, and if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
In one embodiment, the standard value of the operation element is stored in a raw database, and the value of the operation element in the test case is also stored in the raw database.
In one embodiment, the standard values include a first standard value corresponding to the test scenario and a second standard value stored in the shared file, and the element value extraction module 12 includes:
the scene obtaining unit is used for obtaining a test scene corresponding to the classification identifier through a preset mapping relation;
and 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 extraction module 12 is specifically configured to extract the values of the first standard element and the second standard element from the test case.
The first determining 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, and judging whether the value of the second standard element of the test case is correct.
In one embodiment, the operation 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 or not, 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 or not, 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 operation 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 otherwise, judging that the function called by the test case is wrong.
In one embodiment, the operation element includes a method name, and the first determining module 13 further includes:
and the third judging unit is used for judging whether the method name called by the test case is the same as the standard method name, if so, judging that the method called by the test case is correct, and otherwise, judging that the method called by the test case is wrong.
In one embodiment, the second determining module 15 includes:
a result number judging unit, configured to judge whether the number of the expected results is the same as the number of the running results, if so, further judge whether a value of each of the expected results is the same as a value of a corresponding running result, otherwise, judge that a 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 the same as the value of the corresponding operation result, and otherwise, judging that the score corresponding to the error operation result has a logic error.
In this embodiment, the first, second and third determining units in the first, second and third determining units are only used for distinguishing different determining units, and are not used for limiting the execution priorities of the determining units, and have no other limiting meaning, and the execution priorities of the first, second and third determining units can be set differently according to the test requirements.
On one hand, the program testing device selects to directly obtain the standard value of the operation element for testing from the database, and can avoid inaccurate testing result caused by distortion of processed or transferred data compared with data obtained from other places such as an Excel table. The distortion condition may include that when an Excel table is manually entered, wrong data is entered, or errors occur when the data is accumulated and calculated through a specific formula, and the like, and the distortion condition can be well avoided by directly calling the values of the operation elements in the test case from the original database, so that the accuracy of the 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 judgment module, the cause of the program error is preliminarily judged, when all the running elements of the test case are correct, the test case is run through the running module, and whether the running result of the test case meets the expectation is further judged through the second judgment module, so that whether the program branch corresponding to the test case is in error is judged. According to the method and the device, whether the operation element of the program is correct can be judged according to the standard value of the operation element, and whether the corresponding program branch is correct is further judged according to the operation result of the program subsequently because each operation result of the program corresponds to the branch of the corresponding program one by one, so that the accurate positioning of the test case with the error is realized.
The test method for the test case relates to whether each operation element of the program is correct or not, and also 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 the specific definition of the program testing device, reference may be made to the definition of the program testing method above, and details are not repeated here. The respective modules in the program testing apparatus described above may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram 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 comprises a nonvolatile 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 an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external server through a network connection. The computer program is executed by a processor to implement a program testing method.
In one embodiment, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the program testing method in the above embodiments is implemented, for example, steps 101 to 105 shown in fig. 2. Alternatively, the processor, when executing the computer program, implements the functions of the modules/units of the program testing device in the above-described embodiments, such as the functions of the query module 11 to the query module 15 shown in fig. 6. To avoid repetition, further description is omitted here.
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 in the above-described embodiments, such as steps 101 to 105 shown in fig. 2. Alternatively, the computer program, when executed by the processor, implements the functions of the modules/units of the program testing apparatus in the above-described embodiments, such as the functions of the query module 11 to the query module 15 shown in fig. 6. To avoid repetition, further description is omitted here.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile 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 DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A method of program testing, the method comprising:
inquiring a standard value of the operation element which is 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 values of corresponding operation elements from the test cases according to the operation elements obtained by mapping with the classification identifiers of the test cases;
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 the value of the operation element of the test case is judged to be correct, obtaining an expected result set corresponding to the test case, operating the test case and obtaining an operation result of the test case;
judging whether the expected result is consistent with the operation result or not, if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
2. The program testing method according to claim 1, wherein the standard values include a first standard value corresponding to the test scenario and a second standard value stored in the shared file, and the step of querying the standard value of the run element corresponding to the classification identifier of the test case according to the preset mapping relationship between the classification identifier and the run element comprises:
acquiring a test scene corresponding to the classification identification through a preset mapping relation;
and 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.
3. The program test method according to claim 2, wherein the step of extracting values of corresponding run elements from the test cases comprises:
extracting the value of the first standard element and the value of the second standard element from the test case;
the step of judging whether the extracted value of the operating element is the same as the standard value of the corresponding operating element comprises:
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.
4. The program test method according to claim 1, wherein the run element includes an address, a table name, and a field of a data table called by the test case, and the step of determining whether the extracted value of the run element is the same as the standard value of the corresponding run element includes:
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 or not;
if the data tables are the same, judging that the data tables called by the test cases are correct, further judging whether the fields of the data tables called by the test cases are the same as the preset standard fields, and if so, judging that the fields called by the test cases are 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.
5. The program test 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 the same as a standard value of the corresponding run element includes:
and 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 otherwise, judging that the function called by the test case is wrong.
6. The program testing 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 the same as a standard value of the corresponding run element includes:
and judging whether the method name called by the test case is the same as the standard method name, if so, judging that the method called by the test case is correct, and otherwise, judging that the method called by the test case is wrong.
7. The program testing method according to any one of claims 1 to 6, wherein said determining whether the expected result matches the operation result, if so, determining that the test of the test case passes; otherwise, the step of judging the program test failure of the test case comprises the following steps:
judging whether the number of the expected results is the same as that of the running results;
if the expected result values are the same as the corresponding operation result values, judging whether the expected result values are the same as the corresponding operation result values, if so, judging that the test of the test case passes, otherwise, judging that a logical error exists in the score corresponding to the error operation result;
if not, the program branch corresponding to the missing operation result is judged to be missing.
8. A program testing apparatus, characterized in that the apparatus comprises:
the query module is used for querying the standard value of the operation element which is 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 judgment 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 or not, and 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 the value of the operation element of the test case is judged to be correct, operating the test case and acquiring the operation result of the test case;
the second judgment module is used for judging whether the expected result is consistent with the operation result or not, and if so, judging that the test of the test case passes; otherwise, judging that the program test of the test case fails.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the program testing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out a program testing method according to any one of claims 1 to 7.
CN201910841746.8A 2019-09-06 2019-09-06 Program testing method and device, computer equipment and storage medium Pending CN110727582A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910841746.8A CN110727582A (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 CN110727582A (en) 2019-09-06 2019-09-06 Program testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN110727582A true CN110727582A (en) 2020-01-24

Family

ID=69217926

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910841746.8A Pending CN110727582A (en) 2019-09-06 2019-09-06 Program testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110727582A (en)

Citations (5)

* Cited by examiner, † Cited by third party
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
CN109344048A (en) * 2018-08-17 2019-02-15 中国平安人寿保险股份有限公司 A kind of test method, storage medium and server
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
CN109753428A (en) * 2018-12-13 2019-05-14 浙江数链科技有限公司 Service test method, device, computer equipment and readable storage medium storing program for executing

Patent Citations (5)

* Cited by examiner, † Cited by third party
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
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

Similar Documents

Publication Publication Date Title
CN109474578B (en) Message checking method, device, computer equipment and storage medium
CN110941546A (en) Automatic test method, device, equipment and storage medium for WEB page case
CN110765001B (en) Modularized automatic test method and device for application system
CN108491321B (en) Method and device for determining test case range and storage medium
CN109726134B (en) Interface test method and system
CN105138461A (en) Interface testing method and device for application program
CN109062788A (en) Method for generating test case, device, computer equipment and storage medium
CN110751550A (en) Account checking method and device, computer equipment and storage medium
CN113282513B (en) Interface test case generation method and device, computer equipment and storage medium
CN109062925A (en) Automatically generate the method, apparatus, computer equipment and storage medium of insert sentence
CN108132876B (en) Embedded software object code unit testing method based on injection mode
CN112395202B (en) Interface automation test method and device, computer equipment and storage medium
CN111638873A (en) Program code generation method and device, computer equipment and storage medium
CN111615688A (en) Assertion verification code binding method and device
CN110221967A (en) Test data building method, device, computer equipment and storage medium
CN104021072A (en) Machine and methods for evaluating failing software programs
CN110750443A (en) Webpage testing method and device, computer equipment and storage medium
CN111651358B (en) Method for generating test case, software test method, device and server
CN111797026A (en) Test case generation method and device, computer equipment and storage medium
CN110008204A (en) Detection method, device, computer equipment and the storage medium of the quality of data
CN110069404A (en) Code debugging method, apparatus, equipment and 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
WO2021036681A1 (en) Data verification method and apparatus, computer device and storage medium
CN112612706A (en) Automated testing method, computer 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