Method, device, electronic device and storage medium for generating test cases

By injecting collection scripts and generating acquisition threads into the page to be tested, collecting user operation data in real time and generating test cases, the problems of high cost of writing and maintenance of test cases and poor adaptability in the existing technology are solved, and efficient and accurate testing is achieved Use case generation.

CN112527664BActive Publication Date: 2025-02-18CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, the writing and maintenance of test cases is high, and the adaptability is poor, making it difficult to quickly respond to product iteration needs.

Method used

Inject the collection script into the page to be tested, generate the acquisition thread, and set a unique identifier for each page process, listen to user operations in real time, collect click elements and change events, generate user data packets, and form test cases.

Benefits of technology

It reduces the cost of writing and maintenance of test cases, improves the adaptability and accuracy of use cases, and eliminates test omissions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112527664B_ABST
    Figure CN112527664B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of system function testing, and provides a method for generating test cases. First, bullet symbols are marked on a page to be tested according to a preset marking rule to form a project page, and a collection script is injected into the project page, a collection thread is generated based on the collection script, and a unique identifier is set for each page process in the project page, and a user data packet is generated by collecting click elements and change events through the collection thread, so as to obtain all click information of the user, and then element positioning information and change attributes are injected into the user data packet to form a test case, and the unique identifier corresponding to the user operation page and the bullet symbol of the project page to which it belongs are marked on the test case to form a test case, and then the tester can obtain the test case of the corresponding language according to the formed test case, or the system can generate a standard test case according to the formed test case, thereby greatly reducing the maintenance and writing costs of the test case and eliminating the situation of test omissions.
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 function testing, and in particular to a method, device, electronic device and computer-readable storage medium for generating test cases. Background Art

[0002] Testing is an indispensable and important part in product development iteration, among which functional testing is the most important part. 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 iteration of test cases often require a lot of manpower, especially in the Internet industry where iterations are particularly frequent. This is also the largest amount of human participation in automated testing. So if test cases can be automatically generated and then modified by testers or even used directly, this will undoubtedly make testing move one step further in the direction of automation.

[0004] Therefore, there is an urgent need for a method for generating test cases that reduces the cost of writing and maintaining use cases and improves the adaptability of web use cases. Summary of the invention

[0005] The present invention provides a method, device, electronic device and computer-readable storage medium for generating test cases, the main purpose of which is to inject a collection script of a different thread from the page operation into the page to be tested, generate a unique identifier in each operation page, bind the page user, and monitor the elements and element changes of each user in real time to collect test cases on the page, eliminate test omissions, and reduce the cost of case collection and maintenance.

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

[0007] Marking bullet points on the page to be tested according to preset marking rules to form a project page, and injecting a collection script into the project page;

[0008] Generate a collection thread based on the collection script, and set a unique identifier for each page flow in the project page;

[0009] Bind the user identity of the project page, collect the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generate a user data packet with the click elements and change events;

[0010] The element location information of the click element and the change attribute of the change event are obtained for the user data packet, and the element location information and the change attribute are injected into the user data packet to form a use case. The unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs are marked on the use case to form a test case.

[0011] Optionally, the process of marking bullet points on the page to be tested according to a preset marking rule to form a project page, and injecting a collection script into the project page includes:

[0012] Determine, according to the page to be tested, bullet points related to the page to be tested;

[0013] Mark the bullet symbol on the page to be tested to form a project page;

[0014] Injecting collection symbols corresponding to the bullet symbols one by one into the pre-created script to form a collection script, and injecting the collection script into the project page according to the correspondence between the collection symbols and the bullet symbols;

[0015] The collection script reads each page contained in the project page and determines whether each page corresponds one-to-one with the project symbol. If so, the collection preparation is completed. If not, the collection script issues an error prompt to re-inject the collection symbol.

[0016] Optionally, the process of generating a collection thread based on the collection script and setting a unique identifier for each page flow in the project page includes:

[0017] Setting a time threshold for the collection script to form a collection program;

[0018] Setting a collection target for the collection program so that the collection program collects information from the collection target regularly according to the time threshold;

[0019] A unique identifier is set for each page flow in the project page, and the unique identifier is input into the acquisition target.

[0020] Optionally, the process of binding the user identity of the project page, collecting click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generating a user data packet from the click elements and change events includes:

[0021] Find the registration information of the user of the project page, obtain the authorization of the user, and bind the user to the collection thread;

[0022] The acquisition thread obtains the initialization data of the project page and binds the cursor operation of the user again;

[0023] Acquire the user's click and input events by reading the user's cursor operation, and send the click and input events as click elements to the message queue of the acquisition thread;

[0024] Parsing the click element to obtain the user's change event and dynamic process;

[0025] The click elements, change events and dynamic processes are integrated into a user data packet, a timestamp is added to the user data packet, and the user data packet with the timestamp is sent to the message queue.

[0026] Optionally, the change events and dynamic processes include at least: adding new nodes, deleting nodes, changing attributes, changing node content, and changing node text.

[0027] Optionally, the process of obtaining the element location information of the click element and the change attribute of the change event for the user data packet, injecting the element location information and the change attribute into the user data packet to form a test case, and marking the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the test case to form a test case includes:

[0028] Presetting the location information of the click element in the project page; the location information is the ID of each click element;

[0029] Reading the user data packet in the message queue, and searching for the location information of the click element in the project page according to the data in the user data packet;

[0030] Obtaining a change attribute of the change event based on the location information of the clicked element;

[0031] Inputting the location information of the click element and the change attribute of the change event into the data packet to form a use case, and transmitting the use case to the message queue of the acquisition thread;

[0032] A unique identifier corresponding to the user operation page and a bullet point of the corresponding project page are marked on the use case to form a test case, and the test case is uploaded to the use case collection platform.

[0033] Optionally, after marking the unique identifier corresponding to the user operation page and the bullet point of the project page to form the test case, the test case is further screened and sorted. The process of screening and sorting the test case includes:

[0034] The use case collection platform filters out all change events in the page flow corresponding to the unique identifier in the project page according to the unique identifier and the bullet symbol, and sorts them by time according to the timestamp;

[0035] Aggregate the test cases under different bullet points within the same timestamp to form a single project test case;

[0036] Under the same bullet point, test cases with different unique identifiers are divided into single pages to form single-project single-page test cases.

[0037] In order to solve the above problem, the present invention also provides a device for generating a test case, the device comprising:

[0038] The project marking unit is used to mark the project symbols on the page to be tested according to the preset marking rules to form a project page, and inject the collection script into the project page;

[0039] A thread generation unit, used to generate a collection thread based on the collection script, and set a unique identifier for each page flow in the project page;

[0040] A data collection unit, used for binding the user identity of the project page, collecting click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generating a user data packet from the click elements and change events;

[0041] A use case forming unit is used to obtain the element positioning information of the click element and the change attribute of the change event for the user data packet, inject the element positioning information and the change attribute into the user data packet to form a use case, and mark the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the use case to form a test case.

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

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

[0044] The processor executes the instructions stored in the memory to implement the steps in the method for generating test cases described above.

[0045] 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 above-mentioned method for generating test cases.

[0046] The embodiment of the present invention first marks bullet points on the page to be tested according to a preset marking rule to form a project page, and injects a collection script into the project page, generates a collection thread based on the collection script, and sets a unique identifier for each page process in the project page, and then binds the user identity of the project page, collects the click elements and change events corresponding to the user identity during the user operation of the project page through the collection thread, and generates a user data packet for the click elements and change events, thereby obtaining all the user's click information, thereby obtaining the element positioning information of the click element and the change attribute of the change event for the user data packet, and then injecting the element positioning information and the change attribute into the user data packet to form a use case, and marking the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the use case to form a test case, so that the tester can obtain the test case of the corresponding language according to the formed test case, or the system generates a standard test case according to the formed test case, and then the work of the tester changes from writing and maintenance to only maintaining some required test cases from the test case library, which greatly reduces the maintenance and writing costs of the test case and eliminates the situation of test omissions. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A flowchart of a method for generating a test case provided by an embodiment of the present invention;

[0048] Figure 2 A schematic diagram of a module of a device for generating a test case provided by an embodiment of the present invention;

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

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

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

[0052] 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 provided by an embodiment of the present invention. The method can be executed by a device, and the device can be implemented by software and / or hardware.

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

[0054] S1: Mark the bullet points on the page to be tested according to the preset marking rules to form a project page, and inject the collection script into the project page;

[0055] In a specific embodiment of the present invention, the process of step S1 may include:

[0056] S11: determining a bullet point related to the page to be tested according to the page to be tested; marking the bullet point on the page to be tested to form a bullet point page;

[0057] S12: Injecting collection symbols corresponding to the bullet symbols one by one into the pre-created script to form a collection script, and injecting the collection script into the project page according to the correspondence between the collection symbols and the bullet symbols;

[0058] S13: The collection script reads each page contained in the project page and determines whether each page corresponds to the project symbol one-to-one. If so, the collection preparation is completed. If not, the collection script issues an error prompt to re-inject the collection symbol.

[0059] Specifically, in the present embodiment, the page to be tested adopts a sales webpage. When collecting test cases of the sales webpage, bullet points are first marked on the sales webpage according to preset marking rules. The bullet point can be the webpage name when the sales webpage is created, or the website name when the sales website is created, or even the group project name. Of course, it can also be a brand new test name specifically for testing, which can be set according to the actual needs of the test.

[0060] In this embodiment, the bullet symbol of the sales webpage is named for a new test. More specifically, the bullet symbol of the sales webpage is "S web" to ensure that the test cases in the sales project can be found quickly and accurately during the later test case maintenance. Then, a script capable of collecting test cases in the sales webpage is created. The script includes a feature collection module corresponding to the sales webpage, and a test data container consistent with the test tendency of the sales webpage is preset according to the test requirements. For example, when clicking on the add-to-cart and payment in the sales webpage, the speed and element changes during the period are the tendency test points, and the test data container of the element is set to the maximum.

[0061] Inject collection symbols corresponding to the bullet symbols one by one into the created script to form a collection script, and inject the collection script into the project page according to the collection symbol. The collection symbol can be the same as the bullet symbol, or it can be named according to the overall ranking of the collection scripts in the database. In other words, the collection symbol is the name of the collection script. Each set of project pages corresponds to a collection script, so each bullet symbol corresponds to a collection symbol, so as to facilitate the test case management in the later stage; then the collection script reads each page contained in the project page, and determines whether each page corresponds to the bullet symbol one by one. In this embodiment, the sales webpage is in the sales website, and the sales website may need to be tested, but the test tendencies of each sales page are not exactly the same. Therefore, in order to prevent script errors, it is necessary to determine whether the sales page injected with the script is the page that really needs to collect test cases. If it corresponds one by one, the collection preparation is completed, and only the next step of collection is required. If it does not correspond one by one, the collection script issues an error prompt to return to injecting the collection symbol. Although this situation is generally not easy to occur, after this judgment process, the case collection can be completed more accurately, thereby generating a test case with a tendency, thereby improving the accuracy and adaptability of the test case.

[0062] S2: Generate a collection thread based on the collection script and set a unique identifier for each page process in the project page.

[0063] In step S2, the process of generating a collection thread based on the collection script and setting a unique identifier for each page flow in the project page includes:

[0064] S21: Setting a time threshold for the collection script to form a collection program;

[0065] S22: Setting a collection target for the collection program so that the collection program collects information from the collection target regularly according to a time threshold;

[0066] S23: setting a unique identifier for each page flow in the project page, and inputting the unique identifier into the collection target;

[0067] In this embodiment, it also includes S24: the collection program accesses each page in the project page to find out whether there is a unique identifier for each page. If not, a new unique identifier is created for the page. If so, it is determined whether the unique identifier of each page is in the list of the collection target. If so, a collection thread is generated. If not, the unique identifier of the page is returned to prevent collection omissions.

[0068] The unique identifier is a randomly generated non-repeating character string, which is recorded as uuid in this embodiment. The generated unique identifier is placed in the uniform resource locator (url) of the page.

[0069] It should be noted that the collection thread is another thread in the web page that is different from the operation page. The two threads are parallel and do not interfere with each other. Taking the sales web page as an example, the thread for collecting test cases for the sales web page and the thread for selling the sales web page are parallel and do not interfere with each other.

[0070] S3: Bind the user identity of the project page, collect the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generate a user data packet from the click elements and change events;

[0071] The process of step S3 includes:

[0072] S31: Find the user's registration information on the project page, obtain the user's authorization, and bind the user to the collection thread;

[0073] S32: Initialize the project page first, the collection thread obtains the initialization data of the project page, and binds the user's cursor operation again;

[0074] S33: Obtain the user's click and input events by reading the user's cursor operation, and send the click and input events as click elements to the message queue of the acquisition thread;

[0075] S34: Analyze the clicked element to obtain the user's change event and dynamic process; wherein the change event and dynamic process at least include: adding a node, deleting a node, changing attributes, node content, and node text changes.

[0076] S35: Integrate the click elements, change events and dynamic processes into a user data packet, add a timestamp to the user data packet, and send the user data packet with the timestamp to the message queue.

[0077] In this embodiment, the sales webpage is still used as the page to be tested. The collection thread first obtains the registration information of all users in the sales webpage, and obtains the user's authorization based on the registration information. The user's consent should be taken as a prerequisite, and the collection thread is used to monitor the user to obtain the elements clicked by the user and the change events. The elements are the options on the sales webpage, such as the "add to cart", "buy", and "browse" keys. The change event is the state, or a dynamic state, such as the state of switching from add to cart to purchase, and the state of switching from browse to purchase. All elements involved in the change event belong to the scope of collection by the collection thread. The specific process is as described above and will not be repeated here.

[0078] S4: obtaining the element location information of the clicked element and the change attribute of the change event for the user data packet, injecting the element location information and the change attribute into the user data packet to form a test case, and marking the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the test case to form a test case;

[0079] The process of step S4 includes:

[0080] S41: Preset the location information of the click element in the project page; the location information is the ID of each click element;

[0081] S42: reading the user data packet in the message queue, and searching for the location information of the clicked element in the project page according to the data in the user data packet;

[0082] S43: obtaining the change attribute of the change event based on the location information of the clicked element;

[0083] S44: inputting the location information of the clicked element and the changed attributes of the change event into a data packet to form a use case, and transmitting the use case to a message queue of the acquisition thread;

[0084] S45: Mark the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the use case to form a test case, and upload the test case to the use case collection platform.

[0085] After marking the unique identifier corresponding to the user operation page and the bullet point of the project page to form the test case, the test case is screened and sorted S51. The process of screening and sorting the test case S51 includes:

[0086] S51-1: The use case collection platform selects all change events in the page flow corresponding to the unique identifier in the project page according to the unique identifier and the bullet symbol, and sorts them by time stamp;

[0087] S51-2: Aggregate the test cases under different bullet points within the same timestamp to form a single-project test case;

[0088] S51-3: Divide the test cases with different unique identifiers under the same bullet symbol into single pages to form single-project single-page test cases.

[0089] In this embodiment, after the test cases are screened and organized, the application S52 of the test cases is also included. Since the user may not complete a complete process, the tester is required to actively screen out a set of available test cases. The screening process can be achieved by the tester through the screening function provided by the platform.

[0090] As described above, the method for generating test cases provided by the present invention first marks bullet points on the page to be tested according to preset marking rules to form a project page, and injects a collection script into the project page, generates a collection thread based on the collection script, and sets a unique identifier for each page process in the project page, and then binds the user identity of the project page, collects the click elements and change events corresponding to the user identity during the user operation of the project page through the collection thread, and generates a user data packet for the click elements and change events, thereby obtaining all the user's click information, thereby obtaining the element positioning information of the click element and the change attribute of the change event for the user data packet, and then injects the element positioning information and the change attribute into the user data packet to form a use case, and marks the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the use case to form a test case, so that the tester can obtain the test case of the corresponding language according to the formed test case, or the system generates a standard test case according to the formed test case, and then the work of the tester changes from writing and maintenance to only maintaining some required test cases from the test case library, which greatly reduces the maintenance and writing costs of the test case and eliminates the situation of test omissions.

[0091] like Figure 2 As shown, the present invention provides a device 100 for generating test cases, which can be installed in an electronic device. According to the functions implemented, the device 100 for generating test cases can include a project annotation unit 101, a thread generation unit 102, a data acquisition unit 103, and a use case formation 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 complete fixed functions, which are stored in the memory of the electronic device.

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

[0093] The project marking unit 101 is used to mark the project symbols on the page to be tested according to the preset marking rules to form a project page, and inject the collection script into the project page;

[0094] The thread generation unit 102 is used to generate a collection thread based on the collection script and set a unique identifier for each page flow in the project page;

[0095] The data collection unit 103 is used to bind the user identity of the project page, collect the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generate a user data packet from the click elements and change events;

[0096] The use case forming unit 104 is used to obtain the element location information of the clicked element and the change attributes of the change event for the user data packet, inject the element location information and the change attributes into the user data packet to form a use case, and mark the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the use case to form a test case.

[0097] like Figure 3 As shown, the present invention provides an electronic device 1 for a method of generating a test case.

[0098] The electronic device 1 may include a processor 10, a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a program 12 for generating test cases.

[0099] 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 (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may 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 program for generating test cases, etc., but may also be used to temporarily store data that has been output or is to be output.

[0100] The processor 10 may be composed of an integrated circuit in some embodiments, for example, 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 combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as programs for generating test cases, etc.) stored in the memory 11, and calls data stored in the memory 11 to execute various functions of the electronic device 1 and process data.

[0101] 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 realize connection and communication between the memory 11 and at least one processor 10, etc.

[0102] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand 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.

[0103] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0104] 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.

[0105] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or 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, and 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.

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

[0107] The program 12 for generating test cases stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, the following can be achieved:

[0108] On the page to be tested, mark the bullet points according to the preset marking rules to form a project page, and inject the collection script into the project page;

[0109] Generate a collection thread based on the collection script and set a unique identifier for each page process in the project page;

[0110] Bind the user identity of the project page, collect the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generate user data packets from the click elements and change events;

[0111] The element location information of the clicked element and the change attributes of the change event are obtained from the user data packet, and the element location information and the change attributes are injected into the user data packet to form a use case. The unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs are marked on the use case to form a test case.

[0112] 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 above-mentioned generated test cases, the data of the above-mentioned generated test cases are stored in the node of the blockchain where the server cluster is located.

[0113] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it 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 disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0114] 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 only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

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

[0116] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

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

[0118] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0119] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0120] In addition, 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 stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.

[0121] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. 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 solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A method for generating a test case, characterized in that: include: The process of marking bullet points on the page to be tested according to preset marking rules to form a project page, and injecting a collection script into the project page; wherein the process of marking bullet points on the page to be tested according to preset marking rules to form a project page, and injecting a collection script into the project page, includes: Determine, according to the page to be tested, bullet points related to the page to be tested; Mark the bullet symbol on the page to be tested to form a project page; Injecting collection symbols corresponding to the bullet symbols one by one into the pre-created script to form a collection script, and injecting the collection script into the project page according to the correspondence between the collection symbols and the bullet symbols; The collection script reads each page contained in the project page and determines whether each page corresponds to the project symbol one-to-one. If so, the collection preparation is completed. If not, the collection script issues an error prompt to re-inject the collection symbol. Generate a collection thread based on the collection script, and set a unique identifier for each page flow in the project page; Binding the user identity of the project page, collecting the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generating a user data packet from the click elements and change events; wherein the process of binding the user identity of the project page, collecting the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generating a user data packet from the click elements and change events includes: Find the registration information of the user of the project page, obtain the authorization of the user, and bind the user to the collection thread; The acquisition thread obtains the initialization data of the project page and binds the cursor operation of the user again; Acquire the user's click and input events by reading the user's cursor operation, and send the click and input events as click elements to the message queue of the acquisition thread; Parsing the click element to obtain the user's change event and dynamic process; Integrate the click elements, change events and dynamic processes into a user data packet, add a timestamp to the user data packet, and send the user data packet with the timestamp to the message queue; The element location information of the click element and the change attribute of the change event are obtained for the user data packet, and the element location information and the change attribute are injected into the user data packet to form a use case, and the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs are marked on the use case to form a test case.

2. The method for generating a test case according to claim 1, wherein: The process of generating a collection thread based on the collection script and setting a unique identifier for each page flow in the project page includes: Setting a time threshold for the collection script to form a collection program; Setting a collection target for the collection program so that the collection program collects information from the collection target regularly according to the time threshold; A unique identifier is set for each page flow in the project page, and the unique identifier is input into the acquisition target.

3. The method for generating a test case according to claim 1, wherein: The change events and dynamic processes include at least: adding new nodes, deleting nodes, changing attributes, changing node content, and changing node text.

4. The method for generating a test case according to claim 3, wherein: The process of obtaining the element location information of the click element and the change attribute of the change event for the user data packet, injecting the element location information and the change attribute into the user data packet to form a test case, and marking the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the test case to form a test case includes: Presetting the location information of the click element in the project page; the location information is the ID of each click element; Reading the user data packet in the message queue, and searching for the location information of the click element in the project page according to the data in the user data packet; Obtaining a change attribute of the change event based on the location information of the clicked element; Inputting the location information of the click element and the change attribute of the change event into the data packet to form a use case, and transmitting the use case to the message queue of the acquisition thread; A unique identifier corresponding to the user operation page and a bullet point of the corresponding project page are marked on the use case to form a test case, and the test case is uploaded to the use case collection platform.

5. The method for generating a test case according to claim 4, characterized in that: After marking the unique identifier corresponding to the user operation page and the bullet point of the project page to form the test case, the test case is screened and sorted. The process of screening and sorting the test case includes: The use case collection platform filters out all change events in the page flow corresponding to the unique identifier in the project page according to the unique identifier and the bullet symbol, and sorts them by time according to the timestamp; Aggregate the test cases under different bullet points within the same timestamp to form a single project test case; Under the same bullet point, test cases with different unique identifiers are divided into single pages to form single-project single-page test cases.

6. A device for generating test cases, characterized in that: The device comprises: The project marking unit is used to mark bullets on the page to be tested according to preset marking rules to form a project page, and inject a collection script into the project page; wherein the process of marking bullets on the page to be tested according to preset marking rules to form a project page, and injecting a collection script into the project page, includes: Determine, according to the page to be tested, bullet points related to the page to be tested; Mark the bullet symbol on the page to be tested to form a project page; Injecting collection symbols corresponding to the bullet symbols one by one into the pre-created script to form a collection script, and injecting the collection script into the project page according to the correspondence between the collection symbols and the bullet symbols; The collection script reads each page contained in the project page and determines whether each page corresponds to the project symbol one-to-one. If so, the collection preparation is completed. If not, the collection script issues an error prompt to re-inject the collection symbol. A thread generation unit, used to generate a collection thread based on the collection script, and set a unique identifier for each page flow in the project page; The data collection unit is used to bind the user identity of the project page, collect the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generate a user data packet from the click elements and change events; wherein the process of binding the user identity of the project page, collecting the click elements and change events corresponding to the user identity during the user's operation of the project page through the collection thread, and generating a user data packet from the click elements and change events includes: Find the registration information of the user of the project page, obtain the authorization of the user, and bind the user to the collection thread; The acquisition thread obtains the initialization data of the project page and binds the cursor operation of the user again; Acquire the user's click and input events by reading the user's cursor operation, and send the click and input events as click elements to the message queue of the acquisition thread; Parsing the click element to obtain the user's change event and dynamic process; Integrate the click elements, change events and dynamic processes into a user data packet, add a timestamp to the user data packet, and send the user data packet with the timestamp to the message queue; A use case forming unit is used to obtain the element positioning information of the click element and the change attribute of the change event for the user data packet, inject the element positioning information and the change attribute into the user data packet to form a use case, and mark the unique identifier corresponding to the user operation page and the bullet point of the project page to which it belongs on the use case to form a test case.

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 method for generating a test case as described in 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 method for generating a test case as claimed in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Method and device for synchronization of test case and test script

    CN103106138A

  • Method and system for automatically generating a plurality of test cases for an it enabled application

    US20170192882A1