Program testing method, device, equipment and storage medium
By parsing the source code of the program to be tested to generate a parsing result table and comparing it with the test benchmark table, the problems of low efficiency and accuracy in batch program testing are solved, and efficient testing without executing the program is achieved.
Patent Information
- Application Number
- CN202210105285.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-01-28
Smart Images

Figure CN114443484B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a program testing method, device, equipment and storage medium. Background Art
[0002] Batch programs operate by sequentially processing tasks upon receiving a request, outputting the results after all tasks are completed. Batch programs are executed through the creation of a job plan template, either manually or automatically. The template contains several nodes arranged according to the business logic's processing order. Each node invokes the corresponding batch transaction program, processes the data, and outputs the results. Batch programs can process large amounts of data and take a long time to process.
[0003] Banking systems involve large volumes of data and numerous batch transactions. This often leads to scenarios where the business logic is simple but involves processing numerous table fields. There are two primary approaches to data correctness testing for these batch programs: First, batch transactions are executed using large amounts of de-sensitized production data. The batch results are compared with historical data; if they match, the program is considered correct. Second, testers analyze requirements, generate targeted numbers based on business rules, and compare the manually calculated results with those from the batch program. If they match, the program is considered correct.
[0004] The first approach is limited by the integrity and richness of historical data. First, the database must contain the required data; if historical data is cleared, it cannot be recovered. Second, some unpopular transactions have minimal trading volume, resulting in limited historical data that can be recovered. This low trading volume also leads to insufficient data diversity, making it impossible to cover extreme cases in specific scenarios. Regarding the second approach, if there are many processed fields in the table, data generation becomes more difficult and errors are more likely to occur during testing. Both approaches can reduce test efficiency and quality. Summary of the Invention
[0005] The embodiments of the present invention provide a program testing method, apparatus, device and storage medium, which can improve the efficiency and accuracy of program testing without executing the program to be tested.
[0006] In a first aspect, an embodiment of the present invention provides a program testing method, comprising:
[0007] Obtaining source code of a program to be tested, parsing the source code to obtain a parsing result table;
[0008] The analysis result table is compared with the test reference table, and the comparison result is used as the test result of the program to be tested.
[0009] Furthermore, the parsing result table and the test benchmark table are generated using the same template, which includes a source table name, a target table name, field names, field values, and association rules.
[0010] Furthermore, parsing the source code to obtain a parsing result table includes:
[0011] Extracting business information from the source code, the business information including source table name, target table name, field name, field value and association rules;
[0012] The business information is filled into a blank parsing result table, and the filled blank parsing result table is determined as the parsing result table.
[0013] Furthermore, extracting business information from the source code includes:
[0014] Determining a keyword list corresponding to the business information;
[0015] Searching the source code in the order of the keyword list to determine the target string;
[0016] The target character string is split and read to obtain the business information.
[0017] Furthermore, before comparing the analysis result table with the test benchmark table, the method further includes:
[0018] The test benchmark table is established according to business requirements.
[0019] Furthermore, establishing the test benchmark table according to the business requirements includes:
[0020] Determine the source table and target table based on the business requirements;
[0021] The source table and the target table are assembled to generate the test benchmark table.
[0022] Furthermore, the source table and the target table are assembled, including:
[0023] Determine each target field and field value in the target table;
[0024] Determine the source table fields and corresponding association rules in the source table corresponding to each target field according to the field values;
[0025] Fill the target fields, field values, source table fields and association rules into a blank test benchmark table.
[0026] In a second aspect, an embodiment of the present invention further provides a program testing device, comprising:
[0027] A parsing result table acquisition module is used to obtain the source code of the program to be tested, and parse the source code to obtain the parsing result table;
[0028] The test result acquisition module is used to compare the analysis result table with the test reference table, and use the comparison result as the test result of the program to be tested.
[0029] Optionally, the parsing result table acquisition module is also used to:
[0030] Extracting business information from the source code, the business information including source table name, target table name, field name, field value and association rules;
[0031] The business information is filled into a blank parsing result table, and the filled blank parsing result table is determined as the parsing result table.
[0032] Optionally, the parsing result table acquisition module is also used to:
[0033] Determining a keyword list corresponding to the business information;
[0034] Searching the source code in the order of the keyword list to determine the target string;
[0035] The target character string is split and read to obtain the business information.
[0036] Optionally, the program testing device further includes a test benchmark table establishment module, which is used to establish the test benchmark table according to business requirements.
[0037] Optionally, the test benchmark table establishment module is further used to:
[0038] Determine the source table and target table based on the business requirements;
[0039] The source table and the target table are assembled to generate the test benchmark table.
[0040] Optionally, the test benchmark table establishment module is further used to:
[0041] Determine each target field and field value in the target table;
[0042] Determine the source table fields and corresponding association rules in the source table corresponding to each target field according to the field values;
[0043] Fill the target fields, field values, source table fields and association rules into a blank test benchmark table.
[0044] In a third aspect, an embodiment of the present invention further provides a computer device for program testing, comprising:
[0045] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the program testing method as described in any one of the embodiments of the present invention is implemented.
[0046] In a fourth aspect, an embodiment of the present invention further provides a storage medium for program testing, on which a computer program is stored. When the program is executed by a processing device, the program testing method as described in any one of the embodiments of the present invention is implemented.
[0047] The embodiment of the present invention first obtains the source code of the program to be tested, parses the source code to obtain a parsing result table; then compares the parsing result table with the test benchmark table, and uses the comparison result as the test result of the program to be tested. The program testing method provided by the embodiment of the present invention can verify whether the program is correct based on the field processing logic in the source code of the program to be tested. It only needs to compare the test benchmark table with the parsing result table obtained by parsing the source code, without actually executing the program or loading test data. It can improve the efficiency and accuracy of program testing, and can also perform program testing even when the conditions for program execution are not met. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is a flow chart of a program testing method in Embodiment 1 of the present invention;
[0049] Figure 2 This is a schematic diagram of a program testing process in Example 1 of the present invention;
[0050] Figure 3 This is a flow chart of a program testing method in Embodiment 2 of the present invention;
[0051] Figure 4 This is a schematic diagram of the structure of a program testing device in Embodiment 3 of the present invention;
[0052] Figure 5 It is a structural diagram of a computer device in embodiment 4 of the present invention. DETAILED DESCRIPTION
[0053] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.
[0054] Example 1
[0055] Figure 1This is a flowchart of a program testing method provided in the first embodiment of the present invention. This embodiment is applicable to the case where a program is tested without executing the program. The method can be executed by a program testing device, which can be composed of hardware and / or software and can generally be integrated into a device with program testing function, which can be an electronic device such as a server or a server cluster. Figure 1 As shown, the specific steps include:
[0056] Step 110: Obtain the source code of the program to be tested, parse the source code to obtain a parsing result table.
[0057] The program to be tested is the program that the tester needs to test. Typically, the program to be tested can be a batch program such as a data mart. That is, after receiving a task request, the program processes tasks in sequence and outputs the processing results in a unified manner after all tasks are processed. Source code refers to an uncompiled text file written in a specific programming language specification and a series of human-readable computer language instructions. The parsing result table can be a chart obtained by parsing the source code. The chart can include the table name, field names, and values of each field of the target table, as well as the table name and corresponding field names of the source table associated with each field.
[0058] Code parsing involves converting source code into other formats, such as charts, based on its syntax. Alternatively, a pre-written code parser can be used to input the source code. The program's output is a parsing results table. The code parser breaks down the statements in the source code based on their grammatical structure, extracting the necessary information and filling it into the blank parsing results table.
[0059] Step 120: Compare the parsing result table with the test reference table, and use the comparison result as the test result of the program to be tested.
[0060] The test benchmark table may be a chart determined according to business requirements and business rules, which includes table names, field names, field values, and association relationships involved in the task processing of the program to be tested.
[0061] In this embodiment, after obtaining the analysis result table and the test reference table, the contents of the two tables can be compared. If the comparison result shows that the contents of the two tables are consistent, the program to be tested is correct; if the comparison result shows that the contents of the two tables are inconsistent, the program to be tested is incorrect.
[0062] In this embodiment, the parsing result table and the test benchmark table are generated using the same template, which includes a source table name, a target table name, field names, field values, and association rules.
[0063] Preferably, to facilitate comparison, the analysis result table and the test benchmark table can be generated using the same template.
[0064] In this embodiment, before comparing the parsing result table with the test benchmark table, it is also possible to: create a test benchmark table according to business requirements.
[0065] Optionally, a test benchmark table can be established based on business requirements, which can be obtained from the requirements document. The present invention requires testers to intervene as early as possible in the requirements development stage. During the process of writing the requirements document, they work with business personnel to clarify and draw the test benchmark, determine the table names, fields, field types, field values, and the relationships between tables involved in the business rules, and ensure that each record in the test benchmark has a clear source and target, so that it can be used as a basis for testing and code development in the future.
[0066] Optionally, the test benchmark table may be established according to business requirements by: determining a source table and a target table according to business requirements; and compiling the source table and the target table to generate the test benchmark table.
[0067] Specifically, the requirements document may contain multiple business requirements, and the business requirements may determine the generation rules of the target table and determine the source table and the target table. The target table is processed and generated based on the source table. Preferably, after determining the source table and the target table, the fields of the target table and the corresponding field values may be filled in the blank test benchmark table. There may be some fields in the target table whose values are related to one or more fields in the source table. In this case, the source table names corresponding to these fields and the fields in the corresponding source table need to be filled in the corresponding positions of the test benchmark table; for the fields in the target table whose values are not related to the source table, the source table names corresponding to these fields and the fields in the source table can be filled in with "None". The test benchmark table should contain all the fields in the target table.
[0068] Furthermore, the source table and the target table can be assembled in the following manner: determining each target field and field value in the target table; determining the source table field and corresponding association rules in the source table corresponding to each target field based on the field value; and filling each target field, field value, source table field and association rules into a blank test benchmark table.
[0069] For example, let Table 1 be the source table and Table 2 be the target table. Table 1 contains fields 1, 2, 3, 4, and 5, and Table 2 contains fields A, B, C, D, and E. The value of field A is "new valid data", the values of fields B and C are copied from fields 1 and 2 in Table 1 respectively, the value of field D is "current data", and the value of field F is 1. Then, by assembling the source table and the target table, the generated test benchmark table can be:
[0070]
[0071] Figure 2 This is a schematic diagram of a program testing process provided by an embodiment of the present invention. As shown in the figure, after obtaining business requirements and source and target tables, a test benchmark table can be established based on the business requirements and table contents. When program testing is required, a code parser can be used to parse the source code of the program to be tested into a parsing result table. By comparing the contents of the parsing result table with those of the test benchmark table to determine whether they are consistent, it can be determined whether the program to be tested is correct.
[0072] The embodiment of the present invention first obtains the source code of the program to be tested, parses the source code to obtain a parsing result table; then compares the parsing result table with the test benchmark table, and uses the comparison result as the test result of the program to be tested. The program testing method provided by the embodiment of the present invention can verify whether the program is correct based on the field processing logic in the source code of the program to be tested. It only needs to compare the test benchmark table with the parsing result table obtained by parsing the source code, without actually executing the program or loading test data. It can improve the efficiency and accuracy of program testing, and can also perform program testing even when the conditions for program execution are not met.
[0073] Example 2
[0074] Figure 3 This is a flow chart of a program testing method provided by the second embodiment of the present invention. This embodiment is applicable to the case where a program is tested without executing the program. Figure 3 As shown, the specific steps include:
[0075] Step 210: Obtain the source code of the program to be tested.
[0076] In this embodiment, the source code of the program to be tested can be obtained from business personnel.
[0077] Step 220: Extract business information from the source code.
[0078] The business information includes the source table name, target table name, field name, field value, and association rules.
[0079] In this embodiment, after the source code is obtained, information such as the source table name, target table name, field name, field value, and association rules can be extracted from the source code.
[0080] Optionally, the business information in the source code may be extracted by: determining a keyword list corresponding to the business information; searching in the source code in the order of the keyword list to determine a target string; and splitting and reading the target string to obtain the business information.
[0081] Specifically, for the source code of an SQL statement, keywords corresponding to business information may include "insert," "into," "select," and "from." A keyword list can be defined as: list0 = [select, insert, from, inner, join, leftjoin, rightjoin], and a sentence structure can be defined as: listi1 = [insert, into, select, from]; listi2 = [insert, into, select, from, where]; listi3 = [insert, into, select, from, where, and]; listi4 = [insert, into, select, from, inner, join, where]; listi5 = [insert, into, select, from, join, where, and]. The target string in the source code is searched for in sequence according to the keyword list, and the comments between / ** / are removed. The string can then be split using spaces as delimiters and placed into the target string list after the split.
[0082] Furthermore, by reading the target string sequentially, you can obtain the business information contained therein. For example, you can obtain the target table name by reading the content between "insertinto" and "("; you can obtain the target table field name list by reading the content within "()" between "insert" and "select" and splitting it by ","; and you can obtain the source table name by reading the content after "from".
[0083] Step 230: Fill the business information into the blank parsing result table, and determine the filled blank parsing result table as the parsing result table.
[0084] In this embodiment, after obtaining the business information in the source code, the business information can be filled into the blank parsing result table to obtain the parsing result table.
[0085] Step 240: Compare the parsing result table with the test reference table, and use the comparison result as the test result of the program to be tested.
[0086] In this embodiment, after obtaining the analysis result table, it can be compared with the pre-written test reference table. If the comparison result shows that the contents of the two tables are consistent, the program to be tested is correct. If the comparison result shows that the contents of the two tables are inconsistent, the program to be tested is incorrect.
[0087] The embodiment of the present invention first obtains the source code of the program to be tested, then extracts the business information in the source code, and then fills the business information into a blank parsing result table, determines the filled blank parsing result table as the parsing result table, and finally compares the parsing result table with the test benchmark table, and uses the comparison result as the test result of the program to be tested. The program testing method provided by the embodiment of the present invention can verify whether the program is correct based on the field processing logic in the source code of the program to be tested. It only needs to compare the test benchmark table with the parsing result table obtained by parsing the source code. There is no need to actually execute the program or load test data. It can improve the efficiency and accuracy of program testing, and can also perform program testing when the program execution conditions are not met.
[0088] Example 3
[0089] Figure 4 This is a schematic diagram of the structure of a program testing device provided in the third embodiment of the present invention. Figure 4 As shown, the device includes: an analysis result table acquisition module 310 and a test result acquisition module 320.
[0090] The parsing result table acquisition module 310 is used to acquire the source code of the program to be tested, and parse the source code to obtain the parsing result table.
[0091] Optionally, the parsing result table acquisition module 310 is further configured to:
[0092] Extract business information from the source code, including source table name, target table name, field name, field value, and association rules; fill the business information into a blank parsing result table, and determine the filled blank parsing result table as the parsing result table.
[0093] Optionally, the parsing result table acquisition module 310 is further configured to:
[0094] Determine a keyword list corresponding to the business information; search in the source code in the order of the keyword list to determine the target string; split and read the target string to obtain the business information.
[0095] The test result acquisition module 320 is used to compare the parsing result table with the test reference table and use the comparison result as the test result of the program to be tested.
[0096] Optionally, the program testing apparatus further includes a test benchmark table establishing module 330 for establishing a test benchmark table according to business requirements.
[0097] Optionally, the test benchmark table establishing module 330 is further configured to:
[0098] Determine the source table and target table based on business needs; compile the source table and target table to generate a test benchmark table.
[0099] Optionally, the test benchmark table establishing module 330 is further configured to:
[0100] Determine each target field and field value in the target table; based on the field value, determine the source table field in the source table corresponding to each target field and the corresponding association rules; fill each target field, field value, source table field and association rules into the blank test benchmark table.
[0101] The above device can execute the methods provided by all the above embodiments of the present disclosure, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not fully described in this embodiment, please refer to the methods provided by all the above embodiments of the present disclosure.
[0102] Example 4
[0103] Figure 5 A schematic diagram of the structure of a computer device provided in Example 4 of the present invention. Figure 5 A block diagram of a computer device 412 suitable for implementing embodiments of the present invention is shown. Figure 5 The computer device 412 shown is only an example and should not limit the functionality and scope of use of the embodiments of the present invention. The device 412 is a typical program testing computing device.
[0104] like Figure 5 As shown, computer device 412 is implemented as a general-purpose computing device. Components of computer device 412 may include, but are not limited to, one or more processors 416, storage device 428, and a bus 418 that connects various system components (including storage device 428 and processor 416).
[0105] Bus 418 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MCA) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0106] The computer device 412 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 412, including volatile and non-volatile media, removable and non-removable media.
[0107] The storage device 428 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 430 and / or cache memory 432. The computer device 412 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 434 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 Not shown, often called a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a Compact Disc-Read Only Memory (CD-ROM), a Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 418 via one or more data media interfaces. Storage device 428 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.
[0108] A program 436 having a set (at least one) of program modules 426 may be stored, for example, in a storage device 428. Such program modules 426 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 426 generally implement the functions and / or methods of the embodiments described herein.
[0109] The computer device 412 may also communicate with one or more external devices 414 (e.g., a keyboard, a pointing device, a camera, a display 424, etc.), one or more devices that enable a user to interact with the computer device 412, and / or any device that enables the computer device 412 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 422. Furthermore, the computer device 412 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 420. As shown, the network adapter 420 communicates with the other modules of the computer device 412 via a bus 418. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in conjunction with the computer device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0110] The processor 416 executes various functional applications and data processing by running the programs stored in the storage device 428, such as implementing the program testing method provided in the above embodiment of the present invention.
[0111] Example 5
[0112] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processing device, the program testing method according to the embodiment of the present invention is implemented. The computer-readable medium of the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal transmitted in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0113] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0114] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0115] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains the source code of the program to be tested, parses the source code to obtain a parsing result table; compares the parsing result table with the test benchmark table, and uses the comparison result as the test result of the program to be tested.
[0116] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0117] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0118] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.
[0119] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0120] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0121] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A program testing method, characterized in that: include: Obtaining source code of a program to be tested, parsing the source code to obtain a parsing result table; Comparing the parsing result table with the test benchmark table, and using the comparison result as the test result of the program to be tested; wherein the parsing result table and the test benchmark table are generated using the same template, and the template includes a source table name, a target table name, a field name, a field value, and an association rule; The using the comparison result as the test result of the program to be tested includes: if the comparison result shows that the contents of the two tables are consistent, then the program to be tested is correct; if the comparison result shows that the contents of the two tables are inconsistent, then the program to be tested is wrong; Parse the source code to obtain a parsing result table, including: Extracting business information from the source code, the business information including source table name, target table name, field name, field value, and association rules; Filling the business information into a blank parsing result table, and determining the filled blank parsing result table as the parsing result table; Before comparing the analysis result table with the test benchmark table, the method further includes: Determine the source table and target table based on business needs; Determine each target field and field value in the target table; Determine the source table fields and corresponding association rules in the source table corresponding to each target field according to the field values; Fill the target fields, field values, source table fields and association rules into a blank test benchmark table.
2. The method according to claim 1, characterized in that Extracting business information from the source code, including: Determining a keyword list corresponding to the business information; Searching the source code in the order of the keyword list to determine the target string; The target character string is split and read to obtain the business information.
3. A program testing device, characterized in that: include: A parsing result table acquisition module is used to obtain the source code of the program to be tested, and parse the source code to obtain the parsing result table; a test result acquisition module, configured to compare the parsing result table with the test benchmark table and use the comparison result as the test result of the program to be tested; wherein the parsing result table and the test benchmark table are generated using the same template, the template including the source table name, target table name, field name, field value and association rules; The test result acquisition module is specifically configured to: if the comparison result shows that the contents of the two tables are consistent, then the program to be tested is correct; if the comparison result shows that the contents of the two tables are inconsistent, then the program to be tested is wrong; The parsing result table acquisition module is further used to: Extract business information from the source code, including source table name, target table name, field name, field value, and association rules; fill the business information into the blank parsing result table, and determine the filled blank parsing result table as the parsing result table; The program testing device further includes a test benchmark table establishment module, which is used to: Determine the source table and target table based on business needs; determine the target fields and field values in the target table; based on the field values, determine the source table fields and corresponding association rules in the source table corresponding to each target field; fill in the target fields, field values, source table fields and association rules into the blank test benchmark table.
4. A computer device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the program testing method according to any one of claims 1 to 2 when executing the program.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the program testing method according to any one of claims 1 to 2 is implemented.
Citation Information
Patent Citations
Test method and device of data processing system, storage medium and program product
CN113326206A