Test method, device, equipment and storage medium

By extracting input and output data from the background and generating a test scenario parameter group when business personnel execute the logic to be tested, the problem of time-consuming and laborious data source generation and low test accuracy in the prior art is solved, and automatic crawling and high accuracy testing of production environment test cases are realized.

CN112486829BActive Publication Date: 2025-03-11CHINA CITIC BANK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011402258.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-04
Publication Date
2025-03-11
Estimated Expiration
2040-12-04

AI Technical Summary

Technical Problem

In the prior art, the generation method of data source is time-consuming and laborious, and there are subjective factors in the test scenario parameters manually constructed by testers, resulting in low test accuracy.

Method used

During the process of business personnel executing the logic to be tested, input data and output data are extracted from the background, and the test scenario parameter group is determined based on these data, and stored in the data source, thereby automatically grabbing real test cases in the production environment.

Benefits of technology

It realizes automatic capture of real test cases in production environments, reduces the construction cost of data source generation, and improves the test accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112486829B_ABST
    Figure CN112486829B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention disclose a testing method, device, equipment and storage medium, which relate to the field of testing technology. The method comprises: in the process of business personnel executing the logic to be tested, extracting the input data and output data of the logic to be tested from the background; determining a test scenario parameter group according to the input data and the output data, and storing the test scenario parameter group in a data source; reading at least two test scenario parameter groups from the data source, and generating logic based on at least one scenario, generating at least two test scenario data according to the at least two test scenario parameter groups read; testing the logic to be tested according to the at least two test scenario data. The embodiments of the present invention provide a testing method, device, equipment and storage medium, which solve the problems of high construction cost and low test accuracy of the existing data source generation method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of testing technology, and in particular to a testing method, device, equipment and storage medium. Background Art

[0002] Currently, when testing is performed using a data source and unit test logic, the test scenario parameters in the data source are manually constructed by the tester.

[0003] The above data source generation method is not only time-consuming and labor-intensive, but also the test scenario parameters manually constructed by the tester have subjective factors. Therefore, the test accuracy based on the manually constructed test scenario data is low. Summary of the invention

[0004] The embodiments of the present invention provide a testing method, an apparatus, a device and a storage medium to solve the above problems.

[0005] In a first aspect, an embodiment of the present invention provides a testing method, the method comprising:

[0006] When the business personnel execute the logic to be tested, the input data and output data of the logic to be tested are extracted from the background;

[0007] Determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source;

[0008] Reading at least two test scenario parameter groups from the data source, and generating at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic;

[0009] The logic to be tested is tested according to the at least two test scenario data.

[0010] In a second aspect, an embodiment of the present invention further provides a testing device, the device comprising:

[0011] The data capture module is used to extract the input data and output data of the logic to be tested from the background when the business personnel execute the logic to be tested;

[0012] A data storage module, used to determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source;

[0013] A scenario data generation module, configured to read at least two test scenario parameter groups from the data source, and generate at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic;

[0014] A testing module is used to test the logic to be tested according to the at least two test scenario data.

[0015] In a third aspect, an embodiment of the present invention further provides a device, the device comprising:

[0016] one or more processors;

[0017] a storage device for storing one or more programs,

[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the testing method as described in any one of the embodiments of the present invention.

[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a test method as described in any one of the embodiments of the present invention.

[0020] The embodiment of the present invention extracts the input data and output data of the logic to be tested from the background during the process of business personnel executing the logic to be tested; determines the test scenario parameter group according to the input data and the output data, and stores the test scenario parameter group in the data source, thereby realizing automatic capture of real test cases in the production environment, thereby solving the problem of high construction cost of the existing data source generation method. Because the captured test cases are objective and real, the problem of low test accuracy of the existing data source generation method is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flow chart of a testing method provided in Embodiment 1 of the present invention;

[0022] Figure 2 is a flow chart of a testing method provided in Embodiment 2 of the present invention;

[0023] Figure 3 It is a schematic diagram of SpringAOP provided by Embodiment 2 of the present invention;

[0024] Figure 4 is a structural schematic diagram of a testing device provided in Embodiment 3 of the present invention;

[0025] Figure 5 A schematic diagram of the structure of a device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0026] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0027] Embodiment 1

[0028] Figure 1 This is a flow chart of a testing method provided by Embodiment 1 of the present invention. This embodiment can be applied to automatically capture real test cases in a production environment to reduce the construction cost of the data source and improve the test accuracy. Figure 1 , the testing method provided by the embodiment of the present invention includes:

[0029] S110 . When the business personnel execute the logic to be tested, the input data and output data of the logic to be tested are extracted from the background.

[0030] Among them, business personnel refer to people who trigger and execute the logic to be tested during the production process.

[0031] The logic to be tested refers to the business logic to be tested, which can be method logic or interface logic.

[0032] The backend refers to the system that implements website functions such as editing content, modification, and data capture.

[0033] By extracting the input data and output data of the logic to be tested from the background, the input data and output data can be captured without the business personnel being aware of it.

[0034] S120. Determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source.

[0035] The data source is a storage medium for storing the test scenario parameter group. Specifically, the data source may be a file, a database, or a table.

[0036] A test scenario parameter group refers to a combination of parameters that describes a test scenario.

[0037] S130. Read at least two test scenario parameter groups from the data source, and generate at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic.

[0038] Among them, the scenario generation logic is the logic for generating test scenario data.

[0039] Test scenario data refers to data that describes the test scenario.

[0040] Specifically, based on Junit, at least two test scenario parameter groups may be read from a data source, and based on at least one scenario generation logic, at least two test scenario data may be generated according to the at least two test scenario parameter groups read.

[0041] Among them, Junit is a widely used Java unit testing framework.

[0042] S140: Test the logic to be tested according to the at least two test scenario data.

[0043] Specifically, if the logic to be tested is a control interface logic, testing the logic to be tested according to the at least two test scenario data may include:

[0044] According to the at least two test scenario data, calling the control interface logic to be tested in the form of a network;

[0045] A test result of the control interface logic to be tested is determined according to the output result of the control interface logic to be tested.

[0046] The control structure logic refers to the logic describing the control interface. The control interface refers to the Controller interface in a WEB (webpage) application.

[0047] Optionally, if the logic to be tested is method logic or other interface logic except control interface logic, testing the logic to be tested according to the at least two test scenario data may include:

[0048] Generate simulation objects of at least two test scenarios according to the at least two test scenario data;

[0049] Inputting the simulation objects of the at least two test scenarios into the logic to be tested;

[0050] A test result of the logic to be tested is determined according to an output result of the logic to be tested.

[0051] The embodiment of the present invention extracts the input data and output data of the logic to be tested from the background during the process of business personnel executing the logic to be tested; determines a test scenario parameter group according to the input data and the output data, and stores the test scenario parameter group in a data source, thereby realizing automatic capture of real test cases in a production environment, thereby solving the problems of high construction cost and low test accuracy of existing data source generation methods.

[0052] Embodiment 2

[0053] Figure 21 is a flow chart of a test method provided by the second embodiment of the present invention. This embodiment is based on the above embodiment, and further optimizes the above S110 and S130. Figure 2 The testing method provided in the second embodiment of the present invention includes:

[0054] S111. Based on the SpringAOP framework, when the business personnel execute the logic to be tested, the input data and output data of the logic to be tested are extracted from the background.

[0055] Among them, Spring AOP is a key component in the Spring framework, namely the aspect-oriented programming (AOP) framework. Aspect-oriented programming requires breaking down program logic into different parts called pointcuts. Functions across multiple points of an application are called cross-cutting concerns, which are conceptually independent of the business logic of the application. Spring AOP is used in scenarios such as logging, auditing, declarative transactions, security, and caching.

[0056] See also Figure 3 , SpringAOP can realize the output message or output code of the method logic to be tested or the interface logic to be tested, as well as the response of the input message.

[0057] S120, determining a test scenario parameter group according to the input data and the output data, and storing the test scenario parameter group in a data source;

[0058] S131, based on the Feed4Junit unit test framework, read at least two test scenario parameter groups from the data source, and based on at least one scenario generation logic, generate at least two test scenario data according to the read at least two test scenario parameter groups;

[0059] Specifically, based on Feed4Junit, at least two test scenario parameter groups are read from a data source, and based on at least one scenario generation logic, at least two test scenario data are generated according to the read at least two test scenario parameter groups, including:

[0060] Based on the new unit test framework, at least two test scenario parameter groups are read from a data source, and based on at least one scenario generation logic, at least two test scenario data are generated according to the at least two test scenario parameter groups read;

[0061] The new unit test framework is obtained by modifying the inheritance relationship of Feed4Junit, and the new unit test framework inherits from the executor of the Spring framework.

[0062] Among them, the new unit testing framework is a unit testing framework integrated with Spring, which realizes the separation of data and code, and can completely separate test cases and test driver codes, realizing the complete decoupling of test cases and test codes. It is implemented by myself by extending the Feed4Junit source code. It is not the same framework as Junit4. Junit4 does not realize the separation of data and test code, and data and code need to be coupled together.

[0063] The Spring framework is an open source Java platform that provides a comprehensive infrastructure for easy and fast development of durable Java applications. It was created to address the complexity of enterprise application development. Currently, almost all web systems involved, from state-owned enterprises to Internet companies, from traditional private enterprises to joint-stock companies, are built using the Spring framework.

[0064] S140: Test the logic to be tested according to the at least two test scenario data.

[0065] The technical solution of the embodiment of the present invention integrates the data and code separation testing advantages of the new unit testing framework and the characteristic advantages of SpringAOP aspect programming, and uses SpringAOP technology to realize the automatic generation of test cases without any intrusion to the source code program. That is, when the business testers are performing normal business tests, the present invention can automatically capture the business personnel's input test cases and save them to generate test cases without the business personnel noticing. Through the full-scenario testing of the business personnel, the full-scenario test cases of each interaction are saved to the data source. According to these cases, the new unit testing framework is used to perform regression testing on interfaces, methods, etc.

[0066] In other words, the embodiments of the present invention automatically capture test cases of business testers or developers, deploy them to the production environment, capture real test cases of the production environment, and use these test cases to perform regression testing on the system, thereby solving the problems of difficult test writing, incomplete test case coverage, and inability to accumulate test cases. This greatly reduces the pressure on developers to write test cases and consolidates and accumulates test cases for business testing and production environments.

[0067] Embodiment 3

[0068] Figure 4 Schematic diagram of the structure of a test device provided by Embodiment 3 of the present invention. Figure 4 The test device provided in the embodiment of the present application includes: a data capture module 10, a data storage module 20, a scene data generation module 30 and a test module 40.

[0069] The data capture module 10 is used to extract the input data and output data of the logic to be tested from the background when the business personnel execute the logic to be tested;

[0070] A data storage module 20, configured to determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source;

[0071] A scenario data generation module 30, configured to read at least two test scenario parameter groups from the data source, and generate at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic;

[0072] The testing module 40 is used to test the logic to be tested according to the at least two test scenario data.

[0073] The embodiment of the present invention extracts the input data and output data of the logic to be tested from the background during the process of business personnel executing the logic to be tested; determines a test scenario parameter group according to the input data and the output data, and stores the test scenario parameter group in a data source, thereby realizing automatic capture of real test cases in a production environment, thereby solving the problems of high construction cost and low test accuracy of existing data source generation methods.

[0074] Furthermore, the data capture module includes:

[0075] The data capture unit is used to extract the input data and output data of the logic to be tested from the background based on the SpringAOP framework when the business personnel execute the logic to be tested.

[0076] Furthermore, the scene data generation module includes:

[0077] The scenario data generation unit is used to read at least two test scenario parameter groups from a data source based on the Feed4Junit unit test framework, and generate at least two test scenario data according to the at least two test scenario parameter groups read based on at least one scenario generation logic.

[0078] Furthermore, the scene data generating unit is specifically used to:

[0079] Based on the new unit test framework, at least two test scenario parameter groups are read from a data source, and based on at least one scenario generation logic, at least two test scenario data are generated according to the at least two test scenario parameter groups read;

[0080] The new unit test framework is obtained by modifying the inheritance relationship of Feed4Junit, and the new unit test framework inherits from the executor of the Spring framework.

[0081] Embodiment 4

[0082] Figure 5 This is a schematic diagram of the structure of a device provided in Embodiment 4 of the present invention. Figure 5 As shown, the device includes a processor 50, a memory 51, an input device 52 and an output device 53; the number of processors 50 in the device can be one or more. Figure 5 A processor 50 is taken as an example; the processor 50, memory 51, input device 52 and output device 53 in the device can be connected by a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0083] The memory 51 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the test method in the embodiment of the present invention (for example, the data capture module 10, the data storage module 20, the scene data generation module 30 and the test module 40 in the test device). The processor 50 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 51, that is, implementing the above-mentioned test method.

[0084] The memory 51 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 51 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 51 may further include a memory remotely arranged relative to the processor 50, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0085] The input device 52 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 53 may include a display device such as a display screen.

[0086] Embodiment 5

[0087] Embodiment 5 of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a testing method when executed by a computer processor, the method comprising:

[0088] When the business personnel execute the logic to be tested, the input data and output data of the logic to be tested are extracted from the background;

[0089] Determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source;

[0090] Reading at least two test scenario parameter groups from the data source, and generating at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic;

[0091] The logic to be tested is tested according to the at least two test scenario data.

[0092] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, and can also execute related operations in the test method provided by any embodiment of the present invention.

[0093] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0094] It is worth noting that in the embodiment of the above-mentioned testing device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0095] Note that the above are only preferred embodiments of the present invention and the technical principles used. 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 more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A testing method, characterized in that: include: When the business personnel execute the logic to be tested, the input data and output data of the logic to be tested are extracted from the background; Determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source; Reading at least two test scenario parameter groups from the data source, and generating at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic; Testing the logic to be tested according to the at least two test scenario data; The process of extracting input data and output data of the logic to be tested from the background during the execution of the logic to be tested by the business personnel includes: Based on the SpringAOP framework, when business personnel execute the logic to be tested, the input data and output data of the logic to be tested are extracted from the background; Based on Feed4Junit, at least two test scenario parameter groups are read from a data source, and based on at least one scenario generation logic, at least two test scenario data are generated according to the read at least two test scenario parameter groups, including: Based on the new unit test framework, at least two test scenario parameter groups are read from a data source, and based on at least one scenario generation logic, at least two test scenario data are generated according to the at least two test scenario parameter groups read; The new unit test framework is obtained by modifying the inheritance relationship of Feed4Junit, the new unit test framework inherits from the executor of the Spring framework, and the new unit test framework realizes the separation of data and code.

2. A testing device, characterized in that: include: The data capture module is used to extract the input data and output data of the logic to be tested from the background when the business personnel execute the logic to be tested; A data storage module, used to determine a test scenario parameter group according to the input data and the output data, and store the test scenario parameter group in a data source; A scenario data generation module, configured to read at least two test scenario parameter groups from the data source, and generate at least two test scenario data according to the read at least two test scenario parameter groups based on at least one scenario generation logic; A testing module, used for testing the logic to be tested according to the at least two test scenario data; The data capture module includes: A data capture unit is used to extract input data and output data of the logic to be tested from the background when the business personnel execute the logic to be tested based on the SpringAOP framework; The scene data generation module comprises: A scenario data generation unit, used to read at least two test scenario parameter groups from a data source based on a Feed4Junit unit test framework, and based on at least one scenario generation logic, generate at least two test scenario data according to the at least two test scenario parameter groups read, including: based on a new unit test framework, reading at least two test scenario parameter groups from a data source, and based on at least one scenario generation logic, generating at least two test scenario data according to the at least two test scenario parameter groups read; The scene data generating unit is specifically used for: The inheritance relationship of Feed4Junit is modified to obtain a new unit test framework, so that the new unit test framework inherits from the executor of the Spring framework, and the new unit test framework realizes the separation of data and code.

3. An electronic device, characterized in that: The device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the testing method as claimed in claim 1.

4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the testing method according to claim 1 is implemented.

Citation Information

Patent Citations

  • Method, device and equipment for detecting service logic vulnerability and medium

    CN110414242A