Test case generation method, device, electronic device and storage medium

By generating a recording component in the web page plug-in, excluding carousel data and recording web pages in batches, and generating DSL language test cases, the problem of high cost of writing and maintaining automated test cases is solved, and low-cost and easy-to-manage test case generation is achieved.

CN112559355BActive Publication Date: 2025-09-16CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011510532.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-18
Publication Date
2025-09-16
Estimated Expiration
2040-12-18

AI Technical Summary

Technical Problem

In the existing technology, the writing and maintenance of automated test cases requires a lot of manpower, especially for the Internet industry with frequent iterations. In addition, the existing DSL language generation method has high requirements for testers, which increases learning and maintenance costs.

Method used

Use web plug-ins to generate recording components, exclude carousel data, record web pages in batches, obtain attribute data, and generate DSL language test cases through interception interfaces, reducing learning and maintenance costs.

Benefits of technology

It enables the generation of DSL language test cases without manual training, reduces the learning and maintenance costs of operators, and improves the cost-effectiveness of test case management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112559355B_ABST
    Figure CN112559355B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of system testing and provides a method for generating test cases. First, a recording component is generated in a page to be collected using a webpage plug-in. Then, an exclusion interface on the recording component is loaded to exclude carousel data in the page to be collected, converting the page to be collected into a full test page. Then, a recording switch on the recording component is loaded to record the full test page in batches, obtain attribute data in the page to be collected, and then, switching data is intercepted and obtained through an interception interface in the full test page. The user's switching data is combined with the attribute data to generate a DSL language test case. Thus, a specific DSL language is automatically used to generate test cases, reducing learning, writing and maintenance costs. In addition, an operator can directly review and modify the generated DSL application, improving the efficiency of test case management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of system testing, and in particular to a method for generating a test case, a device, an electronic device and a computer-readable storage medium. Background Art

[0002] Testing is an indispensable and important part of product development iteration, and functional testing is the most important part of the testing process. The importance of functional testing in product development is reflected in all aspects, including developers verifying the correctness of functions during development, testers ensuring the correctness of product functions after development, and ensuring the stability of products after going online.

[0003] Automated testing is inseparable from the writing of test cases. The maintenance and iterative writing of test cases often require a lot of manpower, especially in the Internet industry where iterations are particularly frequent. In addition, writing test cases generally requires a certain level of coding foundation, which places certain demands on testers.

[0004] Therefore, in order to reduce the workload of testers, test cases are currently generated using a specific DSL language. The automated testing DSL language is an automated test case written in natural language. Although the use of this language greatly reduces the learning and writing maintenance costs, it still has certain requirements for testers. Testers must undergo DSL language training before they can use it correctly.

[0005] Therefore, there is an urgent need for a test case generation method that can be written in natural language and reduce the cost of learning and maintaining test cases. Summary of the Invention

[0006] The present invention provides a test case generation method, device, electronic device and computer-readable storage medium, the main purpose of which is to directly generate a recorder in a web page and set a recording switch for the recorder, so as to directly generate a specific DSL natural language test case in the browser when actively recording a web page, without generating an action page result mapping, and collect data on the interface during web page operation, and use the data to simulate the interface at runtime, thereby excluding elements that are constantly changing in the web page.

[0007] To achieve the above object, the present invention provides a method for generating a test case, comprising:

[0008] Use web page plug-ins to generate recording components in the page to be collected;

[0009] Loading the exclusion interface on the recording component to exclude the carousel data in the page to be collected, so that the page to be collected is converted into a full test page;

[0010] Loading the recording switch on the recording component, recording the full test page in batches, and obtaining attribute data from the page to be collected;

[0011] The user's switching data is combined with the attribute data to generate a DSL language test case; wherein, the switching data is intercepted and obtained through the interception interface in the full test page.

[0012] Optionally, the process of using a web page plug-in to generate a recording component in the page to be collected includes:

[0013] Get the web plug-in;

[0014] Injecting a collection script into the page to be collected through the web page plug-in;

[0015] Marking the matching interface information in the acquisition script to form a visual script;

[0016] Editing recording rules in the visual script forms a recording component.

[0017] Optionally, the process of excluding the carousel data in the page to be collected and converting the page to be collected into a full test page includes:

[0018] Reading dynamic data of each page in the pages to be collected;

[0019] Analyzing the dynamic data to determine whether the dynamic data is carousel data or passive data;

[0020] If the dynamic data is carousel data, a carousel key is set;

[0021] Divide the carousel key into a public key and a private key, place the public key on the recording component, and place the private key on the carousel data;

[0022] When the recording component records the page to be collected, if the public key on the recording component is paired with the public key on the carousel data, the recording component abandons recording the carousel data and excludes the carousel data to form a full test page.

[0023] Optionally, the process of determining whether the dynamic data is carousel data or passive data includes:

[0024] Writing an infiltration program so that the infiltration program obtains the source of the dynamic data;

[0025] Analyze the source to determine whether the source is original code or element click;

[0026] If it is original encoding, the dynamic data is carousel data; if it is element click, the dynamic data is passive data.

[0027] Optionally, the process of loading the recording switch on the recording component and recording the full test page in batches includes:

[0028] Preset data thresholds;

[0029] Analyze the data values ​​of the single pages and page combinations of the pages to be collected, and determine whether the data values ​​of the single pages and page combinations exceed the data threshold;

[0030] If the data value of the single page exceeds the data threshold, the single page is divided into two for collection; if the data value of the single page does not exceed the data threshold, the single page is directly collected; if the data value of the page combination is less than the data threshold, the page combination is directly collected at one time; if the data value of the page combination is greater than the data threshold, the page combination is divided into a limited number of single pages, and the limited number of single pages are collected in batches, one page at a time;

[0031] Each time a collection is completed, the recording controller is automatically closed and stays for a preset time, and then the recording controller is automatically opened to start the next collection.

[0032] Optionally, the process of obtaining the attribute data in the page to be collected includes:

[0033] Initialize the page to be collected;

[0034] Collecting general information of the browser where the page to be collected is located; the general information at least includes the length and width of the browser;

[0035] Locking the collection range of the pages to be collected according to the general information;

[0036] The user of the page to be collected is bound, and the cursor operation data generated by the user within the collection range is obtained to obtain the click element of the user.

[0037] Optionally, the process of combining the user's switching data with the attribute data to generate a DSL language test case includes:

[0038] The user of the page to be collected sends a command request to the full test page;

[0039] The data interface in the full test page receives and processes the command request to form a return value;

[0040] An interception interface is opened between the data interface and the full test page, and the interception interface is enabled so that the interception interface obtains the command request and the return value;

[0041] Analyzing the command request and the return value to obtain node changes of the full test page;

[0042] The node changes are converted into switching data, and the switching data is combined with the attribute data to generate a DSL language test case.

[0043] In order to solve the above problems, the present invention further provides a test case generation device, the device comprising:

[0044] A component generation unit, configured to generate a recording component in the page to be collected using a web page plug-in;

[0045] A carousel data exclusion unit, configured to load an exclusion interface on the recording component, exclude the carousel data from the page to be collected, and convert the page to be collected into a full test page;

[0046] A page recording unit, configured to load a recording switch on the recording component, record the full test page in batches, and obtain attribute data from the page to be collected;

[0047] The test case generating unit is used to combine the user's switching data with the attribute data to generate a DSL language test case; wherein, the switching data is intercepted and obtained through the interception interface in the full test page.

[0048] In order to solve the above problem, the present invention further provides an electronic device, comprising:

[0049] a memory storing at least one instruction; and

[0050] The processor executes the instructions stored in the memory to implement the steps in the above-mentioned test case generation method.

[0051] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the method for generating test cases described above.

[0052] The embodiment of the present invention first uses a webpage plug-in to generate a recording component in the page to be collected, then loads the exclusion interface on the recording component to exclude the carousel data in the page to be collected, so that the page to be collected is converted into a full test page, and then loads the recording switch on the recording component to record the full test page in batches to obtain attribute data in the page to be collected. Then, the switching data is intercepted and obtained through the interception interface in the full test page, and the user's switching data is combined with the attribute data to generate a DSL language test case, thereby automatically using a specific DSL language to generate test cases, reducing learning and writing maintenance costs. In addition, operators can directly review and modify the generated DSL application, improving the efficiency of test case management. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 A schematic diagram of a flow chart of a method for generating a test case according to an embodiment of the present invention;

[0054] Figure 2 A schematic diagram of modules of a test case generation device provided by an embodiment of the present invention;

[0055] Figure 3 A schematic diagram of the internal structure of an electronic device for implementing a method for generating test cases provided by an embodiment of the present invention;

[0056] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0057] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0058] The present invention provides a method for generating a test case. Figure 1 FIG. 1 is a flow chart of a method for generating a test case according to an embodiment of the present invention. The method can be executed by a device, which can be implemented by software and / or hardware.

[0059] In this embodiment, the method for generating a test case includes:

[0060] S1: Use a web plug-in to generate a recording component on the page to be collected;

[0061] The process of step S1 includes:

[0062] S11: Get web page plug-in;

[0063] S12: injecting a collection script into the page to be collected through the webpage plug-in; wherein the webpage plug-in can be any plug-in adapted to the browser supported by the webpage to be collected. In this embodiment, the webpage plug-in adopts a Chrome plug-in;

[0064] S13: Marking the matching interface information in the acquisition script to form a visual script;

[0065] S14: Edit the recording rules in the visual script to form a recording component; the recording rules are not specifically limited and can be determined based on the tendency during testing. In this embodiment, the recording rules are: set an interface key for the visual script; use the interface key to connect to the interface in the page to be collected; set a monitoring channel in the interface; and monitor data changes in the monitoring channel through the monitoring channel.

[0066] A visual script is a script that can realize the function of docking with any interface. In this embodiment, the page to be collected is a portal page or a video page. Taking the video page as an example, a plug-in that can adapt to the video page is first generated, and then the collection script is injected into the video web page through the plug-in. At this time, the collection script cannot automatically obtain valid information in the video web page. The user's click, change, sliding and other operations in the video web page usually rely on the interface to return data. For example, the user sends a "play" request to the video web page, and the interface in the video web page sends a request return value to the user end in response to the play request. Therefore, in order to collect the user's dynamic operations, it is first necessary to mark the collection script with matching interface information to form a visual script, so that the collection script can have "directionality" and enable it to visually dock with the interface in the video web page to achieve accurate information interception. The visual script can accurately intercept information, but cannot accurately filter valid information. Therefore, it is necessary to configure recording rules for the visual script to form a recording component so that it can obtain tendency information according to the test tendency when testing the page to be collected, thereby forming a test case that is more suitable for the page to be collected.

[0067] S2: Load the exclusion interface on the recording component to exclude the carousel data in the page to be collected, so that the page to be collected is converted into a full test page.

[0068] In step S2, the process of excluding the carousel data in the page to be collected and converting the page to be collected into a full test page includes:

[0069] S21: Reading dynamic data of each page in the pages to be collected;

[0070] S22: Analyze the dynamic data to determine whether the dynamic data is carousel data or passive data. The process of determining whether the dynamic data is carousel data or passive data includes:

[0071] S22-1: Writing a stealth program to enable the stealth program to obtain the source of the dynamic data;

[0072] S22-2: Analyze the source to determine whether the source is original code or element click; the click element is a data code converted by the user click;

[0073] S22-3: If it is original encoding, the dynamic data is carousel data; if it is element click, the dynamic data is passive data;

[0074] S23: If the dynamic data is carousel data, set a carousel key;

[0075] S24: Divide the carousel key into a public key and a private key, place the public key on the recording component, and place the private key on the carousel data;

[0076] S25: When the recording component records the page to be collected, if the public key on the recording component is paired with the public key on the carousel data, the recording component abandons the recording of the carousel data and excludes the carousel data to form a full test page; the carousel data is pre-set data that appears continuously on the page to be collected, such as the carousel announcement that is continuously played on the website, the carousel image that never changes, and the carousel video that is played in a loop.

[0077] In this embodiment, the video web page is still used as the page to be collected. In a complete website containing a limited number of video web pages, there must be a carousel or a carousel announcement that always exists. The carousel is mostly an advertisement for the video content contained in the video web page of the website, and the carousel announcement is mostly an announcement of the advertising space in the video web page or a note about the video website. However, the carousel and carousel announcement are unnecessary for website testing and web page testing. Therefore, when collecting test cases, there is no need to collect carousels and carousel announcements to increase the collection speed and reduce the space occupied by the collected data. The simple recording component does not have a filtering function, so an exclusion interface needs to be added to the recording component. The exclusion interface can be an interface in the actual sense or a rule program with an exclusion function. No specific limitation is made here. In this embodiment, the exclusion interface is a rule program, not an interface in the traditional sense.

[0078] Specifically, the dynamic data of all pages in the video webpage is first read, and the dynamic data includes the carousel data preset in the webpage, as well as the operation data of the user in the background of the video webpage and the data being operated by the administrator in the background of the video webpage. The above operation data is regarded as passive data; then the dynamic data read is analyzed and judged whether it is carousel data or passive data;

[0079] If it is determined that the dynamic data obtained from the video web page is carousel data, a carousel key is set. The carousel key can be a key pair or can simply mark the carousel data. In order to improve the accuracy of identifying carousel data, in this embodiment, the carousel key adopts a key pair, that is, the carousel key is divided into a public key and a private key. The public key is placed on the recording component, and the private key is placed on the carousel data. When the recording component records the page to be collected, the public key on the recording component is paired with the public key on the carousel data, and the recording component abandons the recording of the carousel data and excludes the carousel data. If the public key on the recording component fails to pair with the public key on the carousel data when the recording component records the page to be collected, the carousel data is treated as passive data. That is to say, if it is not certain whether to collect the dynamic data, choose to collect the dynamic data.

[0080] It should be noted that the above exclusion of the carousel data does not mean that the carousel data is excluded from the original page to be collected. Instead, from the perspective of the recording component, after it matches the private key of the carousel data, even if the data is collected again, the carousel data will not be included in the collection scope.

[0081] S3: Loading the recording switch on the recording component, recording the full test page in batches, and obtaining attribute data from the page to be collected;

[0082] In step S3, the recording switch on the recording component is loaded, and the process of recording the full test page in batches includes:

[0083] S31-1: Preset data threshold;

[0084] S31-2: Analyze the data values ​​of the single page or the page combination of the pages to be collected, and determine whether the data values ​​of the single page or the page combination exceed the data threshold;

[0085] S31-3: If the data value of the single page exceeds the data threshold, the single page is divided into two for collection; if the data value of the single page does not exceed the data threshold, the single page is directly collected; if the data value of the page combination is less than the data threshold, the page combination is directly collected at one time; if the data value of the page combination is greater than the data threshold, the page combination is divided into a limited number of single pages, and the limited number of single pages are collected in batches, one page at a time;

[0086] S31-4: After each acquisition is completed, the recording controller automatically turns off and stays for a preset time. The recording controller automatically turns on to start the next acquisition, so that the entire recording component can clearly distinguish each stage of the acquisition process during the data acquisition process, which is convenient for the classification and management of test cases in the later stage.

[0087] In this embodiment, still taking the video web page as an example, in a video website containing video web pages, the amount of data of each web page is different. In order to improve the data collection (recording) speed of the recording component, all the pages to be collected need to be collected in batches. The specific process is as described above and will not be repeated here.

[0088] In step S3, the process of obtaining the attribute data in the page to be collected includes:

[0089] S32-1: Initialize the page to be collected;

[0090] S32-2: Collect general information of the browser where the page to be collected is located; the general information includes at least the length and width of the browser;

[0091] S32-3: Locking the collection range of the pages to be collected according to the general information;

[0092] S32-4: Bind the user of the page to be collected, obtain the cursor operation data generated by the user within the collection range, and obtain the click element of the user.

[0093] S4: combining the user's switching data with the attribute data to generate a DSL language test case; wherein the switching data is intercepted and obtained through the interception interface in the full test page;

[0094] In step S4, the process of obtaining the switching data through the interception interface in the full test page includes:

[0095] S41: The user of the page to be collected sends a command request to the full test page;

[0096] S42: The data interface in the full test page receives and processes the command request to form a return value;

[0097] S43: establishing an interception interface between the data interface and the full test page, and enabling the interception interface to obtain the command request and the return value;

[0098] S44: Analyze the command request and return value to obtain node changes of the full test page;

[0099] S45: Convert the node change into switching data, and combine the switching data with the attribute data to generate a DSL language test case. The process of combining the switching data with the attribute data to generate a DSL language test case includes:

[0100] S45-1: Read the user's click element;

[0101] S45-2: Get the user's dynamic process based on the user's click element;

[0102] S45-3: Use DSL language to correspond the dynamic process to the switching data to generate DSL language test cases.

[0103] As described above, the test case generation method provided by the present invention first uses a web page plug-in to generate a recording component in the page to be collected, then loads the exclusion interface on the recording component to exclude the carousel data in the page to be collected, so that the page to be collected is converted into a full test page, and then loads the recording switch on the recording component to record the full test page in batches to obtain the attribute data in the page to be collected. Then, the switching data is intercepted and obtained through the interception interface in the full test page, and the user's switching data is combined with the attribute data to generate a DSL language test case, thereby automatically using a specific DSL language to generate test cases, reducing learning and writing maintenance costs, and operators can directly review and modify the generated DSL language, thereby improving the convenience of test case management.

[0104] like Figure 2 As shown, the present invention provides a test case generation device 100, which can be installed in an electronic device. Depending on the functions implemented, the test case generation device 100 may include a component generation unit 101, a carousel data exclusion unit 102, a page recording unit 103, and a test case generation unit 104. The module described in the present invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can perform fixed functions, and is stored in the memory of the electronic device.

[0105] In this embodiment, the functions of each module / unit are as follows:

[0106] The component generation unit 101 is used to generate a recording component in the page to be collected using a web page plug-in;

[0107] The carousel data exclusion unit 102 is used to load the exclusion interface on the recording component to exclude the carousel data in the page to be collected, so that the page to be collected is converted into a full test page;

[0108] The page recording unit 103 is used to load the recording switch on the recording component, record the entire test page in batches, and obtain the attribute data of the page to be collected;

[0109] The test case generating unit 104 is configured to combine the user's switching data with the attribute data to generate a DSL language test case; wherein the switching data is intercepted and obtained through the interception interface in the full test page.

[0110] like Figure 3As shown, the present invention provides an electronic device 1 capable of implementing a test case generation method.

[0111] The electronic device 1 may include a processor 10 , a memory 11 , and a bus, and may further include a computer program stored in the memory 11 and executable on the processor 10 , such as a test case generation program 12 .

[0112] Wherein, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 11 can also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Furthermore, the memory 11 can also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device 1, such as the code of the test case generation program, etc., but can also be used to temporarily store data that has been output or is to be output.

[0113] In some embodiments, the processor 10 may be composed of an integrated circuit, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The processor 10 is the control core (Control Unit) of the electronic device, connecting the various components of the entire electronic device using various interfaces and lines, and executing programs or modules stored in the memory 11 (such as a test case generation program, etc.) and calling data stored in the memory 11 to perform various functions of the electronic device 1 and process data.

[0114] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable connection and communication between the memory 11 and at least one processor 10, etc.

[0115] Figure 3 Only the electronic device with components is shown, and it can be understood by those skilled in the art that Figure 3 The structure shown does not constitute a limitation on the electronic device 1 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0116] For example, although not shown, the electronic device 1 may further include a power source (such as a battery) for powering the various components. Preferably, the power source may be logically connected to the at least one processor 10 via a power management device, thereby implementing functions such as charging management, discharging management, and power consumption management through the power management device. The power source may further include any components such as one or more DC or AC power sources, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, etc. The electronic device 1 may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0117] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.

[0118] Optionally, the electronic device 1 may further include a user interface, which may be a display or an input unit (such as a keyboard). Optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.

[0119] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0120] The test case generation program 12 stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When executed in the processor 10, it can achieve the following:

[0121] Use web page plug-ins to generate recording components in the page to be collected;

[0122] Load the exclusion interface on the recording component to exclude the carousel data on the page to be collected, so that the page to be collected is converted into a full test page;

[0123] Load the recording switch on the recording component, record all test pages in batches, and obtain the attribute data of the pages to be collected;

[0124] The user's switching data and attribute data are combined to generate a DSL language test case; wherein the switching data is intercepted and obtained through the interception interface in the full test page.

[0125] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiment is not repeated here. It should be emphasized that in order to further ensure the privacy and security of the generation of the above test cases, the generation data of the above test cases is stored in the node of the blockchain where this server cluster is located.

[0126] Furthermore, if the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).

[0127] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical function division, and other division methods may be used in actual implementation.

[0128] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.

[0129] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional modules.

[0130] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0131] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.

[0132] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0133] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. Second-order terms are used to indicate names and do not imply any particular order.

[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for generating a test case, characterized in that: include: Use web page plug-ins to generate recording components in the page to be collected; Load the exclusion interface on the recording component, exclude the carousel data in the page to be collected, and convert the page to be collected into a full test page; wherein, the process of excluding the carousel data in the page to be collected and converting the page to be collected into a full test page includes: reading the dynamic data of each page in the page to be collected; analyzing the dynamic data, and judging whether the dynamic data is carousel data or passive data; if the dynamic data is carousel data, setting a carousel key; dividing the carousel key into a public key and a private key, placing the public key on the recording component, and placing the private key on the carousel data; when the recording component records the page to be collected, if the public key on the recording component is paired with the public key on the carousel data, the recording component abandons the recording of the carousel data, and excludes the carousel data to form a full test page; wherein, The process of determining whether the dynamic data is carousel data or passive data includes: writing a stealth program to enable the stealth program to obtain the source of the dynamic data; analyzing the source to determine whether the source is original code or element click; if the source is original code, the dynamic data is carousel data; if the source is element click, the dynamic data is passive data; Loading the recording switch on the recording component, recording the full test page in batches, and obtaining attribute data from the page to be collected; The user's switching data is combined with the attribute data to generate a DSL language test case; wherein, the switching data is intercepted and obtained through the interception interface in the full test page.

2. The test case generation method according to claim 1, wherein: The process of using a web plug-in to generate a recording component on the page to be collected includes: Get the web plug-in; Injecting a collection script into the page to be collected through the web page plug-in; Marking the matching interface information in the acquisition script to form a visual script; Editing recording rules in the visual script forms a recording component.

3. The test case generation method according to claim 2, wherein: The process of loading the recording switch on the recording component and recording the full test page in batches includes: Preset data thresholds; Analyze the data values ​​of the single pages and page combinations of the pages to be collected, and determine whether the data values ​​of the single pages and page combinations exceed the data threshold; If the data value of the single page exceeds the data threshold, the single page is divided into two for collection; If the data value of the single page does not exceed the data threshold, directly collect the single page; If the data value of the page combination is less than the data threshold, directly performing a one-time collection on the page combination; If the data value of the page combination is greater than the data threshold, the page combination is divided into a limited number of single pages, and the limited number of single pages are collected in batches, one page at a time; Each time a collection is completed, the recording controller is automatically closed and stays for a preset time, and then the recording controller is automatically opened to start the next collection.

4. The test case generation method according to claim 3, wherein: The process of obtaining the attribute data from the page to be collected includes: Initialize the page to be collected; Collecting general information of the browser where the page to be collected is located; the general information at least includes the length and width of the browser; Locking the collection range of the pages to be collected according to the general information; The user of the page to be collected is bound, and the cursor operation data generated by the user within the collection range is obtained to obtain the click element of the user.

5. The test case generation method according to claim 1, wherein: The process of combining the user's switching data with the attribute data to generate a DSL language test case includes: The user of the page to be collected sends a command request to the full test page; The data interface in the full test page receives and processes the command request to form a return value; An interception interface is opened between the data interface and the full test page, and the interception interface is enabled so that the interception interface obtains the command request and the return value; Analyzing the command request and the return value to obtain node changes of the full test page; The node changes are converted into switching data, and the switching data is combined with the attribute data to generate a DSL language test case.

6. A test case generation device, characterized in that: The device comprises: A component generation unit, configured to generate a recording component in the page to be collected using a web page plug-in; A carousel data exclusion unit is used to load the exclusion interface on the recording component, exclude the carousel data in the page to be collected, and convert the page to be collected into a full test page; wherein, the process of excluding the carousel data in the page to be collected and converting the page to be collected into a full test page includes: reading the dynamic data of each page in the page to be collected; analyzing the dynamic data to determine whether the dynamic data is carousel data or passive data; if the dynamic data is carousel data, setting a carousel key; dividing the carousel key into a public key and a private key, placing the public key on the recording component, and placing the private key on the carousel data; when the recording component records the page to be collected, if the public key on the recording component is paired with the public key on the carousel data, the recording component abandons the recording of the carousel data and excludes the carousel data to form a full test page; wherein, The process of determining whether the dynamic data is carousel data or passive data includes: writing a stealth program to enable the stealth program to obtain the source of the dynamic data; analyzing the source to determine whether the source is original code or element click; if the source is original code, the dynamic data is carousel data; if the source is element click, the dynamic data is passive data; A page recording unit, configured to load a recording switch on the recording component, record the full test page in batches, and obtain attribute data from the page to be collected; The test case generating unit is used to combine the user's switching data with the attribute data to generate a DSL language test case; wherein, the switching data is intercepted and obtained through the interception interface in the full test page.

7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the test case generation method according to any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the test case generation method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Interface automatic test method and device, storage medium and electronic equipment

    CN111190827A