Test coverage calculation method and related device
By calculating the test coverage of functional modules, determining untested operation paths and adding test cases, the problem of insufficient test coverage of functional modules is solved, and full testing and stability of functional modules are achieved.
Patent Information
- Application Number
- CN202410777057.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-13
AI Technical Summary
In the application, the test coverage calculation of the functional module cannot fully cover all operation paths, resulting in the possibility that there are untested operation paths that cannot jump to the user interface of the functional module normally, affecting the comprehensiveness and accuracy of the test.
By obtaining multiple operation paths, calculate the number of occurrences and importance base of the target function identification, find the target test cases, and increase the number of tests of the operation path according to the test path, and calculate the test coverage of the functional module to determine the test cases that need to be added. .
It has realized full testing of functional modules, ensuring that all operation paths are covered by testing, improving the comprehensiveness and accuracy of testing, and ensuring the stability and reliability of functional modules.
Smart Images

Figure CN118642958A
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a test coverage calculation method and related devices. Background Art
[0002] If a functional module is updated or added to the application, the functional module needs to be tested in order to find vulnerabilities and fix them in time. One of the tests for the functional module is to test whether the operation path that jumps to the user interface corresponding to the functional module can jump normally. It is understandable that during the testing process, there may be a lot of operation paths corresponding to the functional module. If an operation path is not tested, there may be a problem that the untested operation path cannot jump to the user interface corresponding to the functional module.
[0003] Based on this, there is an urgent need for a method to calculate the test coverage of functional modules, so as to determine the operation paths that have not been tested or the number of tests does not meet the requirements through test coverage, so as to add test cases for the operation paths and achieve the purpose of full testing of functional modules. Summary of the invention
[0004] In view of the above problems, the present application provides a test coverage calculation method and related devices to realize the calculation of the test coverage of the functional module, so as to determine the operation path that has not been tested or the number of tests does not meet the requirements through the test coverage, so as to add test cases for the operation path and realize the purpose of full testing of the functional module. The specific scheme is as follows:
[0005] The first aspect of the present application provides a test coverage calculation method, comprising:
[0006] Acquire multiple operation paths, the operation paths including multiple operation objects sorted in time from earliest to latest, the operation objects including a user interface identifier, an operation position for a user interface having the user interface identifier, and an operation content for the operation position, and for each of the operation paths, an absolute value of a difference between a time corresponding to the operation object at a first position of the operation path and a time corresponding to the operation object at a last position of the operation path is less than or equal to a first preset duration;
[0007] Finding target function identifiers corresponding to the plurality of operation objects respectively from the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier located on the user interface;
[0008] Obtaining the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths, so as to obtain the number of occurrences corresponding to the multiple target function identifiers respectively;
[0009] For each of the target function identifiers, based on the number of occurrences corresponding to the target function identifier, calculate the importance cardinality corresponding to the target function identifier;
[0010] From the preset correspondence between function identifiers and test cases, searching for target test cases corresponding to the target function identifiers;
[0011] For each of the target test cases corresponding to each of the target function identifiers, obtaining a test path for the target test case;
[0012] For each of the operation paths, if the test path includes the operation path, increase the test times of the operation path to obtain the test times corresponding to the multiple operation paths respectively;
[0013] For each of the target function identifiers, the test coverage of the target function identifier is calculated based on the importance cardinality corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier.
[0014] In a possible implementation, obtaining multiple operation paths includes:
[0015] Acquire multiple operation sets, the operation sets including: a first user interface identifier, a first initial display time of a first user interface having the first user interface identifier, an operation position for the first user interface, an operation time of the operation position, an operation content at the operation position, a second initial display time of jumping from the first user interface to a second user interface, and a second user interface identifier of the second user interface;
[0016] Obtain multiple candidate operation paths;
[0017] Wherein, the candidate operation path includes one or more operation sets. When the candidate operation path includes multiple operation sets, the multiple operation sets are sorted from early to late in time, and the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set;
[0018] Obtaining multiple pending operation paths from the multiple candidate operation paths, wherein a maximum time interval corresponding to the pending operation paths is less than or equal to a first preset time length, and the maximum time interval refers to an absolute value of a difference between the first initial display time of the operation set located at the front and the first initial display time of the operation set located at the back in the pending operation path, or an absolute value of a difference between the first initial display time of the operation set located at the front and the second initial display time of the operation set located at the back in the pending operation path;
[0019] For each operation set included in each pending operation path, acquiring the operation object including the first user interface identifier and the operation position from the operation set; so as to obtain the operation object corresponding to each operation set in the pending operation path;
[0020] For each pending operation path, the operation objects corresponding to the operation set in the pending operation path are sorted according to the order of the corresponding operation sets in the pending operation path to obtain an operation path.
[0021] In a possible implementation, the step of calculating the importance cardinality corresponding to the target function identifier based on the number of occurrences corresponding to the target function identifier includes:
[0022] Determine the number of occurrences corresponding to the target function identifier as the importance base; or,
[0023] Determine the target interval to which the number of occurrences corresponding to the target function identifier belongs; and find the importance cardinality corresponding to the target interval from the corresponding relationship between preset intervals and importance cardinality.
[0024] In a possible implementation, the step of calculating the test coverage of the target function identifier based on the importance cardinality corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier includes:
[0025] For each of the operation paths corresponding to the target function identifier, determining a ratio of the number of tests of the operation path to the importance base corresponding to the target function identifier as the test coverage of the operation path;
[0026] Based on the preset weight of the operation path corresponding to the target function identifier and the test coverage of the operation path corresponding to the target function identifier, the test coverage of the target function identifier is calculated.
[0027] In a possible implementation, the step of obtaining the test path of the target test case includes:
[0028] Obtaining the execution order of multiple test steps included in the target test case;
[0029] For each of the test steps, an object set is obtained from the test step, wherein the object set includes a plurality of the operation objects sorted from earliest to latest according to the operation order;
[0030] The object sets corresponding to the multiple test steps are sorted according to the execution order to obtain the test path of the target test case.
[0031] A second aspect of the present application provides a test coverage calculation device, comprising:
[0032] A first acquisition module is configured to acquire multiple operation paths, wherein the operation paths include multiple operation objects sorted from earliest to latest in time, wherein the operation objects include a user interface identifier, an operation position for a user interface having the user interface identifier, and an operation content for the operation position, and for each of the operation paths, an absolute value of a difference between a time corresponding to the operation object at a first position of the operation path and a time corresponding to the operation object at a last position of the operation path is less than or equal to a first preset duration;
[0033] A first search module is used to search for target function identifiers corresponding to the plurality of operation objects respectively from the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier located on the user interface;
[0034] A second acquisition module is used to acquire the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths, so as to obtain the number of occurrences corresponding to the multiple target function identifiers respectively;
[0035] A first calculation module is used to calculate, for each target function identifier, an importance cardinality corresponding to the target function identifier based on the number of occurrences corresponding to the target function identifier;
[0036] A second search module is used to search for target test cases corresponding to the target function identifiers from the preset correspondence between the function identifiers and the test cases;
[0037] A third acquisition module, configured to acquire, for each target test case corresponding to each target function identifier, a test path of the target test case;
[0038] a fourth acquisition module, configured to, for each of the operation paths, increase the number of tests of the operation path if the test path includes the operation path, so as to obtain the number of tests corresponding to the plurality of operation paths respectively;
[0039] The second calculation module is used to calculate the test coverage of each target function identifier based on the importance base corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier.
[0040] In a possible implementation, the first acquisition module includes:
[0041] A first acquisition unit is used to acquire multiple operation sets, wherein the operation set includes: a first user interface identifier, a first initial display time of a first user interface having the first user interface identifier, an operation position for the first user interface, an operation time of the operation position, an operation content at the operation position, a second initial display time of jumping from the first user interface to a second user interface, and a second user interface identifier of the second user interface;
[0042] A second acquisition unit, used to acquire multiple candidate operation paths;
[0043] Wherein, the candidate operation path includes one or more operation sets. When the candidate operation path includes multiple operation sets, the multiple operation sets are sorted from early to late in time, and the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set;
[0044] a third acquisition unit, configured to obtain a plurality of pending operation paths from the plurality of candidate operation paths, wherein a maximum time interval corresponding to the pending operation paths is less than or equal to a first preset time length, and the maximum time interval refers to an absolute value of a difference between the first initial display time of the operation set located at the front and the first initial display time of the operation set located at the back in the pending operation path, or an absolute value of a difference between the first initial display time of the operation set located at the front and the second initial display time of the operation set located at the back in the pending operation path;
[0045] a fourth acquisition unit, configured to acquire, for each operation set included in each pending operation path, the operation object including the first user interface identifier and the operation position from the operation set, so as to obtain the operation object corresponding to each operation set in the pending operation path;
[0046] The first sorting unit is used to sort the operation objects corresponding to the operation set in the pending operation path according to the order of the corresponding operation set in the pending operation path for each pending operation path, so as to obtain an operation path.
[0047] A third aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the test coverage calculation method of the above-mentioned first aspect or any implementation manner of the first aspect.
[0048] A fourth aspect of the present application provides a server, comprising at least one processor and a memory connected to the processor, wherein:
[0049] The memory is used to store computer programs;
[0050] The processor is used to execute the computer program so that the server can implement the test coverage calculation method of the above-mentioned first aspect or any implementation manner of the first aspect.
[0051] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by a server, the server can implement the test coverage calculation method of the above-mentioned first aspect or any implementation of the first aspect.
[0052] By means of the above technical scheme, the present application provides a test coverage calculation method, which obtains multiple operation paths. Since the multiple operation paths are obtained by the developers through manual operation after completing the development of the functional module, the multiple operation paths obtained are full operation paths without omissions. From the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier in the user interface, find the target function identifiers corresponding to the multiple operation objects respectively; obtain the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths; if the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths is more, it means that there are more other operation objects associated with the operation object, so once there is a problem with the operation object, it may cause other operation objects associated with the operation object to fail to jump normally. Therefore, the more times the operation object appears, the more important the operation object is. For each target function identifier, based on the number of occurrences corresponding to the target function identifier, calculate the importance cardinality corresponding to the target function identifier; from the preset correspondence between the function identifier and the test case, find the target test cases corresponding to multiple target function identifiers; for each target test case corresponding to each target function identifier, obtain the test path of the target test case; for each operation path, if the test path includes the operation path, increase the test times of the operation path to obtain the test times corresponding to multiple operation paths; for each target function identifier, based on the importance cardinality corresponding to the target function identifier and the test times of the operation path containing the operation object corresponding to the target function identifier, calculate the test coverage of the target function identifier. Therefore, it is possible to further analyze whether it is necessary to add test cases for the function module with the target function identifier based on the test coverage of the target function identifier, so as to comprehensively test the function module with the target function identifier. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0054] Figure 1 A schematic diagram of a system architecture provided for this application;
[0055] Figure 2 A schematic diagram of an optional hardware structure of a terminal provided in this application;
[0056] Figure 3 A schematic diagram of the structure of a server 200 provided in this application;
[0057] Figure 4A flowchart of a test coverage calculation method provided in this application;
[0058] Figure 5a to Figure 5b An operation diagram of two operation paths corresponding to the "transfer" function module provided in an embodiment of the present application;
[0059] Figure 6 A schematic diagram of the structure of a test coverage calculation device provided in this application. DETAILED DESCRIPTION
[0060] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0061] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0062] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0063] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a first terminal 100, a server 200 and a second terminal 300. The server 200 may include one or more servers ( Figure 1 In the example, a server is included, and the server 200 can provide the method provided in the embodiment of the present application for one or more terminals.
[0064] Among them, a monitoring application can be installed on the first terminal 100. The first terminal 100 can obtain relevant parameters such as the operations performed by the developer on the user interface through the monitoring application, and send the above parameters to the server 200. The second terminal 300 is a terminal device held by a professional tester. The tester can set test cases for the functional modules to be tested through the second terminal 300, and build a correspondence between the functional identifier of the functional module and the test case. The second terminal 300 can send parameters such as the correspondence between the functional identifier and the test case to the server 200. The server 200 can obtain the test coverage based on the received parameters, and return the test coverage to the second terminal 300, so that the tester can set the test case again based on the test coverage.
[0065] Next describe Figure 1 The product form of the first terminal 100 or the third terminal 300 (hereinafter collectively referred to as terminals);
[0066] The terminal in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.
[0067] Figure 2 An optional hardware structure diagram of a terminal is shown.
[0068] refer to Figure 2 As shown, the terminal may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 This is merely an example of a terminal and does not constitute a limitation on the terminal. The terminal may include more or fewer components than shown in the figure, or a combination of certain components, or different components.
[0069] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the terminal. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0070] Among them, the input device 132 can receive input data and the like.
[0071] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the terminal, interactive interfaces, file display and / or playback of any multimedia file. In the embodiment of the present application, the display unit 140 can be used to display interfaces, processing results, etc.
[0072] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0073] The processor 170 is the control center of the terminal. It uses various interfaces and lines to connect various parts of the entire terminal. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0074] Among them, the memory 120 can be used to store software codes related to the test coverage calculation method, the processor 170 can execute the steps of the method corresponding to the software code, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.
[0075] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0076] In this embodiment of the present application, the RF unit 110 can send data to the server 200 and receive processing results sent by the server 200.
[0077] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0078] The terminal also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.
[0079] The terminal also includes an external interface 180, which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal to communicate with other devices, or to connect a charger to charge the terminal.
[0080] Although not shown, the terminal may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which will not be described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 in the terminal shown.
[0081] Next describe Figure 1 The product form of the server 200;
[0082] Figure 3 A structural diagram of a server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0083] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0084] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0085] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive (HDD), or a solid state drive (SSD).
[0086] The memory 204 may be used to store software codes related to the test coverage calculation method, and the processor 202 may execute the steps of the test coverage calculation method for the chip, and may also schedule other units to implement corresponding functions.
[0087] It should be understood that the above-mentioned terminal and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (digital signal processing, DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0088] Reference Figure 4 , Figure 4 A flow chart of a test coverage calculation method provided in an embodiment of the present application is shown as follows: Figure 4As shown, a test coverage calculation method provided in an embodiment of the present application may include steps 401 to 408, and these steps are described in detail below.
[0089] Step 401: Acquire multiple operation paths.
[0090] The operation path includes multiple operation objects sorted from early to late in time, and the operation objects include a user interface identifier, an operation position for a user interface having the user interface identifier, and an operation content for the operation position. For each of the operation paths, the absolute value of the difference between the time corresponding to the operation object at the first position of the operation path and the time corresponding to the operation object at the last position of the operation path is less than or equal to a first preset duration.
[0091] Exemplarily, multiple operation paths may be stored in a database, or in a queue.
[0092] Exemplarily, the multiple operation paths are operation paths of the same functional module of the same application; exemplary, the multiple operation paths are operation paths of different functional modules of the same application.
[0093] The operation path is an operation path to reach the user interface corresponding to the function module. The function module is described below by taking the application program as a mobile banking application program as an example.
[0094] Exemplarily, the functional modules include but are not limited to: phone bill recharge, my finance, my fund, scan, payment, transfer, account management, and transaction details.
[0095] The following is an example of the "operation path".
[0096] Assuming the function module is transfer, there are two operation paths corresponding to transfer, such as Figure 5a to Figure 5b As shown, it is an operation diagram of two operation paths corresponding to the "transfer" function module provided in the embodiment of the present application.
[0097] pass Figure 5aIt can be seen that the developer clicks on the function icon of the "transfer" function module in the user interface 51 (corresponding to the user interface identifier 01) of the mobile banking application (assuming that the transfer function icon is located at the operation position 0011 of the user interface 51), and can jump to the user interface 52 (corresponding to the user interface identifier 02). The developer clicks on the account transfer function icon in the user interface 52 (assuming that the account transfer function icon is located at the operation position 002 of the user interface 52), and can jump to the user interface 53 (corresponding to the user interface identifier 03). It is assumed that the developer enters the transfer amount 6000 (the input box where "6000" is located is located at the operation position 0031 of the user interface 53), the payee name Zhang San (the input box where "Zhang San" is located is located at the operation position 0032 of the user interface 53), and the receiving account number 222222222222 (the input box where "222222222222" is located at the operation position 0033 of the user interface 53).
[0098] Assuming that the operation object is represented by {user interface identifier, operation position, operation content}, the operation path to reach user interface 53 includes: {user interface identifier 01, operation position 0011, none}, {user interface identifier 02, operation position 002, none}, {user interface identifier 03, operation position 0031, amount}, {user interface identifier 03, operation position 0032, name}, {user interface identifier 03, operation position 0033, receiving account}.
[0099] Exemplarily, the operation position is the position of the operated area, which may be the screen position clicked by the developer, or the position of the function icon corresponding to the keyword contained in the voice. Exemplarily, the operation content may include: at least one of the type of input content, the length of the input content, and the format of the input content.
[0100] For example, the input content "6000" is of type amount, the input content "Zhang San" is of type name, and the input content "22222222222" is of type receiving account. The input content "Zhang San" is in text format, the input content "22222222222" is 11 characters long, and the input content "6000" is in numeric format.
[0101] Exemplarily, the operation content may be “none”, that is, there is no operation content.
[0102] pass Figure 5bIt can be seen that the developer clicks the function icon of the "Account Management" function module in the user interface 51 (corresponding to the user interface identifier 01) of the mobile banking application (assuming that the account management function icon is located at the operation position 0012 of the user interface 51), and can jump to the user interface 54 (corresponding to the user interface identifier 04). The developer clicks the transfer function icon in the user interface 54 (assuming that the transfer function icon is located at the operation position 004 of the user interface 54) and can jump to the user interface 53 (corresponding to the user interface identifier 03). It is assumed that the developer enters the transfer amount 6000 (the input box where "6000" is located is located at the operation position 0031 of the user interface 53), the payee name Zhang San (the input box where "Zhang San" is located is located at the operation position 0032 of the user interface 53) and the receiving account number 222222222222 (the input box where "222222222222" is located at the operation position 0033 of the user interface 53).
[0103] Assuming that the operation object is represented by {user interface identifier, operation position, operation content}, the operation path to reach user interface 53 includes: {user interface identifier 01, operation position 0012, none}, {user interface identifier 04, operation position 004, none}, {user interface identifier 03, operation position 0031, value}, {user interface identifier 03, operation position 0032, name}, {user interface identifier 03, operation position 0033, payment account}.
[0104] The above “time” is explained below. The above “time” can be the operation time for the operation position, or the initial display time when the user interface is opened. The initial display time of the user interface is the moment when the user interface is opened. The following is an explanation.
[0105] Exemplarily, the operation path may include an operation object with an operation position of None, in which case the operation object is located at the end of the operation path.
[0106] If the operation position in the operation object is None, it means that the user has not performed any operation on the user interface and has only viewed the user interface. Since the user has not performed any operation on the user interface, it will not jump to other user interfaces. Therefore, if the operation position in the operation object is None, the operation object is at the end of the operation path.
[0107] If the operation position of the operation object is not None, there is an operation time for the operation position, and the time corresponding to the operation object is the operation time; if the operation position of the operation object is None, the time corresponding to the operation object is the initial display time.
[0108] The following explains that “for each operation path, the absolute value of the difference between the time corresponding to the operation object at the first position of the operation path and the time corresponding to the operation object at the last position of the operation path is less than or equal to the first preset duration”.
[0109] It is understandable that after the developer has developed the functional module, the developer can Figure 5a to Figure 5b The operation positions of each user interface are operated in the manner shown, so that the developer can manually test whether the operation path can jump normally. Since the developer is more familiar with the various functional modules of the application, the speed in the process of operating the user interface may be faster, so the maximum difference between the time corresponding to each operation object belonging to the same operation path is less than or equal to the first preset time length, and for the same operation path, the absolute value of the difference between the time corresponding to the operation object at the first position of the operation path and the time corresponding to the operation object at the last position of the operation path is the maximum difference.
[0110] It is understandable that since developers are more familiar with functional modules, they will operate on all operation paths. In order to obtain a complete and comprehensive operation path, a monitoring application is added to the developer's device. The developer's operation position, operation time and operation content for each user interface are obtained through the monitoring application, thereby obtaining complete multiple operation paths.
[0111] For example, the developer can click a start button of the monitoring application to start the monitoring application; the developer can click an end button of the monitoring application to close the monitoring application.
[0112] Exemplarily, the first preset time length may be determined based on actual conditions. For example, the first preset time length may be 10 seconds.
[0113] Step 402: searching for target function identifiers corresponding to the plurality of operation objects from the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier located on the user interface.
[0114] The following is an example to illustrate “a function icon with a function identifier being located in a regional position of a user interface”.
[0115] like Figure 5a As shown, the function icon 511 of the "transfer" function module is located in the area of the user interface 51. Figure 5a shown.
[0116] Exemplarily, the corresponding relationship in the above step 402 is extracted from the development requirement specification.
[0117] Exemplarily, the corresponding relationship in the above step 402 is extracted from the program code corresponding to the application program.
[0118] Exemplarily, the corresponding relationship in the above step 402 is manually set.
[0119] pass Figure 5a and Figure 5b It can be seen that some operation positions correspond to function icons, such as Figure 5a In the example, the operation position of the user interface 51 corresponds to a function icon 511, and some operation positions do not correspond to a function icon, for example Figure 5a The operation position of the user interface 53 corresponds to an input box, but does not correspond to a function icon. In the process of executing step 402, if the user interface identifier and the operation position in the operation object are respectively the same as the user interface identifier and the area position having the corresponding relationship mentioned in step 402, it means that the operation object corresponds to a function module, so that the target function identifier corresponding to the operation object can be obtained. Assuming that the corresponding relationship includes the corresponding relationship between the user interface identifier 01, the operation position 0011 and the function identifier of the "transfer" function module, the target function identifier corresponding to the operation object {user interface identifier 01, operation position 0011, none} is the function identifier of the "transfer" function module. However, the operation object {user interface identifier 03, operation position 0031, numerical value} does not correspond to a target function identifier.
[0120] It can be understood that the function identifier includes the name of the function module and / or the ID of the function module.
[0121] Step 403: Obtain the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths to obtain the number of occurrences corresponding to the multiple target function identifiers respectively.
[0122] It can be understood that if the operation object 11 corresponding to the target function identifier appears more times in multiple operation paths, it means that there are more other operation objects associated with the operation object 11. Therefore, once a problem occurs with the operation object 11, it may cause other operation objects associated with the operation object 11 to fail to jump normally. Therefore, the more times an operation object appears, the more important the operation object is.
[0123] Exemplarily, the number of occurrences corresponding to each of the plurality of target function identifiers may be stored in a queue.
[0124] Step 404: For each target function identifier, based on the number of occurrences corresponding to the target function identifier, calculate the importance cardinality corresponding to the target function identifier.
[0125] The number of occurrences is positively correlated with the cardinality of importance.
[0126] There are many ways to implement step 404, and the embodiments of the present application provide but are not limited to the following two.
[0127] The first method for implementing step 404 includes the following steps A11.
[0128] Step A11: Determine the number of occurrences corresponding to the target function identifier as the importance base.
[0129] The second method for implementing step 404 includes the following steps A21 to A22.
[0130] Step A21: Determine the target interval to which the number of occurrences corresponding to the target function identifier belongs.
[0131] Step A22: searching for the importance cardinality corresponding to the target interval from the correspondence between preset intervals and importance cardinality.
[0132] Exemplarily, a mathematical operation may be performed on the number of occurrences to obtain an importance base, such as a logarithmic operation.
[0133] Step 405: searching for target test cases corresponding to the target function identifiers from the preset correspondence between the function identifiers and the test cases.
[0134] It is understandable that after the developer manually tests each operation path, the professional tester can be notified to test each operation path of the functional module. The professional tester will set multiple test cases for each functional module; each functional module will be automatically tested through the test case. After setting multiple test cases for each functional module, the corresponding relationship between the functional identifier of the functional module and the test case can be set.
[0135] Step 406: For each target test case corresponding to each target function identifier, obtain the test path of the target test case.
[0136] It can be understood that the target test case includes multiple test steps, and each test step includes operation objects sorted from early to late in chronological order, so the test path can be obtained through the target test case.
[0137] Exemplarily, the test path includes a plurality of operation objects, and the operation content in the operation object includes at least one of the type of input content, the length of the input content, and the format of the input content.
[0138] Step 407: For each of the operation paths, if the test path includes the operation path, increase the test times of the operation path to obtain the test times corresponding to the multiple operation paths respectively.
[0139] Exemplarily, the initial value of the number of tests is 0.
[0140] Exemplarily, the correspondence between the operation path and the number of tests may be stored in a queue.
[0141] Exemplarily, the test path includes the operation path means that the test path is the same as the operation path, or the operation path is a true subset of the test path. Assume that the test path includes: operation object 11→operation object 12→operation object 13→operation object 14. If the operation path is operation object 12→operation object 13, then the test path includes the operation path, and the operation path is a true subset of the test path; if the operation path is operation object 12→operation object 14, then the test path does not include the operation path.
[0142] It is understandable that different test cases for the same operation path of the same functional module are different, as illustrated below. Assume that the operation position F11 of the user interface with the user interface identifier F1 is an input box for searching content, and the user interface with the user interface identifier F2 is a user interface for displaying search results. Assuming that the search content cannot exceed 11 characters, the user interface for displaying search results may display: "No relevant content was found", or "The search content exceeds 11 characters", or "Information representing the content that meets the search content".
[0143] For the operation path of the "search" function module [{user interface identifier F1, operation position F11, search content}→{user interface identifier F2, none, none}], multiple test cases are set in combination with actual conditions. Assuming that the length of the search content filled in the operation position F11 of the "search" function module is not more than 11 characters, three test cases can be set. The three test cases are: test case F111 for testing whether the search content can be normally jumped to the user interface displaying the search results (i.e., the user interface with the user interface identifier F2) when the search content is less than 11 characters, test case F112 for testing whether the search content can be normally jumped to the user interface displaying the search results when the search content is equal to 11 characters, and test case F113 for testing whether the search content can be normally jumped to the user interface displaying the search results when the search content is greater than 11 characters. However, the test paths of these three test cases are all {user interface identifier F1, operation position F11, search content}→{user interface identifier F2, none, none}.
[0144] In summary, different test cases for the same operation path of the same functional module are different, but the test paths of different test cases may be the same. It is understandable that if the operation content includes: the format of the input content, the type of the input content, and the length of the input content, the test paths of different test cases are different.
[0145] Step 408: For each target function identifier, the test coverage of the target function identifier is calculated based on the importance cardinality corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier.
[0146] It can be understood that the operation path including the operation object corresponding to the target function identifier is the operation path corresponding to the target function identifier. Exemplarily, the number of operation paths corresponding to the same target function identifier may be one or more.
[0147] Exemplarily, if the test coverage of the target function identifier is lower than a preset value, it means that one or more test cases need to be added for the functional module corresponding to the target function identifier.
[0148] It can be understood that different test cases for the same operation path of the same functional module are different. If it is necessary to add test cases for the functional module corresponding to the target functional identifier, it is necessary to analyze which operation path the test cases need to be added. For example, it is necessary to add a test case for the operation path {user interface identifier F1, operation position F11, retrieval content}→{user interface identifier F2, none, none}. Assuming that the existing test cases are test case F111 and test case F112, test case F113 can be added.
[0149] The embodiment of the present application provides a test coverage calculation method, which obtains multiple operation paths. Since the multiple operation paths are obtained by developers through manual operation after completing the development of the functional module, the multiple operation paths obtained are complete operation paths without omissions. From the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier in the user interface, find the target function identifiers corresponding to multiple operation objects respectively; obtain the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths; if the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths is more, it means that there are more other operation objects associated with the operation object, so once there is a problem with the operation object, it may cause other operation objects associated with the operation object to fail to jump normally. Therefore, the more times the operation object appears, the more important the operation object is. For each target function identifier, based on the number of occurrences corresponding to the target function identifier, calculate the importance cardinality corresponding to the target function identifier; from the preset correspondence between the function identifier and the test case, find the target test cases corresponding to multiple target function identifiers; for each target test case corresponding to each target function identifier, obtain the test path of the target test case; for each operation path, if the test path includes the operation path, increase the test times of the operation path to obtain the test times corresponding to multiple operation paths; for each target function identifier, based on the importance cardinality corresponding to the target function identifier and the test times of the operation path containing the operation object corresponding to the target function identifier, calculate the test coverage of the target function identifier. Therefore, it is possible to further analyze whether it is necessary to add test cases for the function module with the target function identifier based on the test coverage of the target function identifier, so as to comprehensively test the function module with the target function identifier.
[0150] In an optional implementation, there are multiple implementations of step 408, and the embodiments of the present application provide but are not limited to the following three methods.
[0151] The first method for implementing step 408 includes steps B11 and B12.
[0152] Step B11: for each operation path corresponding to the target function identifier, determine the ratio of the number of tests of the operation path to the importance base corresponding to the target function identifier as the test coverage of the operation path.
[0153] Step B12: Based on the preset weight of the operation path corresponding to the target function identifier and the test coverage of the operation path corresponding to the target function identifier, the test coverage of the target function identifier is calculated.
[0154] Illustratively, the more important the operation path is, the greater the preset weight of the operation path is.
[0155] Exemplarily, it is assumed that the target function identifier corresponds to three operation paths, namely: operation path 111, operation path 112 and operation path 113. Test coverage of the target function identifier = preset weight of operation path 111 * number of tests of operation path 111 + preset weight of operation path 112 * number of tests of operation path 112 + preset weight of operation path 113 * number of tests of operation path 113.
[0156] Exemplarily, if the test coverage of the target function identifier is less than the preset threshold, it is necessary to add test cases for the function module with the target function identifier, for example, to add test cases for detecting abnormal values (for example, in the example of the "search" function module, the length of the search content exceeds 11 characters) and boundary values (for example, in the example of the "search" function module, the length of the search content is equal to 11 characters). It is understandable that the added test cases are different from the existing test cases.
[0157] The second method for implementing step 408 includes step B21 and step B22.
[0158] Step B21: For each operation path corresponding to the target function identifier, determine the ratio of the number of tests of the operation path to the importance base corresponding to the target function identifier as the test coverage of the operation path.
[0159] Step B22: Determine the test coverage of the target function identifier as the test coverage of the operation paths respectively corresponding to the target function identifiers.
[0160] For example, if the test coverage of a certain operation path is less than a preset threshold, it is necessary to add test cases for the operation path, for example, to add test cases for detecting abnormal values (for example, in the example of the "search" function module, the length of the search content exceeds 11 characters) and boundary values (for example, in the example of the "search" function module, the length of the search content is equal to 11 characters). It is understandable that the added test cases are different from the existing test cases.
[0161] The third method for implementing step 408 includes step B31 and step B32.
[0162] Step B31: Obtain a first value, which is the sum of the occurrence times of the operation paths corresponding to the target function identifier.
[0163] Step B32: Determine the ratio of the first value to the importance base corresponding to the target function identifier as the test coverage corresponding to the target function identifier.
[0164] Exemplarily, if the test coverage corresponding to the target function identifier is 1, there is no need to add test cases to the function module with the target function identifier; if the test coverage corresponding to the target function identifier is less than 1, it is necessary to add test cases to the function module with the target function identifier, for example, adding test cases to monitor abnormal values (for example, in the example of the "search" function module, the length of the search content exceeds 11 characters) and boundary values (for example, in the example of the "search" function module, the length of the search content is equal to 11 characters). It can be understood that the added test cases are different from the existing test cases.
[0165] In an optional implementation, there are multiple implementations of step 401. The embodiment of the present application provides but is not limited to the following method. The method includes the following steps C11 to C15 during implementation.
[0166] Step C11: Obtain multiple operation sets, wherein the operation sets include: a first user interface identifier, a first initial display time of a first user interface having the first user interface identifier, an operation position for the first user interface, an operation time of the operation position, an operation content at the operation position, a second initial display time for jumping from the first user interface to a second user interface, and a second user interface identifier of the second user interface.
[0167] Exemplarily, the operation set is represented by [first user interface identifier, first initial display time, (operation position, operation time, operation content), second initial display time, second user interface identifier]. It is understandable that if the developer performs operations on multiple operation positions of the same user interface, the operation set may include multiple operation positions, multiple operation times, and multiple operation contents, and a set of operation positions, operation times, and operation contents are represented by "()". The following example is used to illustrate.
[0168] by Figure 5a For example, if the developer clicks the "OK" button in the user interface 53, a message of "transfer successful" or "transfer failed" may pop up, and the user interface 53 also corresponds to the operation position 0034 where the "OK" button is located.
[0169] Figure 5aThere are three corresponding operation sets, which are operation set G1 [user interface identifier of user interface 51, initial display time of user interface 51, (regional position of “transfer” function icon, time of clicking “transfer” function icon, none), initial display time of user interface 52, user interface identifier of user interface 52], operation set G2 [user interface identifier of user interface 52, initial display time of user interface 52, (regional position of “account transfer” function icon, time of clicking “account transfer” function icon, none), initial display time of user interface 53 , user interface identifier of user interface 53], operation set G3 [user interface identifier of user interface 53, initial display time of user interface 53, (regional position of input box for transfer amount, time for inputting transfer amount, amount), (regional position of input box for payee name, time for inputting payee name, name), (regional position of input box for receiving account, time for inputting receiving account number, receiving account number), (operation position 0034, information indicating "transfer successful" or "transfer failed" is displayed for operation time of operation position 0034), none, none]. Since no jump is made from user interface 53 to other user interfaces, the second user interface identifier is none, and the second initial display time is none.
[0170] Step C12: Acquire multiple candidate operation paths.
[0171] Among them, the candidate operation path includes one or more of the operation sets. When the candidate operation path includes multiple operation sets, the multiple operation sets are sorted from early to late in time, and the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set.
[0172] It can be understood that if the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set, it means that the two adjacent operation sets are also adjacent in the actual operation process.
[0173] Still with the above Figure 5aThe corresponding three operation sets are used as examples for explanation. Since the operation set G1, the operation set G2 and the operation set G3 are sorted from earliest to latest in time, the sorting results are: operation set G1, operation set G2, and operation set G3; the second user interface identifier of the operation set G1 is the user interface identifier of the user interface 52, which is the same as the first user interface identifier of the operation set G2; the second user interface identifier of the operation set G2 is the user interface identifier of the user interface 53, which is the same as the first user interface identifier of the operation set G3. And the second initial display time of the operation set G1 is the initial display time of the user interface 52, which is the same as the first initial display time of the operation set G2; the second initial display time of the operation set G2 is the initial display time of the user interface 53, which is the same as the first initial display time of the operation set G3, so the operation set G1, the operation set G2 and the operation set G3 belong to the same candidate operation path.
[0174] Step C13: Obtain multiple pending operation paths from the multiple candidate operation paths, and the maximum time interval corresponding to the pending operation paths is less than or equal to a first preset duration, and the maximum time interval refers to the absolute value of the difference between the first initial display time of the operation set located at the front and the first initial display time of the operation set located at the back in the pending operation path, or the absolute value of the difference between the first initial display time of the operation set located at the front and the second initial display time of the operation set located at the back in the pending operation path.
[0175] The maximum time interval refers to the maximum difference in time between two operation sets in the pending operation path.
[0176] It is understandable that developers are very familiar with the functional modules, so they can operate the operation path very quickly. If the maximum time interval in the pending operation path is long, it may not be the operation path for a functional module. Therefore, the determination of the first preset time length is very critical.
[0177] Exemplarily, the first preset durations corresponding to different functional modules are different. Exemplarily, they can be determined based on the average value of the number of operation objects in multiple operation paths corresponding to the functional modules. It is understandable that, in order to facilitate customer operation, the number of operation objects in the operation paths of the same functional module is equivalent and will not differ greatly. Assuming that the average value of the number of operation objects in the operation paths corresponding to the functional modules is 5, and assuming that the time it takes for the developer to execute an operation object is 1 second, the first preset duration can be 5 seconds.
[0178] Exemplarily, the first preset durations corresponding to different functional modules are not completely the same, or are completely the same.
[0179] Exemplarily, each pending operation path includes at most a user interface identifier of a home page of an application.
[0180] Step C14: for each operation set included in each pending operation path, obtain the operation object including the first user interface identifier and the operation position from the operation set; so as to obtain the operation object corresponding to each operation set in the pending operation path.
[0181] Step C15: For each pending operation path, the operation objects corresponding to the operation set in the pending operation path are sorted according to the order of the corresponding operation sets in the pending operation path to obtain an operation path.
[0182] Assuming that the pending operation path is {operation set G1, operation set G2, operation set G3}, the operation object G11 obtained from the operation set G1 is {user interface identifier of user interface 51, the area position where the "transfer" function icon is located, none}, the operation object G22 obtained from the operation set G2 is {user interface identifier of user interface 52, the area position where the "account transfer" function icon is located, none}, and the operation objects obtained from the operation set G3 are operation object G31 {user interface identifier of user interface 53, the area position where the input box for the transfer amount is located, the amount}, operation object G32 {user interface identifier of user interface 53, the area position where the input box for the payee's name is located, the name}, and operation object G33 {user interface identifier of user interface 53, operation position 0034, information representing "transfer successful" or "transfer failed" is displayed}. Since the operation set G1 is in the first place, the operation object G11 is in the first place, the operation set G2 is in the second place, the operation object G22 is in the second place, and the operation set G3 is in the third place, so the operation objects G31, G32, and G33 are in the third place. Since the operation objects G31, G32, and G33 are sorted by time, the sorting result is operation object G31, operation object G32, and operation object G33, so the operation path obtained is: operation object G11, operation object G22, operation object G31, operation object G32, and operation object G33.
[0183] In an optional implementation, there are multiple implementations of step 406. The embodiment of the present application provides but is not limited to the following method, which includes the following steps D11 to D13 during implementation.
[0184] Step D11: Obtain the execution order of multiple test steps included in the target test case.
[0185] Step D12: for each of the test steps, obtain an object set from the test step, wherein the object set includes a plurality of the operation objects sorted from earliest to latest according to the operation sequence.
[0186] It is understandable that the test step includes description information for the test step and program code corresponding to the test step. The object set can be obtained based on the description information and program code of the test step.
[0187] Step D13: sorting the object sets corresponding to the multiple test steps respectively according to the execution order to obtain the test path of the target test case.
[0188] A test coverage calculation method provided in an embodiment of the present application is introduced above, and a device for executing the above test coverage calculation method will be introduced below.
[0189] See also Figure 6 , Figure 6 A schematic diagram of the structure of a test coverage calculation device provided in an embodiment of the present application. Figure 6 As shown, the test coverage calculation device includes:
[0190] A first acquisition module 601 is used to acquire multiple operation paths, wherein the operation paths include multiple operation objects sorted from early to late in time, and the operation objects include a user interface identifier, an operation position for a user interface having the user interface identifier, and an operation content for the operation position, and for each of the operation paths, an absolute value of a difference between a time corresponding to the operation object at a first position of the operation path and a time corresponding to the operation object at a last position of the operation path is less than or equal to a first preset duration;
[0191] A first search module 602 is used to search for target function identifiers corresponding to the plurality of operation objects from the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier located on the user interface;
[0192] The second acquisition module 603 is used to acquire the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths, so as to obtain the number of occurrences corresponding to the multiple target function identifiers respectively;
[0193] A first calculation module 604 is used to calculate, for each target function identifier, an importance cardinality corresponding to the target function identifier based on the number of occurrences corresponding to the target function identifier;
[0194] The second search module 605 is used to search for target test cases corresponding to the target function identifiers from the preset correspondence between the function identifiers and the test cases;
[0195] A third acquisition module 606 is used to acquire a test path of each target test case corresponding to each target function identifier;
[0196] A fourth acquisition module 607 is configured to, for each of the operation paths, increase the test times of the operation path if the test path includes the operation path, so as to obtain the test times corresponding to the plurality of operation paths respectively;
[0197] The second calculation module 608 is used to calculate the test coverage of each target function identifier based on the importance base corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier.
[0198] In an optional implementation, the first acquisition module includes:
[0199] A first acquisition unit is used to acquire multiple operation sets, wherein the operation set includes: a first user interface identifier, a first initial display time of a first user interface having the first user interface identifier, an operation position for the first user interface, an operation time of the operation position, an operation content at the operation position, a second initial display time of jumping from the first user interface to a second user interface, and a second user interface identifier of the second user interface;
[0200] A second acquisition unit, used to acquire multiple candidate operation paths;
[0201] Wherein, the candidate operation path includes one or more operation sets. When the candidate operation path includes multiple operation sets, the multiple operation sets are sorted from early to late in time, and the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set;
[0202] a third acquisition unit, configured to obtain a plurality of pending operation paths from the plurality of candidate operation paths, wherein a maximum time interval corresponding to the pending operation paths is less than or equal to a first preset time length, and the maximum time interval refers to an absolute value of a difference between the first initial display time of the operation set located at the front and the first initial display time of the operation set located at the back in the pending operation path, or an absolute value of a difference between the first initial display time of the operation set located at the front and the second initial display time of the operation set located at the back in the pending operation path;
[0203] a fourth acquisition unit, configured to acquire, for each operation set included in each pending operation path, the operation object including the first user interface identifier and the operation position from the operation set, so as to obtain the operation object corresponding to each operation set in the pending operation path;
[0204] The first sorting unit is used to sort the operation objects corresponding to the operation set in the pending operation path according to the order of the corresponding operation set in the pending operation path for each pending operation path, so as to obtain an operation path.
[0205] In an optional implementation, the first calculation module includes:
[0206] A first determining unit is configured to determine the number of occurrences corresponding to the target function identifier as the importance base; or
[0207] The second determining unit is used to determine the target interval to which the number of occurrences corresponding to the target function identifier belongs; and to search for the importance cardinality corresponding to the target interval from a correspondence between preset intervals and importance cardins.
[0208] In an optional implementation, the second calculation module includes:
[0209] A third determining unit is used to determine, for each of the operation paths corresponding to the target function identifier, that a ratio of the number of tests of the operation path to the importance base corresponding to the target function identifier is the test coverage of the operation path;
[0210] A calculation unit is used to calculate the test coverage of the target function identifier based on the preset weight of the operation path corresponding to the target function identifier and the test coverage of the operation path corresponding to the target function identifier.
[0211] In an optional implementation, the third acquisition module includes:
[0212] A fifth acquisition unit, used to acquire the execution order of multiple test steps included in the target test case;
[0213] a sixth acquisition unit, configured to acquire, for each of the test steps, an object set from the test step, the object set comprising a plurality of the operation objects sorted from earliest to latest in operation order;
[0214] The second sorting unit is used to sort the object sets corresponding to the multiple test steps according to the execution order to obtain the test path of the target test case.
[0215] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any test coverage calculation method provided in the embodiment of the present application.
[0216] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by a server, the server can implement any test coverage calculation method provided in an embodiment of the present application.
[0217] The test coverage calculation method and related devices provided by the present invention can be used in the financial field or other fields, for example, can be used in test application scenarios in the financial field. Other fields are any fields other than the financial field, for example, the power field. The above is only an example and does not limit the application field of the test coverage calculation method and related devices provided by the present invention.
[0218] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0219] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0220] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0221] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A test coverage calculation method, It is characterized in that include: Acquire multiple operation paths, the operation paths including multiple operation objects sorted in time from earliest to latest, the operation objects including a user interface identifier, an operation position for a user interface having the user interface identifier, and an operation content for the operation position, and for each of the operation paths, an absolute value of a difference between a time corresponding to the operation object at a first position of the operation path and a time corresponding to the operation object at a last position of the operation path is less than or equal to a first preset duration; Finding target function identifiers corresponding to the plurality of operation objects respectively from the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier located on the user interface; Obtaining the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths, so as to obtain the number of occurrences corresponding to the multiple target function identifiers respectively; For each of the target function identifiers, based on the number of occurrences corresponding to the target function identifier, calculate the importance cardinality corresponding to the target function identifier; From the preset correspondence between function identifiers and test cases, searching for target test cases corresponding to the target function identifiers; For each of the target test cases corresponding to each of the target function identifiers, obtaining a test path for the target test case; For each of the operation paths, if the test path includes the operation path, increase the test times of the operation path to obtain the test times corresponding to the multiple operation paths respectively; For each of the target function identifiers, the test coverage of the target function identifier is calculated based on the importance base corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier.
2. According to the test coverage calculation method of claim 1, It is characterized in that The obtaining of multiple operation paths includes: Acquire multiple operation sets, the operation sets including: a first user interface identifier, a first initial display time of a first user interface having the first user interface identifier, an operation position for the first user interface, an operation time of the operation position, an operation content at the operation position, a second initial display time of jumping from the first user interface to a second user interface, and a second user interface identifier of the second user interface; Obtain multiple candidate operation paths; Wherein, the candidate operation path includes one or more operation sets. When the candidate operation path includes multiple operation sets, the multiple operation sets are sorted from early to late in time, and the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set; Obtaining multiple pending operation paths from the multiple candidate operation paths, wherein a maximum time interval corresponding to the pending operation paths is less than or equal to a first preset time length, and the maximum time interval refers to an absolute value of a difference between the first initial display time of the operation set located at the front and the first initial display time of the operation set located at the back in the pending operation path, or an absolute value of a difference between the first initial display time of the operation set located at the front and the second initial display time of the operation set located at the back in the pending operation path; For each operation set included in each pending operation path, acquiring the operation object including the first user interface identifier and the operation position from the operation set; so as to obtain the operation object corresponding to each operation set in the pending operation path; For each pending operation path, the operation objects corresponding to the operation set in the pending operation path are sorted according to the order of the corresponding operation sets in the pending operation path to obtain an operation path.
3. According to the test coverage calculation method of claim 1, It is characterized in that The step of calculating the importance cardinality corresponding to the target function identifier based on the number of occurrences corresponding to the target function identifier comprises: Determine the number of occurrences corresponding to the target function identifier as the importance base; or, Determine the target interval to which the number of occurrences corresponding to the target function identifier belongs; and find the importance cardinality corresponding to the target interval from the corresponding relationship between preset intervals and importance cardinality.
4. According to the test coverage calculation method of claim 1, It is characterized in that The step of calculating the test coverage of the target function identifier based on the importance cardinality corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier comprises: For each of the operation paths corresponding to the target function identifier, determining a ratio of the number of tests of the operation path to the importance base corresponding to the target function identifier as the test coverage of the operation path; Based on the preset weight of the operation path corresponding to the target function identifier and the test coverage of the operation path corresponding to the target function identifier, the test coverage of the target function identifier is calculated.
5. The test coverage calculation method according to any one of claims 1 to 4, It is characterized in that The step of obtaining the test path of the target test case includes: Obtaining the execution order of multiple test steps included in the target test case; For each of the test steps, an object set is obtained from the test step, wherein the object set includes a plurality of the operation objects sorted from earliest to latest according to the operation order; The object sets corresponding to the multiple test steps are sorted according to the execution order to obtain the test path of the target test case.
6. A test coverage calculation device, It is characterized in that include: A first acquisition module is configured to acquire multiple operation paths, wherein the operation paths include multiple operation objects sorted from earliest to latest in time, wherein the operation objects include a user interface identifier, an operation position for a user interface having the user interface identifier, and an operation content for the operation position, and for each of the operation paths, an absolute value of a difference between a time corresponding to the operation object at a first position of the operation path and a time corresponding to the operation object at a last position of the operation path is less than or equal to a first preset duration; A first search module is used to search for target function identifiers corresponding to the plurality of operation objects respectively from the correspondence between the preset function identifier, the user interface identifier of the user interface where the function identifier is located, and the regional position of the function icon with the function identifier located on the user interface; A second acquisition module is used to acquire the number of occurrences of the operation object corresponding to the target function identifier in the multiple operation paths, so as to obtain the number of occurrences corresponding to the multiple target function identifiers respectively; A first calculation module is used to calculate, for each target function identifier, an importance cardinality corresponding to the target function identifier based on the number of occurrences corresponding to the target function identifier; A second search module is used to search for target test cases corresponding to the target function identifiers from the preset correspondence between the function identifiers and the test cases; A third acquisition module, configured to acquire, for each target test case corresponding to each target function identifier, a test path of the target test case; a fourth acquisition module, configured to, for each of the operation paths, increase the number of tests of the operation path if the test path includes the operation path, so as to obtain the number of tests corresponding to the plurality of operation paths respectively; The second calculation module is used to calculate the test coverage of each target function identifier based on the importance base corresponding to the target function identifier and the number of tests of the operation path including the operation object corresponding to the target function identifier.
7. The test coverage calculation device according to claim 1, It is characterized in that The first acquisition module includes: A first acquisition unit is used to acquire multiple operation sets, wherein the operation set includes: a first user interface identifier, a first initial display time of a first user interface having the first user interface identifier, an operation position for the first user interface, an operation time of the operation position, an operation content at the operation position, a second initial display time of jumping from the first user interface to a second user interface, and a second user interface identifier of the second user interface; A second acquisition unit, used to acquire multiple candidate operation paths; Wherein, the candidate operation path includes one or more operation sets. When the candidate operation path includes multiple operation sets, the multiple operation sets are sorted from early to late in time, and the second user interface identifier of the previous operation set of two adjacent operation sets is the first user interface identifier of the next operation set, and the second initial display time of the previous operation set is the first initial display time of the next operation set; a third acquisition unit, configured to obtain a plurality of pending operation paths from the plurality of candidate operation paths, wherein a maximum time interval corresponding to the pending operation paths is less than or equal to a first preset time length, and the maximum time interval refers to an absolute value of a difference between the first initial display time of the operation set located at the front and the first initial display time of the operation set located at the back in the pending operation path, or an absolute value of a difference between the first initial display time of the operation set located at the front and the second initial display time of the operation set located at the back in the pending operation path; a fourth acquisition unit, configured to acquire, for each operation set included in each pending operation path, the operation object including the first user interface identifier and the operation position from the operation set, so as to obtain the operation object corresponding to each operation set in the pending operation path; The first sorting unit is used to sort the operation objects corresponding to the operation set in the pending operation path according to the order of the corresponding operation set in the pending operation path for each pending operation path, so as to obtain an operation path.
8. A computer program product, It is characterized in that It includes computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the test coverage calculation method as described in any one of claims 1 to 5.
9. A server, It is characterized in that The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the server can implement the test coverage calculation method as described in any one of claims 1 to 5.
10. A computer storage medium, It is characterized in that The storage medium carries one or more computer programs, and when the one or more computer programs are executed by the server, the server can implement the test coverage calculation method as described in any one of claims 1 to 5.
