WO2019169760A1 - Test case range determining method, device, and storage medium - Google Patents

Test case range determining method, device, and storage medium Download PDF

Info

Publication number
WO2019169760A1
WO2019169760A1 PCT/CN2018/089318 CN2018089318W WO2019169760A1 WO 2019169760 A1 WO2019169760 A1 WO 2019169760A1 CN 2018089318 W CN2018089318 W CN 2018089318W WO 2019169760 A1 WO2019169760 A1 WO 2019169760A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
coverage data
code coverage
data
test case
Prior art date
Application number
PCT/CN2018/089318
Other languages
French (fr)
Chinese (zh)
Inventor
陈晓芳
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019169760A1 publication Critical patent/WO2019169760A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Definitions

  • the present application relates to the field of computer technology, and in particular, to a test case range determining method, an electronic device, and a computer readable storage medium.
  • Test Case is a set of test inputs, execution conditions, and expected results that are programmed for a particular purpose to test a program path or verify that a particular requirement is met.
  • each system or software version has a shorter iteration period. To complete the test in a shorter time, this requires a clear test range. At present, most of the test scope is obtained by estimation or by topology, but the scope of the acquisition is limited, so that the scope of the test is not comprehensive enough. Therefore, there is a need to provide a method for quickly and accurately determining the range of test cases.
  • the present application provides a test case range determining method, an electronic device, and a computer readable storage medium.
  • the main purpose of the present invention is to quickly and accurately determine the range of test cases, so that the test case range is close to the actual operation of the user, and the test efficiency is improved.
  • the present application provides a method for determining a test case range, the method comprising:
  • test case set is a final test case set.
  • the present application further provides an electronic device, the device comprising a memory, a processor, and a memory of a test case range determining program executable on the processor, the program being Any step of the test case range determination method as described above is implemented when the processor executes.
  • the present application further provides a computer readable storage medium having stored thereon a test case range determining program, which is executed by a processor to implement the test case range as described above. Determine any step of the method.
  • the test case range determining method, the electronic device and the computer readable storage medium proposed by the present application initially determine the scope of the test case according to the first code coverage data obtained by the user performing the operation behavior in the operating environment of the system. , reducing the effectiveness of the test case, improving the efficiency of the test case range determination; and executing the test case in the system test environment to obtain the second code coverage data, comparing the two sets of code coverage data to obtain the difference code, adjusting the test case according to the difference code, determining The final test case scope maximizes the test case range to the user's actual operating behavior and improves test efficiency.
  • FIG. 1 is a schematic diagram of a preferred embodiment of a server of the present application.
  • FIG. 2 is a schematic diagram of a program module of the test case range determining program of FIG. 1;
  • FIG. 3 is a flow chart of a preferred embodiment of a method for determining a test case range of the present application.
  • the application provides a server 1.
  • a server 1 of the present application is shown.
  • the server 1 may be a rack server, a blade server, a tower server, or a rack server.
  • the server 1 includes a memory 11, a processor 12, a communication bus 13, a network interface 14, and a display 15.
  • the memory 11 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (for example, an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like.
  • the memory 11 may be an internal storage unit of the server 1, such as the hard disk of the server 1, in some embodiments.
  • the memory 11 may also be an external storage device of the server 1 in other embodiments, such as a plug-in hard disk equipped on the server 1, a smart memory card (SMC), and a secure digital (Secure Digital, SD) ) cards, flash cards, etc. Further, the memory 11 may also include both an internal storage unit of the server 1 and an external storage device.
  • the memory 11 can be used not only for storing application software and various types of data installed in the server 1, such as the test case range determining program 10, but also for temporarily storing data that has been output or is to be output.
  • the processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data processing chip for running program code or processing stored in the memory 11. Data, such as test case range determining program 10, and the like.
  • CPU Central Processing Unit
  • controller microcontroller
  • microprocessor or other data processing chip for running program code or processing stored in the memory 11.
  • Data such as test case range determining program 10, and the like.
  • Communication bus 13 is used to implement connection communication between these components.
  • the network interface 14 may include a standard wired interface, a wireless interface (such as a WI-FI interface), and is typically used to establish a communication connection between the server 1 and other electronic devices.
  • the server 1 may extract code coverage data from the server side (not shown) of the code coverage tool through the network interface 14, and the server side deployment server 1 of the code coverage tool is configured to receive the code coverage tool.
  • the code sent by the client (not shown) covers the data, and the client of the code coverage tool is deployed on the system to be tested.
  • the display 15 may be an LED display, a liquid crystal display, a touch liquid crystal display, and an Organic Light-Emitting Diode (OLED) touch device.
  • the display 15 may also be referred to as a display screen or display unit for displaying information processed in the server 1 and a user interface for displaying visualization.
  • FIG. 1 shows only server 1 with components 11-14, but it should be understood that not all illustrated components may be implemented, and more or fewer components may be implemented instead.
  • the server 1 may further include a user interface
  • the user interface may include an input unit such as a keyboard
  • the optional user interface may further include a standard wired interface and a wireless interface.
  • a test case range determining program 10 is stored in the memory 11.
  • the processor 12 executes the test case range determining program 10 stored in the memory 11, the following steps are implemented:
  • A1 Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
  • A2 Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
  • A3 analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
  • test case set is a final test case set.
  • the solution of the present application is described by taking the system P as an example.
  • deploy the code coverage tool on the server side of the server side for example, the client and server side of the Jacobo code coverage tool.
  • the client of the Jacoco code coverage tool is used to record the user's behavior in the actual operating environment of the system, and the coverage of the system code when executing the test case in the system's test environment; Jacoco code coverage
  • the server side of the tool is used to receive coverage of the system code recorded by the client of the Jacoco Code Coverage Tool.
  • the client of the Jacoco Code Coverage Tool sends the generated first code coverage data to the server side of the Jacobo Code Coverage Tool, which extracts the first code coverage data from the server side of the Jacobo Code Coverage Tool and passes the server 1
  • the display is shown to the tester for the tester to analyze the first code coverage data to initially determine the scope of the test case for System P. It can be understood that the function code or the operation flow executed by the user will be overwritten in the corresponding code in the system P, and the code corresponding to the function module or the operation flow that has not been executed will not be overwritten.
  • the first code coverage data includes: a package, a class, a method, and a line information that are covered by the code of the system P when the user performs the foregoing operation behavior in the actual operating environment of the system P.
  • the first code coverage data collection process the first coverage of the corresponding package, class, and method, and the first ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
  • the server 1 analyzes the overwritten code in the first code coverage data. It can be understood that the function module or the operation flow of the system is implemented by the average code. Therefore, according to the code covered in the first code coverage data, it can be deduced which functional modules or operations are performed by the user in the actual operating environment of the system P. Process. According to the deduced operation flow, the scenarios of each operation flow are respectively determined, and corresponding test cases are further obtained, and a preliminary determined test case set is generated.
  • the second code coverage data includes: a package, a class, a method, and a row information that are covered in the code of the system P when the test case is executed in the test environment of the system P.
  • the second coverage of the corresponding package, class, method, and the second ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
  • test case when executed, there may be cases where the returned test result is inconsistent with the expected result.
  • the user's operation behavior is emphasized, and the focus is on the operation flow performed by the user, because the specific value of the input itself is different, and the test result does not affect the coverage of the system code, so Does not affect the second code coverage data.
  • the covered part of the two sets of code coverage data contains multiple packages, each of which includes a class, the method includes a method, and the method includes a code line. If the difference in the coverage of a package in the two sets of code coverage data does not meet the preset conditions, it indicates that there are differences in the classes included in the package, the methods and methods included in the class, and further explains the preliminary determination.
  • the test behaviors that are not covered by the test case set and executed by the user in the actual operating environment of the system P need to further improve the test cases.
  • the coverage of each packet included in the first code coverage data in the first code coverage data and the second code coverage data is separately read, and each packet is calculated in the first code coverage data and the second code coverage data.
  • the difference degree of the coverage ratio is filtered out, and the difference code corresponding to the preset threshold is filtered out, and the difference code corresponding to the partial packet whose difference is smaller than the preset threshold is determined.
  • the formula for calculating the difference is:
  • M is the difference between the coverage of the packet in the first code coverage data and the coverage in the second code coverage data, where A is the coverage of the packet in the first code coverage data, and B is the Coverage coverage in the second code coverage data.
  • the coverage of a packet in the first code coverage data is 40%, and the coverage in the second code coverage data is 35%.
  • the difference in coverage of the packet in the two sets of code coverage data is calculated according to the calculation formula. The degree is 5%. If the preset threshold is 3% and the difference is greater than the preset threshold, the difference code corresponding to the package needs to be further determined. Further comparing the coverage of the class included in the package, filtering one or more classes whose first coverage is inconsistent with the second coverage, and further covering the method included in the one or more classes The situation is analyzed, and one or more methods with inconsistent coverage in the two sets of code coverage data are compared and selected, and the final difference code is specific to the code line.
  • the 10th to 20th lines of codes covered in the first code coverage data are not covered in the second code coverage data, then the 10th to 20th lines of codes are The difference code between the data is overwritten for the two sets of code.
  • the difference code between the first code coverage data and the second code coverage data has been located.
  • the difference code is analyzed to determine an application scenario and an operation flow or a function module corresponding to the difference code. If the existing test case set includes the test case corresponding to the application scenario, the test case is adjusted, if the existing If the test case does not contain the test case corresponding to the application scenario, the test case corresponding to the application scenario is added, and the initially determined test case set is updated.
  • the second code coverage data is updated by using the third code coverage data to obtain the updated second code coverage data, specifically, the uncovered difference code is extracted from the second code coverage data, and The coverage status of the difference code that coincides with the covered code in the third code coverage data is updated, that is, the status that is not covered is updated to the covered status.
  • the size of the threshold when the preset threshold of the degree of difference is 0, that is, the code covering the third code coverage data is compared with the difference code, when the code covered in the third code coverage data is completely The difference code is included, and after the second code coverage data is updated, the difference between the calculated first code coverage data and the second code coverage data is 0, indicating that the newly added or adjusted test case range has been completely covered.
  • the application scenario and operation flow that are not covered in the above steps. Through this step, the scope of the test case can completely include the behavior of the user in the actual operating environment of the system, and the accuracy of the test is improved.
  • the server 1 proposed by the foregoing embodiment initially determines the scope of the test case according to the first code coverage data obtained by the user performing the operation behavior in the operating environment of the system, reduces the validity of the test case, and improves the efficiency of determining the scope of the test case;
  • the test case is executed in the system test environment to obtain the second code coverage data, and the difference code between the two sets of code coverage data is obtained, the test case is adjusted according to the difference code, and the final test case range is determined, so that the test case range is maximized close to the actual operation of the user. Behavior, improve test efficiency.
  • the test case scope determining program 10 may also be divided into one or more modules, one or more modules being stored in the memory 11 and being processed by one or more processors (this Embodiments are executed by processor 12) to accomplish the present application, and a module referred to herein refers to a series of computer program instructions that are capable of performing a particular function.
  • FIG. 2 it is a schematic diagram of a program module of the test case range determining program 10 in FIG. 1.
  • the test case range determining program 10 can be divided into a first recording module 110 and a second recording module 120.
  • the analysis module 130, the update module 140, and the determination module 150, the functions or operation steps implemented by the modules 110-150 are similar to the above, and are not described in detail herein, for example, where:
  • the first recording module 110 is configured to record first code coverage data when the user performs an operation behavior in a running environment of the system, analyze the first code coverage data to derive a user operation behavior, and initially determine a test case set;
  • a second recording module 120 configured to receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
  • the analyzing module 130 is configured to analyze the first code coverage data and the second code coverage data to obtain a difference between the first code coverage data and the second code coverage data, and determine the Whether the difference meets the preset conditions;
  • the updating module 140 is configured to: when the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate the first code coverage data and the second code coverage data a difference code between the two, adjusting the test case set according to the difference code, executing the adjusted test case set, and obtaining the updated second code coverage data;
  • the determining module 150 is configured to determine that the test case set is a final test case set when a difference between the first code coverage data and the second code coverage data satisfies a preset condition.
  • the present application also provides a talent management method.
  • a talent management method Referring to Figure 3, there is shown a flow chart of a preferred embodiment of the talent management method of the present application. The method can be performed by a device that can be implemented by software and/or hardware.
  • the talent management method includes steps S1-S5:
  • test case set is a final test case set.
  • the solution of the present application is described by taking the system P as an example.
  • deploy the code coverage tool on the server side of the server side for example, the client and server side of the Jacobo code coverage tool.
  • the client of the Jacoco code coverage tool is used to record the user's behavior in the actual operating environment of the system, and the coverage of the system code when executing the test case in the system's test environment; Jacoco code coverage
  • the server side of the tool is used to receive coverage of the system code recorded by the client of the Jacoco Code Coverage Tool.
  • the client of the Jacoco Code Coverage Tool sends the generated first code coverage data to the server side of the Jacobo Code Coverage Tool, which extracts the first code coverage data from the server side of the Jacobo Code Coverage Tool and passes the server 1
  • the display is shown to the tester for the tester to analyze the first code coverage data to initially determine the scope of the test case for System P. It can be understood that the function code or the operation flow executed by the user will be overwritten in the corresponding code in the system P, and the code corresponding to the function module or the operation flow that has not been executed will not be overwritten.
  • the first code coverage data includes: a package, a class, a method, and a line information that are covered by the code of the system P when the user performs the foregoing operation behavior in the actual operating environment of the system P.
  • the first code coverage data collection process the first coverage of the corresponding package, class, and method, and the first ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
  • the first code coverage data generated by the client of the Jacoco code coverage tool in a short time to record the user behavior may not fully represent all the functional modules or operation processes executed by the user in the system P, in order not to waste Under the premise of resources, the first code covers the data more comprehensively, and filters the first code coverage data in the time dimension, and sets a preset time interval, for example, two days after the time point of opening the client of the Jacoco code coverage tool.
  • the first code coverage data for the time period is taken as the final first code coverage data and sent to the server side of the Jacobo Code Coverage Tool.
  • the server 1 analyzes the overwritten code in the first code coverage data. It can be understood that the function module or the operation flow of the system is implemented by the average code. Therefore, according to the code covered in the first code coverage data, it can be deduced which functional modules or operations are performed by the user in the actual operating environment of the system P. Process. According to the deduced operation flow, the scenarios of each operation flow are respectively determined, and corresponding test cases are further obtained, and a preliminary determined test case set is generated.
  • the second code coverage data includes: a package, a class, a method, and a row information that are covered in the code of the system P when the test case is executed in the test environment of the system P.
  • the second coverage of the corresponding package, class, method, and the second ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
  • test case when executed, there may be cases where the returned test result is inconsistent with the expected result.
  • the user's operation behavior is emphasized, and the focus is on the operation flow performed by the user, because the specific value of the input itself is different, and the test result does not affect the coverage of the system code, so Does not affect the second code coverage data.
  • the covered part of the two sets of code coverage data contains multiple packages, each of which includes a class, the method includes a method, and the method includes a code line. If the difference in the coverage of a package in the two sets of code coverage data does not meet the preset conditions, it indicates that there are differences in the classes included in the package, the methods and methods included in the class, and further explains the preliminary determination.
  • the test behaviors that are not covered by the test case set and executed by the user in the actual operating environment of the system P need to further improve the test cases.
  • the coverage of each packet included in the first code coverage data in the first code coverage data and the second code coverage data is separately read, and each packet is calculated in the first code coverage data and the second code coverage data.
  • the difference degree of the coverage ratio is filtered out, and the difference code corresponding to the preset threshold is filtered out, and the difference code corresponding to the partial packet whose difference is smaller than the preset threshold is determined.
  • the formula for calculating the difference is:
  • M is the difference between the coverage of the packet in the first code coverage data and the coverage in the second code coverage data, where A is the coverage of the packet in the first code coverage data, and B is the Coverage coverage in the second code coverage data.
  • the coverage of a packet in the first code coverage data is 40%, and the coverage in the second code coverage data is 35%.
  • the difference in coverage of the packet in the two sets of code coverage data is calculated according to the calculation formula. The degree is 5%. If the preset threshold is 3% and the difference is greater than the preset threshold, the difference code corresponding to the package needs to be further determined. Further comparing the coverage of the class included in the package, filtering one or more classes whose first coverage is inconsistent with the second coverage, and further covering the method included in the one or more classes The situation is analyzed, and one or more methods with inconsistent coverage in the two sets of code coverage data are compared and selected, and the final difference code is specific to the code line.
  • the 10th to 20th lines of codes covered in the first code coverage data are not covered in the second code coverage data, then the 10th to 20th lines of codes are The difference code between the data is overwritten for the two sets of code.
  • the difference code between the first code coverage data and the second code coverage data has been located.
  • the difference code is analyzed to determine an application scenario and an operation flow or a function module corresponding to the difference code. If the existing test case set includes the test case corresponding to the application scenario, the test case is adjusted, if the existing If the test case does not contain the test case corresponding to the application scenario, the test case corresponding to the application scenario is added, and the initially determined test case set is updated.
  • the second code coverage data is updated by using the third code coverage data to obtain the updated second code coverage data, specifically, the uncovered difference code is extracted from the second code coverage data, and The coverage status of the difference code that coincides with the covered code in the third code coverage data is updated, that is, the status that is not covered is updated to the covered status.
  • the size of the threshold when the preset threshold of the degree of difference is 0, that is, the code covering the third code coverage data is compared with the difference code, when the code covered in the third code coverage data is completely The difference code is included, and after the second code coverage data is updated, the difference between the calculated first code coverage data and the second code coverage data is 0, indicating that the newly added or adjusted test case range has been completely covered.
  • the application scenario and operation flow that are not covered in the above steps. Through this step, the scope of the test case can completely include the behavior of the user in the actual operating environment of the system, and the accuracy of the test is improved.
  • the reason why the sha-1 algorithm is not called is analyzed, if the sha-1 algorithm corresponds to the segment The code has no operational scenarios, or the user does not perform such operations.
  • the uncovered code corresponding to the sha-1 algorithm can be used as redundant code to remove it from the system code, thereby reducing the system code size.
  • the method for determining the scope of the test case proposed by the above embodiment according to the first code coverage data obtained by the user in performing the operation behavior in the operating environment of the system, initially determines the scope of the test case, reduces the effectiveness of the test case, and improves the efficiency of determining the scope of the test case. And execute the test case in the system test environment to obtain the second code coverage data, compare the two sets of code coverage data to get the difference code, adjust the test case according to the difference code, determine the final test case range, and make the test case range be as close as possible to the user.
  • the actual operational behavior improves test efficiency.
  • the embodiment of the present application further provides a computer readable storage medium.
  • the computer readable storage medium stores a test case range determining program 10, and when the program is executed by the processor, the following operations are implemented:
  • A1 Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
  • A2 Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
  • A3 analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
  • test case set is a final test case set.
  • the specific embodiment of the computer readable storage medium of the present application is substantially the same as the specific embodiment of the method for determining the scope of the test case described above, and is not described herein.
  • the technical solution of the present application which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM as described above). , a disk, an optical disk, including a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods described in the various embodiments of the present application.
  • a terminal device which may be a mobile phone, a computer, a server, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present application provides a test case range determining method. The method comprises: recording first code coverage data when a user executes an operation behavior in an operating environment of a system, and preliminarily determining a test case set; recording second code coverage data when the test case set is executed in a test environment of the system; calculating a difference between the first code coverage data and the second code coverage data; if the difference does not meet a preset condition, localizing a difference code between the first code coverage data and the second code coverage data, adjusting the test case set, executing the adjusted test case set, and acquiring updated second code coverage data; and if the difference meets the preset condition, determining the test case set as a final test case set. The present application further provides an electronic device and a storage medium. The present application quickly and accurately determines a test case range, thereby enabling the test case range to be close to the actual operations of a user and improving test efficiency.

Description

测试用例范围确定方法、装置及存储介质Test case range determining method, device and storage medium
本申请基于巴黎公约申明享有2018年3月6日递交的申请号为CN201810183368.4、名称为“测试用例范围确定方法、装置及存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。This application is based on the priority of the Chinese Patent Application entitled "Test Method Range Determination Method, Apparatus and Storage Medium", which is filed on March 6, 2018, with the application number of CN201810183368.4, which is filed on March 6, 2018. The content is incorporated herein by reference.
技术领域Technical field
本申请涉及计算机技术领域,尤其涉及一种测试用例范围确定方法、电子装置及计算机可读存储介质。The present application relates to the field of computer technology, and in particular, to a test case range determining method, an electronic device, and a computer readable storage medium.
背景技术Background technique
测试是指在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对其是否能满足设计要求进行评估的过程。测试用例(Test Case)是为某个特殊目标而编制的一组测试输入、执行条件以及预期结果,以便测试某个程序路径或核实是否满足某个特定需求。Testing is the process of operating a program under specified conditions to detect procedural errors, measure software quality, and evaluate whether it meets design requirements. A Test Case is a set of test inputs, execution conditions, and expected results that are programmed for a particular purpose to test a program path or verify that a particular requirement is met.
现在,各个系统或软件版本迭代周期都较短,若要在较短时间内完成测试,这就要求有明确的测试范围。目前,测试范围大都通过预估或通过拓扑的方式来获取,但获取的范围有限,使测试的范围不够全面。因此,需要提供一种能快速、准确确定测试用例范围的方法。Now, each system or software version has a shorter iteration period. To complete the test in a shorter time, this requires a clear test range. At present, most of the test scope is obtained by estimation or by topology, but the scope of the acquisition is limited, so that the scope of the test is not comprehensive enough. Therefore, there is a need to provide a method for quickly and accurately determining the range of test cases.
发明内容Summary of the invention
本申请提供一种测试用例范围确定方法、电子装置及计算机可读存储介质,其主要目的在于快速、准确地确定测试用例范围,使测试用例范围贴近用户的实际操作,提高测试效率。The present application provides a test case range determining method, an electronic device, and a computer readable storage medium. The main purpose of the present invention is to quickly and accurately determine the range of test cases, so that the test case range is close to the actual operation of the user, and the test efficiency is improved.
为实现上述目的,本申请提供一种测试用例范围确定方法,该方法包括:To achieve the above objective, the present application provides a method for determining a test case range, the method comprising:
S1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;S1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
S2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;S2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
S3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到 所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;S3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
S4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至S3;及S4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to S3;
S5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。S5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
此外,为实现上述目的,本申请还提供一种电子装置,该装置包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的测试用例范围确定程序,该程序被所述处理器执行时实现如上所述的测试用例范围确定方法的任意步骤。In addition, in order to achieve the above object, the present application further provides an electronic device, the device comprising a memory, a processor, and a memory of a test case range determining program executable on the processor, the program being Any step of the test case range determination method as described above is implemented when the processor executes.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有测试用例范围确定程序,该程序被处理器执行时实现如上所述的测试用例范围确定方法的任意步骤。In addition, in order to achieve the above object, the present application further provides a computer readable storage medium having stored thereon a test case range determining program, which is executed by a processor to implement the test case range as described above. Determine any step of the method.
相较于现有技术,本申请提出的测试用例范围确定方法、电子装置及计算机可读存储介质,根据用户在系统的运行环境下执行操作行为得到的第一代码覆盖数据,初步确定测试用例范围,缩小了测试用例的有效,提高测试用例范围确定的效率;并在系统测试环境下执行测试用例得到第二代码覆盖数据,对比两组代码覆盖数据得到差异代码,根据差异代码调整测试用例,确定最终的测试用例范围,使测试用例范围最大限度地接近用户实际的操作行为,提高测试效率。Compared with the prior art, the test case range determining method, the electronic device and the computer readable storage medium proposed by the present application initially determine the scope of the test case according to the first code coverage data obtained by the user performing the operation behavior in the operating environment of the system. , reducing the effectiveness of the test case, improving the efficiency of the test case range determination; and executing the test case in the system test environment to obtain the second code coverage data, comparing the two sets of code coverage data to obtain the difference code, adjusting the test case according to the difference code, determining The final test case scope maximizes the test case range to the user's actual operating behavior and improves test efficiency.
附图说明DRAWINGS
图1为本申请服务器较佳实施例的示意图;1 is a schematic diagram of a preferred embodiment of a server of the present application;
图2为图1中测试用例范围确定程序的程序模块示意图;2 is a schematic diagram of a program module of the test case range determining program of FIG. 1;
图3为本申请测试用例范围确定方法较佳实施例的流程图。3 is a flow chart of a preferred embodiment of a method for determining a test case range of the present application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
本申请提供一种服务器1。参照图1所示,为本申请服务器1较佳实施例的示意图。The application provides a server 1. Referring to FIG. 1, a schematic diagram of a preferred embodiment of the server 1 of the present application is shown.
在本实施例中,服务器1可以是机架式服务器、刀片式服务器、塔式服务器或机柜式服务器。In this embodiment, the server 1 may be a rack server, a blade server, a tower server, or a rack server.
该服务器1包括存储器11、处理器12,通信总线13,网络接口14以及显示器15。The server 1 includes a memory 11, a processor 12, a communication bus 13, a network interface 14, and a display 15.
其中,存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器11在一些实施例中可以是所述服务器1的内部存储单元,例如该服务器1的硬盘。存储器11在另一些实施例中也可以是所述服务器1的外部存储设备,例如该服务器1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器11还可以既包括该服务器1的内部存储单元也包括外部存储设备。存储器11不仅可以用于存储安装于该服务器1的应用软件及各类数据,例如测试用例范围确定程序10等,还可以用于暂时地存储已经输出或者将要输出的数据。The memory 11 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (for example, an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 11 may be an internal storage unit of the server 1, such as the hard disk of the server 1, in some embodiments. The memory 11 may also be an external storage device of the server 1 in other embodiments, such as a plug-in hard disk equipped on the server 1, a smart memory card (SMC), and a secure digital (Secure Digital, SD) ) cards, flash cards, etc. Further, the memory 11 may also include both an internal storage unit of the server 1 and an external storage device. The memory 11 can be used not only for storing application software and various types of data installed in the server 1, such as the test case range determining program 10, but also for temporarily storing data that has been output or is to be output.
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如测试用例范围确定程序10等。The processor 12, in some embodiments, may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data processing chip for running program code or processing stored in the memory 11. Data, such as test case range determining program 10, and the like.
通信总线13用于实现这些组件之间的连接通信。 Communication bus 13 is used to implement connection communication between these components.
网络接口14可以包括标准的有线接口、无线接口(如WI-FI接口),通常用于在该服务器1与其他电子设备之间建立通信连接。例如,服务器1可以通过网络接口14从代码覆盖率工具的服务器端(图中未标出)提取代码覆盖数据,所述代码覆盖率工具的服务器端部署服务器1端,用于接收代码覆 盖率工具的客户端(图中未标出)发送的代码覆盖数据,所述代码覆盖率工具的客户端部署在待测试系统上。The network interface 14 may include a standard wired interface, a wireless interface (such as a WI-FI interface), and is typically used to establish a communication connection between the server 1 and other electronic devices. For example, the server 1 may extract code coverage data from the server side (not shown) of the code coverage tool through the network interface 14, and the server side deployment server 1 of the code coverage tool is configured to receive the code coverage tool. The code sent by the client (not shown) covers the data, and the client of the code coverage tool is deployed on the system to be tested.
显示器15(Display)可以是LED显示器、液晶显示器、触控式液晶显示器以及有机发光二极管(Organic Light-Emitting Diode,OLED)触摸器等。其中,显示器15也可以称为显示屏或显示单元,用于显示在服务器1中处理的信息以及用于显示可视化的用户界面。The display 15 (Display) may be an LED display, a liquid crystal display, a touch liquid crystal display, and an Organic Light-Emitting Diode (OLED) touch device. Among them, the display 15 may also be referred to as a display screen or display unit for displaying information processed in the server 1 and a user interface for displaying visualization.
图1仅示出了具有组件11-14的服务器1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。Figure 1 shows only server 1 with components 11-14, but it should be understood that not all illustrated components may be implemented, and more or fewer components may be implemented instead.
可选地,该服务器1还可以包括用户接口,用户接口可以包括输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。Optionally, the server 1 may further include a user interface, and the user interface may include an input unit such as a keyboard, and the optional user interface may further include a standard wired interface and a wireless interface.
在图1所示的实施例中,存储器11中存储有测试用例范围确定程序10。处理器12执行存储器11中存储的测试用例范围确定程序10时实现如下步骤:In the embodiment shown in FIG. 1, a test case range determining program 10 is stored in the memory 11. When the processor 12 executes the test case range determining program 10 stored in the memory 11, the following steps are implemented:
A1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;A1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
A2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;A2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
A3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;A3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
A4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至A3;及A4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to A3;
A5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。A5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
本实施例中,以系统P为例对本申请的方案进行说明。在系统P部署代码覆盖率工具的客户端,在服务器1端部署代码覆盖率工具的服务器端,例如,Jacoco代码覆盖率工具的客户端及服务器端。具体地,Jacoco代码覆盖 率工具的客户端用于记录用户在系统的实际运行环境下执行某操作行为,及在系统的测试环境下执行测试用例时,系统代码的被覆盖情况;Jacoco代码覆盖率工具的服务器端用于接收Jacoco代码覆盖率工具的客户端记录的系统代码的被覆盖情况。In this embodiment, the solution of the present application is described by taking the system P as an example. On the client side of the system P deployment code coverage tool, deploy the code coverage tool on the server side of the server side, for example, the client and server side of the Jacobo code coverage tool. Specifically, the client of the Jacoco code coverage tool is used to record the user's behavior in the actual operating environment of the system, and the coverage of the system code when executing the test case in the system's test environment; Jacoco code coverage The server side of the tool is used to receive coverage of the system code recorded by the client of the Jacoco Code Coverage Tool.
在对进行版本更新后的系统P进行测试时,需确保测试用例的范围满足测试需求。启动部署在系统P的Jacoco代码覆盖率工具的客户端,对用户在系统的实际运行环境下的操作行为进行监控。其中,操作行为包括:用户点击系统、执行系统的某个功能模块或者执行某些操作流程,Jacoco代码覆盖率工具的客户端会记录下被用户执行的功能模块或者操作流程对应的系统代码,并生成第一代码覆盖数据。Jacoco代码覆盖率工具的客户端将生成的第一代码覆盖数据发送至Jacoco代码覆盖率工具的服务器端,服务器1从Jacoco代码覆盖率工具的服务器端摘取第一代码覆盖数据,并通过服务器1的显示器向测试人员展示,供测试人员针对第一代码覆盖数据进行分析,以初步确定系统P的测试用例范围。可以理解的是,被用户执行过的功能模块或者操作流程,其在系统P中对应的代码都会被覆盖到,反之,未被执行过的功能模块或者操作流程对应的代码则不会被覆盖。具体地,所述第一代码覆盖数据包括:用户在系统P的实际运行环境下执行上述操作行为时,系统P的代码中被覆盖的包、类、方法及行信息。在第一代码覆盖数据收集过程中,计算了对应的包、类、方法的第一覆盖率,以及被覆盖代码的行数占系统P的代码的总行数的第一比例。When testing the system P after the version update, you need to ensure that the scope of the test case meets the test requirements. Start the client deployed in System P's Jacoco Code Coverage Tool to monitor the user's operating behavior in the actual operating environment of the system. The operation behavior includes: the user clicks on the system, executes a certain function module of the system, or performs some operation flow, and the client of the Jacoco code coverage tool records the system code corresponding to the function module or the operation flow executed by the user, and Generate the first code to overwrite the data. The client of the Jacoco Code Coverage Tool sends the generated first code coverage data to the server side of the Jacobo Code Coverage Tool, which extracts the first code coverage data from the server side of the Jacobo Code Coverage Tool and passes the server 1 The display is shown to the tester for the tester to analyze the first code coverage data to initially determine the scope of the test case for System P. It can be understood that the function code or the operation flow executed by the user will be overwritten in the corresponding code in the system P, and the code corresponding to the function module or the operation flow that has not been executed will not be overwritten. Specifically, the first code coverage data includes: a package, a class, a method, and a line information that are covered by the code of the system P when the user performs the foregoing operation behavior in the actual operating environment of the system P. In the first code coverage data collection process, the first coverage of the corresponding package, class, and method, and the first ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
进一步地,服务器1从Jacoco代码覆盖率工具的服务器端摘取出第一代码覆盖数据后,对第一代码覆盖数据中被覆盖的代码进行分析。可以理解的是,系统的功能模块或者操作流程由均代码实现,因此,根据第一代码覆盖数据中被覆盖的代码,可以推导出用户在系统P的实际运行环境下执行了哪些功能模块或者操作流程。根据推导得出的操作流程分别确定各操作流程的场景,并进一步得到对应的测试用例,生成初步确定的测试用例集。例如,对第一代码覆盖数据中的代码数据进行挖掘,发现MD5算法对应的代码被覆盖,sha-1算法对应的代码未被覆盖,那么可以确定用户执行的操作流程中调用了MD5算法,测试人员在设计测试用例时,则需要覆盖MD5算法的调用场景。确定测试用例集为本领域人员习知的技术手段,在此不作累述。Further, after extracting the first code coverage data from the server side of the Jacoco code coverage tool, the server 1 analyzes the overwritten code in the first code coverage data. It can be understood that the function module or the operation flow of the system is implemented by the average code. Therefore, according to the code covered in the first code coverage data, it can be deduced which functional modules or operations are performed by the user in the actual operating environment of the system P. Process. According to the deduced operation flow, the scenarios of each operation flow are respectively determined, and corresponding test cases are further obtained, and a preliminary determined test case set is generated. For example, mining the code data in the first code coverage data, and finding that the code corresponding to the MD5 algorithm is overwritten, and the code corresponding to the sha-1 algorithm is not overwritten, then it can be determined that the MD5 algorithm is invoked in the operation flow executed by the user, and the test is performed. When designing a test case, the person needs to override the calling scenario of the MD5 algorithm. Determining the test case set is a technical means known to those skilled in the art and will not be described here.
接收执行测试用例集的指令,开启部署在系统P的测试环境下的Jacoco代码覆盖率工具的客户端,并在系统P的测试环境下执行上述步骤得到的测试用例集中的测试用例,记录执行测试用例时系统P的代码的被覆盖情况,作为第二代码覆盖数据。具体地,第二代码覆盖数据包括:在系统P的测试环境下执行测试用例时,系统P的代码中被覆盖的包、类、方法及行信息。同样,在第二代码覆盖数据收集过程中,计算了对应的包、类、方法的第二覆盖率,以及被覆盖代码的行数占系统P的代码的总行数的第二比例。Receiving the instruction to execute the test case set, opening the client of the Jacoco code coverage tool deployed in the test environment of the system P, and executing the test case in the test case set obtained by the above steps in the test environment of the system P, recording the execution test In the case of the use case, the code of the system P is covered, and the second code covers the data. Specifically, the second code coverage data includes: a package, a class, a method, and a row information that are covered in the code of the system P when the test case is executed in the test environment of the system P. Similarly, in the second code coverage data collection process, the second coverage of the corresponding package, class, method, and the second ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
需要说明的是,在执行测试用例时,可能出现返回的测试结果与预期结果不一致的情况。在本方案中,强调的是用户的操作行为,重点关注的是用户执行的操作流程,因为输入的具体值本身就存在差异,而且,测试结果对系统代码的被覆盖情况不会有影响,故不会影响第二代码覆盖数据。It should be noted that when the test case is executed, there may be cases where the returned test result is inconsistent with the expected result. In this scheme, the user's operation behavior is emphasized, and the focus is on the operation flow performed by the user, because the specific value of the input itself is different, and the test result does not affect the coverage of the system code, so Does not affect the second code coverage data.
两组代码覆盖数据中被覆盖部分包含多个包,每个包中包括类,类中包括方法,方法中包括代码行。如果某包在两组代码覆盖数据中的覆盖率的差异不满足预设条件,说明该包中包含的类、类中包含的方法、方法中包含的代码行也存在差异,进一步说明初步确定的测试用例集中未覆盖到的、用户在系统P的实际运行环境下执行的操作行为,需进一步完善测试用例。The covered part of the two sets of code coverage data contains multiple packages, each of which includes a class, the method includes a method, and the method includes a code line. If the difference in the coverage of a package in the two sets of code coverage data does not meet the preset conditions, it indicates that there are differences in the classes included in the package, the methods and methods included in the class, and further explains the preliminary determination. The test behaviors that are not covered by the test case set and executed by the user in the actual operating environment of the system P need to further improve the test cases.
具体地,分别读取第一代码覆盖数据中包含的各包在第一代码覆盖数据和第二代码覆盖数据中的覆盖率,计算各包在第一代码覆盖数据和第二代码覆盖数据中的覆盖率的差异度;筛选出差异度小于预设阈值对应的包,确定差异小于预设阈值的该部分包对应的差异代码。其中,差异度的计算公式为:Specifically, the coverage of each packet included in the first code coverage data in the first code coverage data and the second code coverage data is separately read, and each packet is calculated in the first code coverage data and the second code coverage data. The difference degree of the coverage ratio is filtered out, and the difference code corresponding to the preset threshold is filtered out, and the difference code corresponding to the partial packet whose difference is smaller than the preset threshold is determined. Among them, the formula for calculating the difference is:
M=(A-B)/AM=(A-B)/A
其中,M为某包在第一代码覆盖数据中的覆盖率与第二代码覆盖数据中的覆盖率之间的差异度,A为该包在第一代码覆盖数据中的覆盖率,B为该包在第二代码覆盖数据中的覆盖率。Where M is the difference between the coverage of the packet in the first code coverage data and the coverage in the second code coverage data, where A is the coverage of the packet in the first code coverage data, and B is the Coverage coverage in the second code coverage data.
例如,某包在第一代码覆盖数据中的覆盖率为40%,在第二代码覆盖数据中的覆盖率为35%,根据计算公式计算该包在两组代码覆盖数据中的覆盖率的差异度为5%,假设预设阈值为3%,差异度大于预设阈值,则需要进一步确定该包对应的差异代码。进一步对比该包所包含的类的覆盖情况,从该包中筛选出第一覆盖率与第二覆盖率不一致的一个或多个类,并进一步对该一个或多个类所包含的方法的覆盖情况进行分析,对比并挑选出在两组代码 覆盖数据中覆盖率不一致的一个或多个方法,将最终的差异代码具体到代码行。例如,经过上述分析步骤,发现在第一代码覆盖数据中被覆盖的第10行至第20行代码,在第二代码覆盖数据中未被覆盖到,那么,第10行至第20行代码即为两组代码覆盖数据之间的差异代码。For example, the coverage of a packet in the first code coverage data is 40%, and the coverage in the second code coverage data is 35%. The difference in coverage of the packet in the two sets of code coverage data is calculated according to the calculation formula. The degree is 5%. If the preset threshold is 3% and the difference is greater than the preset threshold, the difference code corresponding to the package needs to be further determined. Further comparing the coverage of the class included in the package, filtering one or more classes whose first coverage is inconsistent with the second coverage, and further covering the method included in the one or more classes The situation is analyzed, and one or more methods with inconsistent coverage in the two sets of code coverage data are compared and selected, and the final difference code is specific to the code line. For example, after the above analysis step, it is found that the 10th to 20th lines of codes covered in the first code coverage data are not covered in the second code coverage data, then the 10th to 20th lines of codes are The difference code between the data is overwritten for the two sets of code.
至此,已定位了第一代码覆盖数据及第二代码覆盖数据之间的差异代码。对所述差异代码进行分析,确定差异代码对应的应用场景及操作流程或者功能模块,若已有的测试用例集中包含该应用场景对应的测试用例,则对该测试用例进行调整,若已有的测试用例集中不包含该应用场景对应的测试用例,则新增该应用场景对应的测试用例,并更新初步确定的测试用例集。So far, the difference code between the first code coverage data and the second code coverage data has been located. The difference code is analyzed to determine an application scenario and an operation flow or a function module corresponding to the difference code. If the existing test case set includes the test case corresponding to the application scenario, the test case is adjusted, if the existing If the test case does not contain the test case corresponding to the application scenario, the test case corresponding to the application scenario is added, and the initially determined test case set is updated.
继续接收执行测试用例的指令,从所述更新后的测试用例集中调取并执行新增的或者调整后的测试用例,Jacoco代码覆盖率工具的客户端记录第三代码覆盖数据。作为一种实施方式,利用第三代码覆盖数据对第二代码覆盖数据进行更新得到更新后的第二代码覆盖数据,具体地,从第二代码覆盖数据中抽取未被覆盖的差异代码,且对与第三代码覆盖数据中被覆盖的代码一致的差异代码的覆盖状态进行更新,即,由未被覆盖的状态更新为被覆盖状态。Continue to receive instructions to execute the test case, retrieve and execute the added or adjusted test case from the updated test case set, and the client of the Jacoco code coverage tool records the third code coverage data. As an implementation manner, the second code coverage data is updated by using the third code coverage data to obtain the updated second code coverage data, specifically, the uncovered difference code is extracted from the second code coverage data, and The coverage status of the difference code that coincides with the covered code in the third code coverage data is updated, that is, the status that is not covered is updated to the covered status.
进一步地,获取更新后的第二代码覆盖数据中该包的覆盖率,计算各包在第一代码覆盖数据和第二代码覆盖数据中的覆盖率的差异度,当各包的差异度均小于或等于预设阈值时,说明测试用例不需要再调整,否则,继续执行上述确定差异代码、调整测试用例的步骤。Further, obtaining the coverage ratio of the packet in the updated second code coverage data, and calculating a difference degree of coverage of each packet in the first code coverage data and the second code coverage data, when the difference degree of each packet is smaller than Or equal to the preset threshold, indicating that the test case does not need to be adjusted. Otherwise, continue to perform the above steps of determining the difference code and adjusting the test case.
可以理解的是,第二代码覆盖数据与第一代码覆盖数据之间各包的差异度越小,则测试用例覆盖的范围越接近用户的真实操作情况,测试人员可根据需求调整差异度预设阈值的大小。在其他实施例中,当所述差异度的预设阈值为0时,也就是对第三代码覆盖数据被覆盖的代码与上述差异代码进行对比,当第三代码覆盖数据中被覆盖的代码完全包含上述差异代码,在对第二代码覆盖数据进行更新后,计算得到的第一代码覆盖数据及第二代码覆盖数据的差异度则为0,说明新增或者调整后的测试用例范围已经完全覆盖了上述步骤中未被覆盖的应用场景及操作流程。通过该步骤可使测试用例的范围完全包含用户在系统实际运行环境下的行为,提高测试的准确性。It can be understood that the smaller the difference between the packets of the second code coverage data and the first code coverage data, the closer the coverage of the test case is to the actual operation of the user, and the tester can adjust the difference preset according to the requirement. The size of the threshold. In other embodiments, when the preset threshold of the degree of difference is 0, that is, the code covering the third code coverage data is compared with the difference code, when the code covered in the third code coverage data is completely The difference code is included, and after the second code coverage data is updated, the difference between the calculated first code coverage data and the second code coverage data is 0, indicating that the newly added or adjusted test case range has been completely covered. The application scenario and operation flow that are not covered in the above steps. Through this step, the scope of the test case can completely include the behavior of the user in the actual operating environment of the system, and the accuracy of the test is improved.
上述实施例提出的服务器1,根据用户在系统的运行环境下执行操作行为 得到的第一代码覆盖数据,初步确定测试用例范围,缩小了测试用例的有效,提高测试用例范围确定的效率;并在系统测试环境下执行测试用例得到第二代码覆盖数据,对比两组代码覆盖数据得到差异代码,根据差异代码调整测试用例,确定最终的测试用例范围,使测试用例范围最大限度地接近用户实际的操作行为,提高测试效率。The server 1 proposed by the foregoing embodiment initially determines the scope of the test case according to the first code coverage data obtained by the user performing the operation behavior in the operating environment of the system, reduces the validity of the test case, and improves the efficiency of determining the scope of the test case; The test case is executed in the system test environment to obtain the second code coverage data, and the difference code between the two sets of code coverage data is obtained, the test case is adjusted according to the difference code, and the final test case range is determined, so that the test case range is maximized close to the actual operation of the user. Behavior, improve test efficiency.
可选地,在其他的实施例中,测试用例范围确定程序10还可以被分割为一个或者多个模块,一个或者多个模块被存储于存储器11中,并由一个或多个处理器(本实施例为处理器12)所执行,以完成本申请,本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段。例如,参照图2所示,为图1中测试用例范围确定程序10的程序模块示意图,该实施例中,测试用例范围确定程序10可以被分割为第一记录模块110、第二记录模块120、分析模块130、更新模块140及确定模块150,所述模块110-150所实现的功能或操作步骤均与上文类似,此处不再详述,示例性地,例如其中:Alternatively, in other embodiments, the test case scope determining program 10 may also be divided into one or more modules, one or more modules being stored in the memory 11 and being processed by one or more processors (this Embodiments are executed by processor 12) to accomplish the present application, and a module referred to herein refers to a series of computer program instructions that are capable of performing a particular function. For example, as shown in FIG. 2, it is a schematic diagram of a program module of the test case range determining program 10 in FIG. 1. In this embodiment, the test case range determining program 10 can be divided into a first recording module 110 and a second recording module 120. The analysis module 130, the update module 140, and the determination module 150, the functions or operation steps implemented by the modules 110-150 are similar to the above, and are not described in detail herein, for example, where:
第一记录模块110,用于记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;The first recording module 110 is configured to record first code coverage data when the user performs an operation behavior in a running environment of the system, analyze the first code coverage data to derive a user operation behavior, and initially determine a test case set;
第二记录模块120,用于接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;a second recording module 120, configured to receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
分析模块130,用于对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;The analyzing module 130 is configured to analyze the first code coverage data and the second code coverage data to obtain a difference between the first code coverage data and the second code coverage data, and determine the Whether the difference meets the preset conditions;
更新模块140,用于当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据;及The updating module 140 is configured to: when the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate the first code coverage data and the second code coverage data a difference code between the two, adjusting the test case set according to the difference code, executing the adjusted test case set, and obtaining the updated second code coverage data;
确定模块150,用于当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。The determining module 150 is configured to determine that the test case set is a final test case set when a difference between the first code coverage data and the second code coverage data satisfies a preset condition.
此外,本申请还提供一种人才管理方法。参照图3所示,为本申请人才 管理方法较佳实施例的流程图。该方法可以由一个装置执行,该装置可以由软件和/或硬件实现。In addition, the present application also provides a talent management method. Referring to Figure 3, there is shown a flow chart of a preferred embodiment of the talent management method of the present application. The method can be performed by a device that can be implemented by software and/or hardware.
在本实施例中,人才管理方法包括步骤S1-S5:In this embodiment, the talent management method includes steps S1-S5:
S1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;S1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
S2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;S2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
S3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;S3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
S4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至S3;及S4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to S3;
S5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。S5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
本实施例中,以系统P为例对本申请的方案进行说明。在系统P部署代码覆盖率工具的客户端,在服务器1端部署代码覆盖率工具的服务器端,例如,Jacoco代码覆盖率工具的客户端及服务器端。具体地,Jacoco代码覆盖率工具的客户端用于记录用户在系统的实际运行环境下执行某操作行为,及在系统的测试环境下执行测试用例时,系统代码的被覆盖情况;Jacoco代码覆盖率工具的服务器端用于接收Jacoco代码覆盖率工具的客户端记录的系统代码的被覆盖情况。In this embodiment, the solution of the present application is described by taking the system P as an example. On the client side of the system P deployment code coverage tool, deploy the code coverage tool on the server side of the server side, for example, the client and server side of the Jacobo code coverage tool. Specifically, the client of the Jacoco code coverage tool is used to record the user's behavior in the actual operating environment of the system, and the coverage of the system code when executing the test case in the system's test environment; Jacoco code coverage The server side of the tool is used to receive coverage of the system code recorded by the client of the Jacoco Code Coverage Tool.
在对进行版本更新后的系统P进行测试时,需确保测试用例的范围满足测试需求。启动部署在系统P的Jacoco代码覆盖率工具的客户端,对用户在系统的实际运行环境下的操作行为进行监控。其中,操作行为包括:用户点击系统、执行系统的某个功能模块或者执行某些操作流程,Jacoco代码覆盖率工具的客户端会记录下被用户执行的功能模块或者操作流程对应的系统代码,并生成第一代码覆盖数据。Jacoco代码覆盖率工具的客户端将生成的第一代码覆盖数据发送至Jacoco代码覆盖率工具的服务器端,服务器1从Jacoco 代码覆盖率工具的服务器端摘取第一代码覆盖数据,并通过服务器1的显示器向测试人员展示,供测试人员针对第一代码覆盖数据进行分析,以初步确定系统P的测试用例范围。可以理解的是,被用户执行过的功能模块或者操作流程,其在系统P中对应的代码都会被覆盖到,反之,未被执行过的功能模块或者操作流程对应的代码则不会被覆盖。具体地,所述第一代码覆盖数据包括:用户在系统P的实际运行环境下执行上述操作行为时,系统P的代码中被覆盖的包、类、方法及行信息。在第一代码覆盖数据收集过程中,计算了对应的包、类、方法的第一覆盖率,以及被覆盖代码的行数占系统P的代码的总行数的第一比例。When testing the system P after the version update, you need to ensure that the scope of the test case meets the test requirements. Start the client deployed in System P's Jacoco Code Coverage Tool to monitor the user's operating behavior in the actual operating environment of the system. The operation behavior includes: the user clicks on the system, executes a certain function module of the system, or performs some operation flow, and the client of the Jacoco code coverage tool records the system code corresponding to the function module or the operation flow executed by the user, and Generate the first code to overwrite the data. The client of the Jacoco Code Coverage Tool sends the generated first code coverage data to the server side of the Jacobo Code Coverage Tool, which extracts the first code coverage data from the server side of the Jacobo Code Coverage Tool and passes the server 1 The display is shown to the tester for the tester to analyze the first code coverage data to initially determine the scope of the test case for System P. It can be understood that the function code or the operation flow executed by the user will be overwritten in the corresponding code in the system P, and the code corresponding to the function module or the operation flow that has not been executed will not be overwritten. Specifically, the first code coverage data includes: a package, a class, a method, and a line information that are covered by the code of the system P when the user performs the foregoing operation behavior in the actual operating environment of the system P. In the first code coverage data collection process, the first coverage of the corresponding package, class, and method, and the first ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
可以理解的是,Jacoco代码覆盖率工具的客户端在较短时间内记录用户行为生成的第一代码覆盖数据不一定能完全代表用户在系统P执行的所有功能模块或者操作流程,为了在不浪费资源的前提下,使第一代码覆盖数据更全面,在时间维度上对第一代码覆盖数据进行过滤,设置预设时间区间,例如,开启Jacoco代码覆盖率工具的客户端的时间点之后两天的时间内,取该时间段内的第一代码覆盖数据作为最终的第一代码覆盖数据,并将其发送至Jacoco代码覆盖率工具的服务器端。It can be understood that the first code coverage data generated by the client of the Jacoco code coverage tool in a short time to record the user behavior may not fully represent all the functional modules or operation processes executed by the user in the system P, in order not to waste Under the premise of resources, the first code covers the data more comprehensively, and filters the first code coverage data in the time dimension, and sets a preset time interval, for example, two days after the time point of opening the client of the Jacoco code coverage tool. The first code coverage data for the time period is taken as the final first code coverage data and sent to the server side of the Jacobo Code Coverage Tool.
进一步地,服务器1从Jacoco代码覆盖率工具的服务器端摘取出第一代码覆盖数据后,对第一代码覆盖数据中被覆盖的代码进行分析。可以理解的是,系统的功能模块或者操作流程由均代码实现,因此,根据第一代码覆盖数据中被覆盖的代码,可以推导出用户在系统P的实际运行环境下执行了哪些功能模块或者操作流程。根据推导得出的操作流程分别确定各操作流程的场景,并进一步得到对应的测试用例,生成初步确定的测试用例集。例如,对第一代码覆盖数据中的代码数据进行挖掘,发现MD5算法对应的代码被覆盖,sha-1算法对应的代码未被覆盖,那么可以确定用户执行的操作流程中调用了MD5算法,测试人员在设计测试用例时,则需要覆盖MD5算法的调用场景。确定测试用例集为本领域人员习知的技术手段,在此不作累述。Further, after extracting the first code coverage data from the server side of the Jacoco code coverage tool, the server 1 analyzes the overwritten code in the first code coverage data. It can be understood that the function module or the operation flow of the system is implemented by the average code. Therefore, according to the code covered in the first code coverage data, it can be deduced which functional modules or operations are performed by the user in the actual operating environment of the system P. Process. According to the deduced operation flow, the scenarios of each operation flow are respectively determined, and corresponding test cases are further obtained, and a preliminary determined test case set is generated. For example, mining the code data in the first code coverage data, and finding that the code corresponding to the MD5 algorithm is overwritten, and the code corresponding to the sha-1 algorithm is not overwritten, then it can be determined that the MD5 algorithm is invoked in the operation flow executed by the user, and the test is performed. When designing a test case, the person needs to override the calling scenario of the MD5 algorithm. Determining the test case set is a technical means known to those skilled in the art and will not be described here.
接收执行测试用例集的指令,开启部署在系统P的测试环境下的Jacoco代码覆盖率工具的客户端,并在系统P的测试环境下执行上述步骤得到的测试用例集中的测试用例,记录执行测试用例时系统P的代码的被覆盖情况,作为第二代码覆盖数据。具体地,第二代码覆盖数据包括:在系统P的测试 环境下执行测试用例时,系统P的代码中被覆盖的包、类、方法及行信息。同样,在第二代码覆盖数据收集过程中,计算了对应的包、类、方法的第二覆盖率,以及被覆盖代码的行数占系统P的代码的总行数的第二比例。Receiving the instruction to execute the test case set, opening the client of the Jacoco code coverage tool deployed in the test environment of the system P, and executing the test case in the test case set obtained by the above steps in the test environment of the system P, recording the execution test In the case of the use case, the code of the system P is covered, and the second code covers the data. Specifically, the second code coverage data includes: a package, a class, a method, and a row information that are covered in the code of the system P when the test case is executed in the test environment of the system P. Similarly, in the second code coverage data collection process, the second coverage of the corresponding package, class, method, and the second ratio of the number of lines of the covered code to the total number of lines of the code of the system P are calculated.
需要说明的是,在执行测试用例时,可能出现返回的测试结果与预期结果不一致的情况。在本方案中,强调的是用户的操作行为,重点关注的是用户执行的操作流程,因为输入的具体值本身就存在差异,而且,测试结果对系统代码的被覆盖情况不会有影响,故不会影响第二代码覆盖数据。It should be noted that when the test case is executed, there may be cases where the returned test result is inconsistent with the expected result. In this scheme, the user's operation behavior is emphasized, and the focus is on the operation flow performed by the user, because the specific value of the input itself is different, and the test result does not affect the coverage of the system code, so Does not affect the second code coverage data.
两组代码覆盖数据中被覆盖部分包含多个包,每个包中包括类,类中包括方法,方法中包括代码行。如果某包在两组代码覆盖数据中的覆盖率的差异不满足预设条件,说明该包中包含的类、类中包含的方法、方法中包含的代码行也存在差异,进一步说明初步确定的测试用例集中未覆盖到的、用户在系统P的实际运行环境下执行的操作行为,需进一步完善测试用例。The covered part of the two sets of code coverage data contains multiple packages, each of which includes a class, the method includes a method, and the method includes a code line. If the difference in the coverage of a package in the two sets of code coverage data does not meet the preset conditions, it indicates that there are differences in the classes included in the package, the methods and methods included in the class, and further explains the preliminary determination. The test behaviors that are not covered by the test case set and executed by the user in the actual operating environment of the system P need to further improve the test cases.
具体地,分别读取第一代码覆盖数据中包含的各包在第一代码覆盖数据和第二代码覆盖数据中的覆盖率,计算各包在第一代码覆盖数据和第二代码覆盖数据中的覆盖率的差异度;筛选出差异度小于预设阈值对应的包,确定差异小于预设阈值的该部分包对应的差异代码。其中,差异度的计算公式为:Specifically, the coverage of each packet included in the first code coverage data in the first code coverage data and the second code coverage data is separately read, and each packet is calculated in the first code coverage data and the second code coverage data. The difference degree of the coverage ratio is filtered out, and the difference code corresponding to the preset threshold is filtered out, and the difference code corresponding to the partial packet whose difference is smaller than the preset threshold is determined. Among them, the formula for calculating the difference is:
M=(A-B)/AM=(A-B)/A
其中,M为某包在第一代码覆盖数据中的覆盖率与第二代码覆盖数据中的覆盖率之间的差异度,A为该包在第一代码覆盖数据中的覆盖率,B为该包在第二代码覆盖数据中的覆盖率。Where M is the difference between the coverage of the packet in the first code coverage data and the coverage in the second code coverage data, where A is the coverage of the packet in the first code coverage data, and B is the Coverage coverage in the second code coverage data.
例如,某包在第一代码覆盖数据中的覆盖率为40%,在第二代码覆盖数据中的覆盖率为35%,根据计算公式计算该包在两组代码覆盖数据中的覆盖率的差异度为5%,假设预设阈值为3%,差异度大于预设阈值,则需要进一步确定该包对应的差异代码。进一步对比该包所包含的类的覆盖情况,从该包中筛选出第一覆盖率与第二覆盖率不一致的一个或多个类,并进一步对该一个或多个类所包含的方法的覆盖情况进行分析,对比并挑选出在两组代码覆盖数据中覆盖率不一致的一个或多个方法,将最终的差异代码具体到代码行。例如,经过上述分析步骤,发现在第一代码覆盖数据中被覆盖的第10行至第20行代码,在第二代码覆盖数据中未被覆盖到,那么,第10行至第20行代码即为两组代码覆盖数据之间的差异代码。For example, the coverage of a packet in the first code coverage data is 40%, and the coverage in the second code coverage data is 35%. The difference in coverage of the packet in the two sets of code coverage data is calculated according to the calculation formula. The degree is 5%. If the preset threshold is 3% and the difference is greater than the preset threshold, the difference code corresponding to the package needs to be further determined. Further comparing the coverage of the class included in the package, filtering one or more classes whose first coverage is inconsistent with the second coverage, and further covering the method included in the one or more classes The situation is analyzed, and one or more methods with inconsistent coverage in the two sets of code coverage data are compared and selected, and the final difference code is specific to the code line. For example, after the above analysis step, it is found that the 10th to 20th lines of codes covered in the first code coverage data are not covered in the second code coverage data, then the 10th to 20th lines of codes are The difference code between the data is overwritten for the two sets of code.
至此,已定位了第一代码覆盖数据及第二代码覆盖数据之间的差异代码。对所述差异代码进行分析,确定差异代码对应的应用场景及操作流程或者功能模块,若已有的测试用例集中包含该应用场景对应的测试用例,则对该测试用例进行调整,若已有的测试用例集中不包含该应用场景对应的测试用例,则新增该应用场景对应的测试用例,并更新初步确定的测试用例集。So far, the difference code between the first code coverage data and the second code coverage data has been located. The difference code is analyzed to determine an application scenario and an operation flow or a function module corresponding to the difference code. If the existing test case set includes the test case corresponding to the application scenario, the test case is adjusted, if the existing If the test case does not contain the test case corresponding to the application scenario, the test case corresponding to the application scenario is added, and the initially determined test case set is updated.
继续接收执行测试用例的指令,从所述更新后的测试用例集中调取并执行新增的或者调整后的测试用例,Jacoco代码覆盖率工具的客户端记录第三代码覆盖数据。作为一种实施方式,利用第三代码覆盖数据对第二代码覆盖数据进行更新得到更新后的第二代码覆盖数据,具体地,从第二代码覆盖数据中抽取未被覆盖的差异代码,且对与第三代码覆盖数据中被覆盖的代码一致的差异代码的覆盖状态进行更新,即,由未被覆盖的状态更新为被覆盖状态。Continue to receive instructions to execute the test case, retrieve and execute the added or adjusted test case from the updated test case set, and the client of the Jacoco code coverage tool records the third code coverage data. As an implementation manner, the second code coverage data is updated by using the third code coverage data to obtain the updated second code coverage data, specifically, the uncovered difference code is extracted from the second code coverage data, and The coverage status of the difference code that coincides with the covered code in the third code coverage data is updated, that is, the status that is not covered is updated to the covered status.
进一步地,获取更新后的第二代码覆盖数据中该包的覆盖率,计算各包在第一代码覆盖数据和第二代码覆盖数据中的覆盖率的差异度,当各包的差异度均小于或等于预设阈值时,说明测试用例不需要再调整,否则,继续执行上述确定差异代码、调整测试用例的步骤。Further, obtaining the coverage ratio of the packet in the updated second code coverage data, and calculating a difference degree of coverage of each packet in the first code coverage data and the second code coverage data, when the difference degree of each packet is smaller than Or equal to the preset threshold, indicating that the test case does not need to be adjusted. Otherwise, continue to perform the above steps of determining the difference code and adjusting the test case.
可以理解的是,第二代码覆盖数据与第一代码覆盖数据之间各包的差异度越小,则测试用例覆盖的范围越接近用户的真实操作情况,测试人员可根据需求调整差异度预设阈值的大小。在其他实施例中,当所述差异度的预设阈值为0时,也就是对第三代码覆盖数据被覆盖的代码与上述差异代码进行对比,当第三代码覆盖数据中被覆盖的代码完全包含上述差异代码,在对第二代码覆盖数据进行更新后,计算得到的第一代码覆盖数据及第二代码覆盖数据的差异度则为0,说明新增或者调整后的测试用例范围已经完全覆盖了上述步骤中未被覆盖的应用场景及操作流程。通过该步骤可使测试用例的范围完全包含用户在系统实际运行环境下的行为,提高测试的准确性。It can be understood that the smaller the difference between the packets of the second code coverage data and the first code coverage data, the closer the coverage of the test case is to the actual operation of the user, and the tester can adjust the difference preset according to the requirement. The size of the threshold. In other embodiments, when the preset threshold of the degree of difference is 0, that is, the code covering the third code coverage data is compared with the difference code, when the code covered in the third code coverage data is completely The difference code is included, and after the second code coverage data is updated, the difference between the calculated first code coverage data and the second code coverage data is 0, indicating that the newly added or adjusted test case range has been completely covered. The application scenario and operation flow that are not covered in the above steps. Through this step, the scope of the test case can completely include the behavior of the user in the actual operating environment of the system, and the accuracy of the test is improved.
在其他实施例中,对于第一代码覆盖数据中未被覆盖的系统代码,例如,sha-1算法对应的代码,分析sha-1算法未被调用的原因,若sha-1算法对应的这段代码无可操作场景,或者用户没有执行该类操作,可将sha-1算法对应的未被覆盖的代码作为冗余代码,将其从系统代码中剔除,从而精简系统代码体积。In other embodiments, for the uncovered system code in the first code coverage data, for example, the code corresponding to the sha-1 algorithm, the reason why the sha-1 algorithm is not called is analyzed, if the sha-1 algorithm corresponds to the segment The code has no operational scenarios, or the user does not perform such operations. The uncovered code corresponding to the sha-1 algorithm can be used as redundant code to remove it from the system code, thereby reducing the system code size.
上述实施例提出的测试用例范围确定方法,根据用户在系统的运行环境下执行操作行为得到的第一代码覆盖数据,初步确定测试用例范围,缩小了测试用例的有效,提高测试用例范围确定的效率;并在系统测试环境下执行测试用例得到第二代码覆盖数据,对比两组代码覆盖数据得到差异代码,根据差异代码调整测试用例,确定最终的测试用例范围,使测试用例范围最大限度地接近用户实际的操作行为,提高测试效率。The method for determining the scope of the test case proposed by the above embodiment, according to the first code coverage data obtained by the user in performing the operation behavior in the operating environment of the system, initially determines the scope of the test case, reduces the effectiveness of the test case, and improves the efficiency of determining the scope of the test case. And execute the test case in the system test environment to obtain the second code coverage data, compare the two sets of code coverage data to get the difference code, adjust the test case according to the difference code, determine the final test case range, and make the test case range be as close as possible to the user. The actual operational behavior improves test efficiency.
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有测试用例范围确定程序10,该程序被处理器执行时实现如下操作:In addition, the embodiment of the present application further provides a computer readable storage medium. The computer readable storage medium stores a test case range determining program 10, and when the program is executed by the processor, the following operations are implemented:
A1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;A1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
A2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;A2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
A3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;A3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
A4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至A3;及A4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to A3;
A5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。A5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
本申请计算机可读存储介质具体实施方式与上述测试用例范围确定方法的具体实施方式基本相同,在此不作累述。The specific embodiment of the computer readable storage medium of the present application is substantially the same as the specific embodiment of the method for determining the scope of the test case described above, and is not described herein.
需要说明的是,上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、 装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。It should be noted that the foregoing serial numbers of the embodiments of the present application are merely for the description, and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising", or any other variations thereof are intended to encompass a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a plurality of elements includes not only those elements but also Other elements listed, or elements that are inherent to such a process, device, item, or method. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, the device, the item, or the method that comprises the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM as described above). , a disk, an optical disk, including a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods described in the various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above is only a preferred embodiment of the present application, and is not intended to limit the scope of the patent application, and the equivalent structure or equivalent process transformations made by the specification and the drawings of the present application, or directly or indirectly applied to other related technical fields. The same is included in the scope of patent protection of this application.

Claims (20)

  1. 一种测试用例范围确定方法,应用于电子装置,其特征在于,该方法包括:A test case range determining method is applied to an electronic device, the method comprising:
    S1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;S1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
    S2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;S2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
    S3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;S3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
    S4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至S3;及S4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to S3;
    S5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。S5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
  2. 如权利要求1所述的测试用例范围确定方法,其特征在于,所述步骤S3包括:The test case range determining method according to claim 1, wherein the step S3 comprises:
    分别读取所述第一代码覆盖数据中包含的各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率;Reading, respectively, a coverage ratio of each packet included in the first code coverage data in the first code coverage data and the second code coverage data;
    分别计算各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率的差异度;及Calculating, respectively, a difference in coverage of each packet in the first code coverage data and the second code coverage data; and
    判断所述各包的差异度是否均小于或等于预设阈值。Determining whether the degree of difference of each packet is less than or equal to a preset threshold.
  3. 如权利要求2所述的测试用例范围确定方法,其特征在于,所述“当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码”的步骤包括:The method for determining a test case range according to claim 2, wherein said "when said difference between said first code coverage data and said second code coverage data does not satisfy a preset condition, said determining said The steps of the first code overlay data and the second code overlay data difference code include:
    当所述各包中包含差异度大于预设阈值的一个或多个包时,筛选出所述一个或多个包;When the each package includes one or more packets whose degree of difference is greater than a preset threshold, the one or more packets are filtered out;
    分别对比所述一个或多个包中包含的类在所述第一代码覆盖数据及所述 第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个类;Comparing the coverage of the class included in the one or more packages in the first code coverage data and the second code coverage data, respectively, screening the first code coverage data and the second code Overlay one or more classes with different coverage in the data;
    分别对比所述一个或多个类中包含的方法在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个方法;及Comparing the coverage of the method included in the one or more classes in the first code coverage data and the second code coverage data, respectively, filtering out the first code coverage data and the second code One or more methods that cover different coverage in the data; and
    分别对比所述一个或多个方法中包含的代码行在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的代码行,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码。Comparing the coverage of the code lines included in the one or more methods in the first code coverage data and the second code coverage data, respectively, screening out the first code coverage data and the second The code covers different lines of code in the coverage data, and determines a difference code between the first code coverage data and the second code coverage data.
  4. 如权利要求3所述的测试用例范围确定方法,其特征在于,所述第一代码覆盖数据包括:用户在生产环境下执行所述操作流程,系统代码中被覆盖的包、类、方法及行信息。The method for determining a test case range according to claim 3, wherein the first code coverage data comprises: a user executing the operation flow in a production environment, and a package, a class, a method, and a line covered in the system code. information.
  5. 如权利要求4所述的测试用例范围确定方法,其特征在于,所述第二代码覆盖数据包括:在测试环境下执行所述测试用例集,系统代码中被覆盖的包、类、方法及行信息。The method for determining a test case range according to claim 4, wherein the second code coverage data comprises: executing the test case set in the test environment, the package, class, method, and line covered in the system code. information.
  6. 一种电子装置,其特征在于,该装置包括:存储器、处理器,所述存储器上存储有可在所述处理器上运行的测试用例范围确定程序,该程序被所述处理器执行时实现如下步骤:An electronic device, comprising: a memory, a processor, wherein the memory stores a test case range determining program runable on the processor, and the program is implemented by the processor as follows step:
    A1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;A1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
    A2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;A2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
    A3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;A3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
    A4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至A3;及A4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to A3;
    A5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足 预设条件时,确定所述测试用例集为最终的测试用例集。A5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
  7. 如权利要求6所述的电子装置,其特征在于,所述步骤A3包括:The electronic device of claim 6, wherein the step A3 comprises:
    分别读取所述第一代码覆盖数据中包含的各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率;Reading, respectively, a coverage ratio of each packet included in the first code coverage data in the first code coverage data and the second code coverage data;
    分别计算各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率的差异度;及Calculating, respectively, a difference in coverage of each packet in the first code coverage data and the second code coverage data; and
    判断所述各包的差异度是否均小于或等于预设阈值。Determining whether the degree of difference of each packet is less than or equal to a preset threshold.
  8. 如权利要求7所述的电子装置,其特征在于,所述“当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码”的步骤包括:The electronic device according to claim 7, wherein said "determining said first code when a difference between said first code coverage data and said second code coverage data does not satisfy a preset condition The steps of overlaying the difference code between the data and the second code overlay data include:
    当所述各包中包含差异度大于预设阈值的一个或多个包时,筛选出所述一个或多个包;When the each package includes one or more packets whose degree of difference is greater than a preset threshold, the one or more packets are filtered out;
    分别对比所述一个或多个包中包含的类在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个类;Comparing the coverage of the class included in the one or more packages in the first code coverage data and the second code coverage data, respectively, screening the first code coverage data and the second code Overlay one or more classes with different coverage in the data;
    分别对比所述一个或多个类中包含的方法在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个方法;及Comparing the coverage of the method included in the one or more classes in the first code coverage data and the second code coverage data, respectively, filtering out the first code coverage data and the second code One or more methods that cover different coverage in the data; and
    分别对比所述一个或多个方法中包含的代码行在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的代码行,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码。Comparing the coverage of the code lines included in the one or more methods in the first code coverage data and the second code coverage data, respectively, screening out the first code coverage data and the second The code covers different lines of code in the coverage data, and determines a difference code between the first code coverage data and the second code coverage data.
  9. 如权利要求8所述的电子装置,其特征在于,所述第一代码覆盖数据包括:用户在生产环境下执行所述操作流程,系统代码中被覆盖的包、类、方法及行信息。The electronic device according to claim 8, wherein the first code coverage data comprises: a user executing the operation flow in the production environment, the package, class, method and line information covered in the system code.
  10. 如权利要求9所述的电子装置,其特征在于,所述第二代码覆盖数据包括:在测试环境下执行所述测试用例集,系统代码中被覆盖的包、类、方法及行信息。The electronic device according to claim 9, wherein the second code coverage data comprises: executing the test case set, the package, class, method, and line information covered in the system code in a test environment.
  11. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有测试用例范围确定程序,该程序被所述处理器执行时实现如下步骤:A computer readable storage medium, characterized in that the computer readable storage medium stores a test case range determining program, and when the program is executed by the processor, the following steps are implemented:
    A1、记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;A1. Recording a first code coverage data when the user performs an operation behavior in a system operating environment, analyzing the first code coverage data to derive a user operation behavior, and initially determining a test case set;
    A2、接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;A2. Receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
    A3、对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;A3, analyzing the first code coverage data and the second code coverage data, obtaining a difference between the first code coverage data and the second code coverage data, and determining whether the difference satisfies Set conditions;
    A4、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至A3;及A4. When the difference between the first code coverage data and the second code coverage data does not satisfy a preset condition, locate a difference code between the first code coverage data and the second code coverage data. Adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to A3;
    A5、当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。A5. When the difference between the first code coverage data and the second code coverage data meets a preset condition, determine that the test case set is a final test case set.
  12. 如权利要求11所述的计算机可读存储介质,其特征在于,所述步骤A3包括:The computer readable storage medium of claim 11 wherein said step A3 comprises:
    分别读取所述第一代码覆盖数据中包含的各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率;Reading, respectively, a coverage ratio of each packet included in the first code coverage data in the first code coverage data and the second code coverage data;
    分别计算各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率的差异度;及Calculating, respectively, a difference in coverage of each packet in the first code coverage data and the second code coverage data; and
    判断所述各包的差异度是否均小于或等于预设阈值。Determining whether the degree of difference of each packet is less than or equal to a preset threshold.
  13. 如权利要求12所述的计算机可读存储介质,其特征在于,所述“当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码”的步骤包括:The computer readable storage medium according to claim 12, wherein said "determining said difference when said difference between said first code coverage data and said second code coverage data does not satisfy a preset condition The steps of the first code overlay data and the second code overlay data difference code include:
    当所述各包中包含差异度大于预设阈值的一个或多个包时,筛选出所述一个或多个包;When the each package includes one or more packets whose degree of difference is greater than a preset threshold, the one or more packets are filtered out;
    分别对比所述一个或多个包中包含的类在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个类;Comparing the coverage of the class included in the one or more packages in the first code coverage data and the second code coverage data, respectively, screening the first code coverage data and the second code Overlay one or more classes with different coverage in the data;
    分别对比所述一个或多个类中包含的方法在所述第一代码覆盖数据及所 述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个方法;及Comparing the coverage of the method included in the one or more classes in the first code coverage data and the second code coverage data, respectively, filtering out the first code coverage data and the second code One or more methods that cover different coverage in the data; and
    分别对比所述一个或多个方法中包含的代码行在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的代码行,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码。Comparing the coverage of the code lines included in the one or more methods in the first code coverage data and the second code coverage data, respectively, screening out the first code coverage data and the second The code covers different lines of code in the coverage data, and determines a difference code between the first code coverage data and the second code coverage data.
  14. 如权利要求13所述的计算机可读存储介质,其特征在于,所述第一代码覆盖数据包括:用户在生产环境下执行所述操作流程,系统代码中被覆盖的包、类、方法及行信息。The computer readable storage medium of claim 13, wherein the first code coverage data comprises: a user executing the operation flow in a production environment, a package, a class, a method, and a line covered in the system code information.
  15. 如权利要求14所述的计算机可读存储介质,其特征在于,所述第二代码覆盖数据包括:在测试环境下执行所述测试用例集,系统代码中被覆盖的包、类、方法及行信息。The computer readable storage medium of claim 14, wherein the second code coverage data comprises: executing the test case set in a test environment, the covered packages, classes, methods, and lines in the system code information.
  16. 一种测试用例范围确定程序,其特征在于,该程序包括:A test case scoping program, characterized in that the program comprises:
    第一记录模块,用于记录用户在系统的运行环境下执行操作行为时的第一代码覆盖数据,分析所述第一代码覆盖数据推导出用户的操作行为,并初步确定测试用例集;a first recording module, configured to record first code coverage data when the user performs an operation behavior in a running environment of the system, analyze the first code coverage data to derive a user operation behavior, and initially determine a test case set;
    第二记录模块,用于接收执行所述测试用例集的指令,记录在系统的测试环境下执行所述测试用例集时的第二代码覆盖数据;a second recording module, configured to receive an instruction to execute the test case set, and record second code coverage data when the test case set is executed in a test environment of the system;
    分析模块,用于对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足预设条件;An analysis module, configured to analyze the first code coverage data and the second code coverage data, obtain a difference between the first code coverage data and the second code coverage data, and determine the difference Whether the preset conditions are met;
    更新模块,用于当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,定位所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码,根据所述差异代码调整所述测试用例集,执行所述调整后的测试用例集,得到更新后的第二代码覆盖数据,流程返回至A3;及And an updating module, configured to locate between the first code coverage data and the second code coverage data when a difference between the first code coverage data and the second code coverage data does not satisfy a preset condition a difference code, adjusting the test case set according to the difference code, executing the adjusted test case set, obtaining the updated second code coverage data, and the process returns to A3;
    确定模块,用于当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异满足预设条件时,确定所述测试用例集为最终的测试用例集。And a determining module, configured to determine, when the difference between the first code coverage data and the second code coverage data meets a preset condition, the test case set as a final test case set.
  17. 如权利要求16所述的测试用例范围确定程序,其特征在于,所述“对所述第一代码覆盖数据及所述第二代码覆盖数据进行分析,得到所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异,并判断所述差异是否满足 预设条件”的步骤包括:The test case range determining program according to claim 16, wherein said analyzing said first code coverage data and said second code coverage data to obtain said first code coverage data and said The step of the second code covering the difference between the data and determining whether the difference satisfies the preset condition includes:
    分别读取所述第一代码覆盖数据中包含的各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率;Reading, respectively, a coverage ratio of each packet included in the first code coverage data in the first code coverage data and the second code coverage data;
    分别计算各包在所述第一代码覆盖数据和所述第二代码覆盖数据中的覆盖率的差异度;及Calculating, respectively, a difference in coverage of each packet in the first code coverage data and the second code coverage data; and
    判断所述各包的差异度是否均小于或等于预设阈值。Determining whether the degree of difference of each packet is less than or equal to a preset threshold.
  18. 如权利要求17所述的测试用例范围确定程序,其特征在于,所述“当所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异不满足预设条件时,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码”的步骤包括:The test case range determining program according to claim 17, wherein said "determining said difference when said difference between said first code coverage data and said second code coverage data does not satisfy a preset condition The steps of the first code overlay data and the second code overlay data difference code include:
    当所述各包中包含差异度大于预设阈值的一个或多个包时,筛选出所述一个或多个包;When the each package includes one or more packets whose degree of difference is greater than a preset threshold, the one or more packets are filtered out;
    分别对比所述一个或多个包中包含的类在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个类;Comparing the coverage of the class included in the one or more packages in the first code coverage data and the second code coverage data, respectively, screening the first code coverage data and the second code Overlay one or more classes with different coverage in the data;
    分别对比所述一个或多个类中包含的方法在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的一个或多个方法;及Comparing the coverage of the method included in the one or more classes in the first code coverage data and the second code coverage data, respectively, filtering out the first code coverage data and the second code One or more methods that cover different coverage in the data; and
    分别对比所述一个或多个方法中包含的代码行在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率,筛选出在所述第一代码覆盖数据及所述第二代码覆盖数据中的覆盖率不同的代码行,确定所述第一代码覆盖数据及所述第二代码覆盖数据之间的差异代码。Comparing the coverage of the code lines included in the one or more methods in the first code coverage data and the second code coverage data, respectively, screening out the first code coverage data and the second The code covers different lines of code in the coverage data, and determines a difference code between the first code coverage data and the second code coverage data.
  19. 如权利要求18所述的测试用例范围确定程序,其特征在于,所述第一代码覆盖数据包括:用户在生产环境下执行所述操作流程,系统代码中被覆盖的包、类、方法及行信息。The test case scope determining program according to claim 18, wherein the first code coverage data comprises: a user executing the operation flow in a production environment, and a package, a class, a method, and a line covered in the system code. information.
  20. 如权利要求19所述的测试用例范围确定程序,其特征在于,所述第二代码覆盖数据包括:在测试环境下执行所述测试用例集,系统代码中被覆盖的包、类、方法及行信息。The test case scope determining program according to claim 19, wherein the second code coverage data comprises: executing the test case set in the test environment, the covered packages, classes, methods, and lines in the system code. information.
PCT/CN2018/089318 2018-03-06 2018-05-31 Test case range determining method, device, and storage medium WO2019169760A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810183368.4 2018-03-06
CN201810183368.4A CN108491321B (en) 2018-03-06 2018-03-06 Method and device for determining test case range and storage medium

Publications (1)

Publication Number Publication Date
WO2019169760A1 true WO2019169760A1 (en) 2019-09-12

Family

ID=63341563

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/089318 WO2019169760A1 (en) 2018-03-06 2018-05-31 Test case range determining method, device, and storage medium

Country Status (2)

Country Link
CN (1) CN108491321B (en)
WO (1) WO2019169760A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542761B (en) * 2018-10-11 2022-03-11 平安科技(深圳)有限公司 Software quality evaluation method, device and storage medium
CN109857431B (en) * 2019-01-11 2022-06-03 平安科技(深圳)有限公司 Code modification method and device, computer readable medium and electronic equipment
CN111831535A (en) * 2019-04-17 2020-10-27 北京世纪好未来教育科技有限公司 Code positioning method and device of test case and computer storage medium
CN110413506B (en) * 2019-06-19 2023-02-03 平安普惠企业管理有限公司 Test case recommendation method, device, equipment and storage medium
CN111309635B (en) * 2020-03-26 2023-12-15 北京奇艺世纪科技有限公司 Test case generation method, device, server and storage medium
CN113946511B (en) * 2021-10-15 2022-06-17 杭州研极微电子有限公司 Full-function test case set acquisition method and system
CN115982058B (en) * 2023-03-20 2023-07-07 中国空气动力研究与发展中心计算空气动力研究所 Error positioning method, device, equipment and medium for computational fluid dynamics code

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103309811A (en) * 2013-06-27 2013-09-18 南京大学 Method for quickly positioning software code defects based on test execution record
CN104133771A (en) * 2014-08-13 2014-11-05 五八同城信息技术有限公司 Testing method and device
US20150026664A1 (en) * 2013-07-17 2015-01-22 International Business Machines Corporation Method and system for automated test case selection
US20160291970A1 (en) * 2015-03-31 2016-10-06 Ca, Inc. Effective Defect Management Across Multiple Code Branches
CN106776338A (en) * 2016-12-30 2017-05-31 北京金山安全软件有限公司 Test method, test device and server
US20170371304A1 (en) * 2016-06-27 2017-12-28 Webomates LLC Method and system for determining mapping of test case(s) with code snippets of computer program

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713989B (en) * 2012-09-29 2018-02-02 百度在线网络技术(北京)有限公司 A kind of method for generating test case and device for user terminal
CN105512021A (en) * 2014-09-25 2016-04-20 阿里巴巴集团控股有限公司 Method and device for Diff analysis used for software testing
US9886367B2 (en) * 2015-04-29 2018-02-06 International Business Machines Corporation Unified processing test structure
CN106528399A (en) * 2015-09-15 2017-03-22 腾讯科技(深圳)有限公司 Test case determination method and apparatus

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103309811A (en) * 2013-06-27 2013-09-18 南京大学 Method for quickly positioning software code defects based on test execution record
US20150026664A1 (en) * 2013-07-17 2015-01-22 International Business Machines Corporation Method and system for automated test case selection
CN104133771A (en) * 2014-08-13 2014-11-05 五八同城信息技术有限公司 Testing method and device
US20160291970A1 (en) * 2015-03-31 2016-10-06 Ca, Inc. Effective Defect Management Across Multiple Code Branches
US20170371304A1 (en) * 2016-06-27 2017-12-28 Webomates LLC Method and system for determining mapping of test case(s) with code snippets of computer program
CN106776338A (en) * 2016-12-30 2017-05-31 北京金山安全软件有限公司 Test method, test device and server

Also Published As

Publication number Publication date
CN108491321A (en) 2018-09-04
CN108491321B (en) 2021-05-25

Similar Documents

Publication Publication Date Title
WO2019169760A1 (en) Test case range determining method, device, and storage medium
CN106844217B (en) Method and device for embedding point of applied control and readable storage medium
US20150256552A1 (en) Imalicious code detection apparatus and method
Rathnayaka et al. An efficient approach for advanced malware analysis using memory forensic technique
TW201941058A (en) Anomaly detection method and device
CN110704304B (en) Application program testing method and device, storage medium and server
JP7115552B2 (en) Analysis function imparting device, analysis function imparting method and analysis function imparting program
CN109101815B (en) Malicious software detection method and related equipment
US9317416B2 (en) Merging automated testing reports
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
US9898386B2 (en) Detecting byte ordering type errors in software code
US20140365833A1 (en) Capturing trace information using annotated trace output
CN109271315B (en) Script code detection method, script code detection device, computer equipment and storage medium
CN110554962A (en) Regression testing process covering method, server and computer readable storage medium
TW201220118A (en) A method and a system for automatically analyzing and classifying a malicious program
CN107223257B (en) Test method, test server and test system
US10534700B2 (en) Separating test verifications from test executions
US10365995B2 (en) Composing future application tests including test action data
CN114218110A (en) Account checking test method and device for financial data, computer equipment and storage medium
JP2016099857A (en) Fraudulent program handling system and fraudulent program handling method
CN110287700B (en) iOS application security analysis method and device
CN108090352B (en) Detection system and detection method
CN109067605B (en) Storage subsystem fault diagnosis method and device, terminal and storage medium
CN111090593A (en) Method, device, electronic equipment and storage medium for determining crash attribution
CN108829575B (en) Test case recommendation method, electronic device and readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18909127

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 09.12.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18909127

Country of ref document: EP

Kind code of ref document: A1