CN112685298A - Code coverage testing method and device for application program and electronic equipment - Google Patents

Code coverage testing method and device for application program and electronic equipment Download PDF

Info

Publication number
CN112685298A
CN112685298A CN202011568395.7A CN202011568395A CN112685298A CN 112685298 A CN112685298 A CN 112685298A CN 202011568395 A CN202011568395 A CN 202011568395A CN 112685298 A CN112685298 A CN 112685298A
Authority
CN
China
Prior art keywords
sub
service function
thread
code coverage
coverage information
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202011568395.7A
Other languages
Chinese (zh)
Inventor
张璐鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202011568395.7A priority Critical patent/CN112685298A/en
Publication of CN112685298A publication Critical patent/CN112685298A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses a code coverage testing method and device of an application program, electronic equipment, a storage medium and a program product, and relates to the fields of information flow and big data in the technical field of computers. The specific implementation scheme is as follows: monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of an application program to be tested, the application program to be tested has a plurality of sub-service functions, each sub-service function indicated by the test request is tested respectively to obtain code coverage information of each sub-service function, the code coverage information of the application program to be tested is determined according to the code coverage information of each sub-service function, the code coverage information corresponding to each sub-service function is obtained by testing each sub-service function, the flexibility and diversity of code testing can be achieved, and the accuracy of the code coverage information of any determined sub-service function is achieved.

Description

Code coverage testing method and device for application program and electronic equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code coverage testing method and apparatus for an application program, an electronic device, a storage medium, and a program product, which are applicable to the fields of information flow and big data.
Background
With the development of internet and computer technologies, the technology related to application testing has new breakthroughs, and Code Coverage information, such as Code Coverage (Code Coverage), is a measure in application testing.
In the prior art, code coverage information is usually obtained by instrumentation, compiling and executing a code to be tested based on a golang tool chain, however, the code coverage information obtained based on the method is mixed coverage information, and in order to obtain code coverage information corresponding to different sub-service functions of an application program, completion is usually performed on the basis of the mixed coverage information.
However, the above method may cause a problem that the reliability and the comprehensiveness of the completion are low.
Disclosure of Invention
The application provides a code coverage testing method and device for an application program for improving code coverage information for determining sub-service functions, an electronic device, a storage medium and a program product.
According to an aspect of the present application, there is provided a code coverage testing method for an application program, including:
monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of an application program to be tested, and the application program to be tested has a plurality of sub-service functions;
respectively testing each sub-service function indicated by the test request to obtain code coverage information of each sub-service function;
and determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
According to another aspect of the present application, there is provided a code coverage testing apparatus for an application program, including:
the monitoring module is used for monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of an application program to be tested, and the application program to be tested has a plurality of sub-service functions;
the test module is used for respectively testing each sub-service function indicated by the test request to obtain code coverage information of each sub-service function;
and the first determining module is used for determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
According to another aspect of the present application, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the above embodiments.
According to another aspect of the present application, there is provided a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of the above embodiment.
According to another aspect of the application, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method according to the above embodiments.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present application, nor do they limit the scope of the present application. Other features of the present application will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not intended to limit the present application. Wherein:
FIG. 1 is a schematic diagram according to a first embodiment of the present application;
FIG. 2 is a schematic diagram according to a second embodiment of the present application;
FIG. 3 is a schematic illustration according to a third embodiment of the present application;
FIG. 4 is a schematic illustration according to a fourth embodiment of the present application;
FIG. 5 is a schematic illustration according to a fifth embodiment of the present application;
FIG. 6 is a schematic illustration according to a sixth embodiment of the present application;
FIG. 7 is a schematic illustration according to a seventh embodiment of the present application;
FIG. 8 is a schematic illustration according to an eighth embodiment of the present application;
fig. 9 is a schematic diagram of a ninth embodiment according to the present application.
Detailed Description
The following description of the exemplary embodiments of the present application, taken in conjunction with the accompanying drawings, includes various details of the embodiments of the application for the understanding of the same, which are to be considered exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
With the development of the internet and computer technology, the number of application programs is rapidly increasing, and the application programs are written based on codes, thereby realizing corresponding application services, such as communication services, shopping services, accommodation services, travel services, and the like.
In order to improve the reliable operation of the application program, the application program can be tested after the application program is written based on the code, and the code coverage information, such as the code coverage rate, is a measure in the application program test.
Wherein the code coverage characterizes the proportion and extent to which code in the application is tested. For example, when an application is tested, the running code is m lines, and the code coverage rate is m/n.
Correspondingly, if the code coverage rate is larger, the utilization rate of the codes in the application program is higher; if the code coverage rate is smaller, the utilization rate of the code in the application program is lower. If the utilization rate is low, the redundancy degree of the codes in the application program is high, the codes can be adaptively adjusted, and the utilization rate of the code resources is improved.
It should be noted that the application may include a plurality of sub-service functions, such as for communication applications, which may include: and a sub-service function and a session sub-service function for acquiring the address book information. That is, different sub-service functions for an application are implemented based on code corresponding thereto.
In the related art, when a code coverage test is performed on an application, all codes of the application are usually tested to obtain mixed coverage information, and when code coverage information of a certain sub-service function needs to be obtained, completion needs to be performed on the basis of the mixed coverage information.
For example, communication applications include: the method comprises the steps of obtaining sub-service functions and session sub-service functions of address book information, and when code coverage test is carried out on a communication application program, testing all codes of the communication application program, namely the tested codes comprise: acquiring codes of sub-service functions of address list information and codes of session sub-service functions, wherein the obtained code coverage information comprises: and if the code coverage information of the sub-service function of the address book information needs to be determined, corresponding processing, such as completion and the like, needs to be carried out on the basis of the relaxation coverage information, so as to obtain the code coverage information of the sub-service function of the address book information.
However, the code coverage information obtained by a complementary method or the like may cause a problem that the accuracy and reliability of the code coverage information are low.
The inventor of the application obtains the inventive concept of the application through creative work: and monitoring the test request, and testing each sub-service function of the application program to obtain code coverage information corresponding to each sub-service function.
Based on the inventive concept, the application provides a code coverage testing method, device, electronic device, storage medium and program product for an application program, which are applied to the fields of information flow and big data in the technical field of computers, so as to achieve the accuracy and reliability of code coverage information corresponding to each sub-service function.
Fig. 1 is a schematic diagram according to a first embodiment of the present application, and as shown in fig. 1, the method for testing code coverage of an application program of the present embodiment includes:
s101: monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of the application program to be tested, and the application program to be tested has a plurality of sub-service functions.
For example, the execution subject of this embodiment may be a code coverage testing apparatus (hereinafter, simply referred to as a testing apparatus) of an application program, and the testing apparatus may be a computer, a server (including a local server and a cloud server), a terminal device, a processor, a chip, and the like, which is not limited in this embodiment.
Based on the above example, the application to be tested may include a plurality of sub-service functions, such as a sub-service function for obtaining address book information, a session sub-service function, a data sub-service function, and a sub-service function for accessing a database. Correspondingly, the test request may be used to request a sub-service function of the application to be tested, for example, the test request may be used to test the sub-service function of obtaining the address book information; the test request may also be used to request to test multiple sub-service functions of the application to be tested, for example, the test request may be used to test the sub-service function that obtains the address book information and test the session sub-service function.
S102: and respectively testing each sub-service function indicated by the test request to obtain the code coverage information of each sub-service function.
In one example, if the test request indicates to test one sub-service function, the testing apparatus tests the one sub-service function to obtain the code coverage information of the one sub-service function.
In another example, if the test request indicates to test the sub-service functions, the testing apparatus tests each of the sub-service functions to obtain code coverage information corresponding to each of the sub-service functions.
It should be noted that, in this embodiment, after the test request is received, each sub-service function indicated by the test request is tested, so as to obtain the code coverage information of each sub-service function, thereby accurately and reliably determining the code coverage information of each sub-service function, and thus implementing adaptive adjustment and modification of the code of each service function based on the code coverage information of each sub-service function, thereby implementing the technical effects of improving the code utilization rate and improving the operating efficiency of the application program to be tested.
S103: and determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
After the testing device determines the code coverage information of each sub-service function, the testing device may determine the code coverage information of the application to be tested based on the code coverage information.
Based on the above analysis, an embodiment of the present application provides a code coverage testing method for an application program, where the method includes: monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of an application program to be tested, the application program to be tested has a plurality of sub-service functions, each sub-service function indicated by the test request is tested respectively to obtain code coverage information of each sub-service function, determining code coverage information of the application program to be tested according to the code coverage information of each sub-service function, respectively testing each sub-service function indicated by the test request to obtain code coverage information corresponding to each sub-service function, the accuracy and reliability of the determined code coverage information of each sub-service function can be improved, and determining the code coverage information of the application program to be tested based on the code coverage information corresponding to each sub-service function, the technical effect of reliability of the code coverage information of the determined application program to be tested can be improved.
Fig. 2 is a schematic diagram of a second embodiment of the present application, and as shown in fig. 2, the method for testing code coverage of an application program of the present embodiment includes:
s201: monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of the application program to be tested, and the application program to be tested has a plurality of sub-service functions.
For example, the description about S201 may refer to S101, which is not described herein again.
In some embodiments, the test request may be snooped by way of a Reverse Proxy (Reverse Proxy).
The reverse proxy approach employed by the present embodiment will now be exemplarily described with reference to the application scenario shown in fig. 3. In the application scenario as shown in fig. 3:
a client 301 (such as a desktop computer shown in fig. 3, but the client may also be another user terminal, such as a laptop computer and a mobile terminal, etc.) is connected to a reverse proxy server 303 through an internet (internet)302, and the user 304 may send a test request to a server 305 on an internal network through the client 302 and the reverse proxy server 303.
Among other things, proxy server 303 may listen for test requests sent by user 304 over internet 302 to server 305 on the internal network based on client 302.
That is, in some embodiments, the test device may include: the proxy server monitors the test request by the proxy server and the servers on the internal network.
Accordingly, as can be seen from the above example, the execution subject of the present embodiment may include a plurality of servers, such as the proxy server shown in fig. 3 and the servers on the internal network, and the proxy server monitors the test request and the servers on the internal network execute the test of the corresponding sub-service function.
It should be noted that the above examples are only used for exemplary illustration, and the application scenarios to which the present embodiment may be applied are not to be construed as limitations on the application scenarios of the present embodiment.
S202: from the plurality of threads for executing the test request, a thread corresponding to execution of each sub-service function is determined.
For example, in connection with the above example, if the application to be tested includes: and acquiring the sub-service function and the session sub-service function of the address book information, wherein the test device determines a thread for executing the sub-service function of acquiring the address book information from a plurality of threads, and determines a thread for executing the session sub-service function from the plurality of threads, and the thread for executing the sub-service function of acquiring the address book information and the thread for executing the session sub-service function are two different threads.
It should be noted that, in this embodiment, the number of threads for executing the test request is multiple, each thread has an independent memory space, the threads having the independent memory spaces are isolated from each other, and the threads do not interfere with each other when executing the sub-service functions corresponding to each thread, so that the technical effect of accuracy and reliability of the code coverage information of each sub-service function obtained when executing each sub-service function based on the thread corresponding to each sub-service function is achieved.
In some embodiments, S202 may include: and selecting and executing the thread corresponding to each sub-service function from the threads based on a preset scheduling period.
For example, the scheduling cycle may be understood as a scheduling frequency for each thread, which may be a frequency in time or a frequency in times. For example, the frequency in time can be understood as: scheduling each thread on the basis of time, such as calling a certain thread at preset time intervals; as another example, the frequency in times can be understood as: after each thread is called once, the thread is called, and the like.
Specifically, the testing apparatus may sort the scheduling order of each thread in advance, and sequentially select a thread corresponding to each sub-service function from the threads based on the sorting.
In some embodiments, the testing apparatus may test the operation performance of each thread in advance, and determine the scheduling cycle based on the operation performance of each thread, that is, determine the order in which each thread is scheduled.
For example, for a thread with better running performance, the testing device preferentially selects the thread; on the contrary, for the thread with poor running performance, the testing device selects the thread with poor running performance after selecting the thread with good running performance.
That is, the threads may be sorted based on the running performance of the threads, and if the threads are arranged in an ascending order based on the running performance, the testing device selects the threads from the end of the arrangement in sequence when selecting the threads; if the order is descending order based on the operation performance, the testing device selects the threads from the head end of the order when selecting the threads.
In this embodiment, a thread corresponding to each sub-service function is selected from the threads based on the scheduling period, so that a technical effect of fast and convenient calling of the thread can be achieved.
In some embodiments, when the test request is not monitored, the states of the threads are sleep states, and based on a preset scheduling cycle, a thread corresponding to each sub-service function is selected from the threads, including: and awakening the thread executing each sub-service function from the threads based on the scheduling period, and executing each sub-service function based on the awakened thread.
For example, the testing apparatus may be provided with a scheduler and a plurality of threads, and the scheduler may implement the call to the plurality of threads. For example, a scheduler may be understood as a parent thread and multiple threads may be understood as multiple child threads, with calls to the multiple child threads being completed based on the parent thread.
And in some embodiments, the invoking of the thread may be implemented in a unix socket (unix socket) based manner, such as the multithreading may be pooled into a thread pool, similar to the concept of a buffer in an operating system, and the corresponding thread is awakened and invoked by the test apparatus from the thread pool based on the scheduling cycle.
In this embodiment, the states of the threads may include two types, one type is a sleep state and one type is an awake state, and the initial state of each thread may be the sleep state, for example, each thread is in the sleep state before being called, that is, when the test apparatus does not monitor the test request and has no application program to be tested, each thread is in the sleep state, and when the test apparatus monitors the test request, the test apparatus may wake up the thread that executes each sub-service function from each thread in each sleep state based on the scheduling cycle, so as to execute each sub-service function based on the woken-up thread.
For example, with reference to the above example, if the number of threads is n, where n is a positive integer greater than 1, before the testing device does not monitor the application program to be tested, the n threads are all in a sleep state, and if the testing device monitors the application program to be tested, the application program to be tested includes: and acquiring the sub-service function and the session sub-service function of the address book information, the test device wakes up the thread for executing the sub-service function of acquiring the address book information from the n threads based on the scheduling cycle, and executes the sub-service function of acquiring the address book information based on the woken-up thread, and wakes up the thread for executing the session sub-service function from (n-1) sleeping threads (excluding the thread for executing the sub-service function of acquiring the address book information), and executes the session sub-service function based on the woken-up thread.
It should be noted that, in this embodiment, when the test device does not monitor the test request, each thread is in a sleep state, and when the test request is monitored, at least part of the threads in the sleep state are woken up, so that at least part of the threads in the sleep state are in a woken-up state, thereby completing feedback of the test request and achieving a technical effect of saving resources.
In some embodiments, after each sub-service function is executed based on a thread that wakes up, the test device may adjust the state of the thread that wakes up to a sleep state.
For example, in connection with the above example, if the testing apparatus executes the sub-service function for acquiring the address book information based on the woken thread, the state of the thread is adjusted from the woken state to the sleep state.
It should be noted that, in this embodiment, after the thread that is wakened up executes the corresponding sub-service function, the state of the thread that is wakened up is switched from the wakening state to the sleeping state, so that the technical effects of reducing resource consumption and realizing resource utilization rate can be achieved.
In some embodiments, if each thread is in the awake state, the method may further include: and determining the load capacity of each thread, selecting the thread with the minimum load capacity from the threads, and determining the thread as the thread executing each sub-service function.
For example, with reference to the above example, if the number of threads is n, and the n threads are all in an awake state, that is, the n threads are all executing corresponding sub-service functions, the test device may determine a load amount of each thread of the n threads, obtain n load amounts, select a minimum load amount from the n load amounts, determine a thread corresponding to the minimum load amount, and determine the thread corresponding to the minimum load amount as the thread executing each sub-service function.
In some embodiments, if the number of the minimum load capacity is multiple, that is, the load capacities of the multiple threads are the same, the testing device may randomly select a thread corresponding to the minimum load capacity, and determine the thread corresponding to the randomly selected minimum load capacity as the thread executing each sub-service function; alternatively, the testing apparatus may select a thread with the best operation performance from the threads corresponding to the minimum load amounts based on the historical operation performance of the threads corresponding to the minimum load amounts, and execute each sub-service function based on the thread with the best operation performance.
It should be noted that, in this embodiment, the thread with the smallest load amount is selected from the threads, and the thread that executes each sub-service function is determined, so that the resource utilization rate can be improved, and the running performance of each thread is optimized.
S203: and testing each sub-service function based on the thread corresponding to each sub-service function to obtain code coverage information corresponding to each sub-server function.
For example, with reference to the above example, based on the thread corresponding to the sub-service function for acquiring the address book information, the sub-service function for acquiring the address book information is tested, and the code coverage information corresponding to the sub-service function for acquiring the address book information is obtained.
Illustratively, the acquisition of the code coverage information corresponding to each sub-service function can be realized in a way of inserting piles in code sequences. For example, some probes (also called "detectors") are inserted into codes corresponding to sub-service functions for acquiring address book information, which are essentially code segments for information acquisition, and may be assignment statements or function calls for acquiring coverage information, and feature data of code operation is thrown out through execution of the probes, and through analysis of the data, control flow and data flow information of the codes can be obtained, and further, code coverage information, such as code coverage rate, can be obtained.
S204: and determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
For example, the description about S204 may refer to S103, which is not described again here.
Fig. 4 is a schematic diagram of a fourth embodiment of the present application, and as shown in fig. 4, the method for testing code coverage of an application program of the present embodiment includes:
s401: monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of the application program to be tested, and the application program to be tested has a plurality of sub-service functions.
For example, the description about S401 may refer to S101, which is not described again here.
S402: and determining a thread corresponding to the execution of each sub-service function from the threads for executing the test request, and determining the association relationship between each sub-service function and the corresponding thread.
In one example, the test apparatus may split the test request into a plurality of sub-test requests based on the sub-service function, and for different sub-test requests, the test apparatus may put a characteristic value in each sub-test request, where the characteristic value may be understood as a unique identifier of each test request for distinguishing different sub-test requests.
For example, the test request is a test request for an application program to be tested, where the application program to be tested includes a plurality of sub-service functions, and the test apparatus may split the application program to be tested based on each sub-service function to obtain a sub-test request corresponding to each sub-service function, and put a feature value used for distinguishing from other sub-test requests in each sub-test request.
It should be noted that the feature value of the sub-test request may be related to the sub-service function of the sub-test request, or may be a randomly allocated feature value, which is not limited in this embodiment.
Accordingly, the testing device may determine a respective thread for each sub-test request, such that each test request, i.e. each sub-service function, is executed based on the determined respective thread.
In another example, the test apparatus may split the test request into a plurality of sub-test requests based on the sub-service function, and for different sub-test requests, the association relationship between the sub-test requests and the threads may be recorded.
Illustratively, the testing device assigns a thread to each sub-test request, and determines the association relationship between the sub-test request and the thread. For example, the sub-test requests and the threads may be assigned the same identifier, so that when the threads feed back the code coverage information, the sub-test requests with the same identifier may be determined based on the identifier of the threads, and the code coverage information may be determined as the code coverage information of the sub-test requests with the same identifier, so as to determine the code coverage information corresponding to the sub-service functions.
Of course, each sub-service function and the thread corresponding to the sub-service function may be assigned the same identifier, so as to determine the code coverage information corresponding to each sub-service function based on the same identifier.
It should be noted that, in combination with the above example, the test request monitored by the test apparatus may also be a test request corresponding to one sub-service function, and accordingly, the test apparatus may monitor test requests corresponding to a plurality of sub-service functions, that is, the test request monitored by the test apparatus is multiple, and each test request in the multiple test requests is a code coverage test for one sub-service function, and then the test apparatus may also determine code coverage information corresponding to each test request, that is, determine code coverage information of each sub-service function, based on the manner in the above example.
In other embodiments, the test request heard by the testing apparatus may be a test of a plurality of sub-service functions, such as an application to be tested including: if the test request may be a test indicating the sub-service function for obtaining the address book information and the sub-service function for the session, the testing apparatus may select a thread for the test request and determine code coverage information of the test request, that is, determine code coverage information of the sub-service function for obtaining the address book information and the sub-service function for the session.
S403: and testing each sub-service function based on the thread corresponding to each sub-service function to obtain code coverage information corresponding to each sub-service function.
In connection with the above example, this step can be understood as: the testing device executes each sub-test request based on the thread corresponding to each sub-test request, thereby completing the test of each sub-service function and obtaining the code coverage information corresponding to each sub-service function.
S404: and determining a mapping relation according to the code coverage information of each sub-service function, wherein the mapping relation represents the mapping relation between different sub-service functions and different code coverage information.
For example, in combination with the above example, there is an association relationship between each sub-service function and the corresponding thread, when the testing apparatus receives the code coverage information fed back by the thread, the sub-service function corresponding to the received code coverage information may be determined based on the association relationship, and a mapping relationship between the sub-service function and the code coverage information may be established.
For another example, when the thread executes the corresponding sub-test request to obtain the corresponding code coverage information, the corresponding feature value may be put into the code coverage information, and the testing apparatus may determine the corresponding sub-test request based on the feature value in the code coverage information, and determine the corresponding sub-service function, thereby establishing the mapping relationship between the sub-service function and the code coverage information.
In some embodiments, the code of the application under test may be adjusted based on the mapping.
It should be noted that, in this embodiment, by determining the mapping relationship between each sub-service function and the corresponding code coverage information, the codes corresponding to at least part of the sub-service functions may be adjusted based on the mapping relationship, so as to delete redundant codes, reduce the running time of the application program to be tested, and improve the technical effect of reliability of the application program to be tested.
S405: and determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
For example, the description about S405 may refer to S103, which is not described again here.
Fig. 5 is a schematic diagram of a fifth embodiment of the present application, and as shown in fig. 5, the code coverage testing apparatus 500 of the application program of the present embodiment includes:
the monitoring module 501 is configured to monitor a test request, where the test request is used to request to test at least one sub-service function of an application program to be tested, and the application program to be tested has multiple sub-service functions.
The testing module 502 is configured to test each sub-service function indicated by the test request, so as to obtain code coverage information of each sub-service function.
The first determining module 503 is configured to determine code coverage information of the application to be tested according to the code coverage information of each sub-service function.
Fig. 6 is a schematic diagram according to a sixth embodiment of the present application, and as shown in fig. 6, on the basis of the fifth embodiment, the number of threads for executing a test request is multiple, and the test module 502 includes:
the thread determining submodule 5021 is configured to determine a thread corresponding to each sub-service function.
The testing sub-module 5022 is configured to test each sub-service function based on the thread corresponding to each sub-service function, and obtain code coverage information corresponding to each sub-service function.
In some embodiments, the thread determining submodule is configured to select, from the threads, a thread corresponding to each sub-service function to be executed based on a preset scheduling cycle.
In some embodiments, when no test request is monitored, the state of each thread is a sleep state; the thread determination submodule 5021 is configured to wake up a thread that performs each sub-service function from among threads based on a scheduling period, and perform each sub-service function based on the woken-up thread.
Fig. 7 is a schematic diagram of a seventh embodiment according to the present application, and as shown in fig. 7, on the basis of the sixth embodiment, the test module further includes:
the adjusting module 5023 is configured to adjust the state of the woken thread to a sleep state after the woken thread executes each sub-service function.
In some embodiments, each thread is in an awake state, the thread determining submodule 5021 is configured to determine a load amount of each thread, select a thread with the smallest load amount from the threads, and determine the thread as a thread for executing each sub-service function.
Fig. 8 is a schematic diagram of an eighth embodiment of the present application, and as shown in fig. 8, on the basis of the seventh embodiment, a code coverage testing apparatus 500 further includes:
a second determining module 504, configured to determine a mapping relationship according to the code coverage information of each sub-service function, where the mapping relationship represents a mapping relationship between different sub-service functions and different code coverage information.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
FIG. 9 illustrates a schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 9, the electronic apparatus 900 includes a computing unit 901, which can perform various appropriate actions and processes in accordance with a computer program stored in a Read Only Memory (ROM)902 or a computer program loaded from a storage unit 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The calculation unit 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
A number of components in the device 900 are connected to the I/O interface 905, including: an input unit 906 such as a keyboard, a mouse, and the like; an output unit 907 such as various types of displays, speakers, and the like; a storage unit 908 such as a magnetic disk, optical disk, or the like; and a communication unit 909 such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 909 allows the device 900 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
The computing unit 901 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 901 performs the respective methods and processes described above, such as a code coverage test method of an application program. For example, in some embodiments, the code coverage testing method of the application program may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 900 via ROM 902 and/or communications unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the code coverage testing method of the application program described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute the code coverage test method of the application program by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The Server can be a cloud Server, also called a cloud computing Server or a cloud host, and is a host product in a cloud computing service system, so as to solve the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service ("Virtual Private Server", or simply "VPS"). The server may also be a server of a distributed system, or a server incorporating a blockchain.
According to another aspect of embodiments of the present application, there is also provided a computer program product including a computer program which, when executed by a processor, implements a method according to any of the above embodiments, such as the method shown in any of fig. 1, fig. 2 and fig. 4 when executed.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present application may be executed in parallel, sequentially, or in different orders, and the present invention is not limited thereto as long as the desired results of the technical solutions disclosed in the present application can be achieved.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (17)

1. A code coverage testing method of an application program comprises the following steps:
monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of an application program to be tested, and the application program to be tested has a plurality of sub-service functions;
respectively testing each sub-service function indicated by the test request to obtain code coverage information of each sub-service function;
and determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
2. The method of claim 1, wherein the number of threads for executing test requests is plural; respectively testing each sub-service function indicated by the test request to obtain code coverage information of each sub-service function, including:
determining a thread corresponding to the execution of each sub-service function;
and testing each sub-service function based on the thread corresponding to each sub-service function to obtain code coverage information corresponding to each sub-service function.
3. The method of claim 2, wherein determining the thread corresponding to the execution of each sub-service function comprises:
and selecting the thread corresponding to each sub-service function from the threads based on a preset scheduling period.
4. The method of claim 3, wherein the state of each thread is a sleep state when no test request is monitored; based on a preset scheduling cycle, selecting a thread corresponding to each sub-service function from the threads, including:
and based on the scheduling cycle, awakening the thread executing each sub-service function from the threads, and executing each sub-service function based on the awakened thread.
5. The method of claim 4, wherein the thread executing each sub-service function is woken up from the threads based on the scheduling period, and after the thread executing each sub-service function is woken up, the method further comprises:
after the awakened thread executes each sub-service function, the state of the awakened thread is adjusted to a sleep state.
6. The method of claim 4, if each thread is in an awake state, further comprising:
and determining the load capacity of each thread, selecting the thread with the minimum load capacity from the threads, and determining the thread as the thread executing each sub-service function.
7. The method according to any one of claims 1 to 6, further comprising, after testing each sub-service function indicated by the test request respectively to obtain code coverage information of each sub-service function:
and determining a mapping relation according to the code coverage information of each sub-service function, wherein the mapping relation represents the mapping relation between different sub-service functions and different code coverage information.
8. A code coverage testing apparatus of an application program, comprising:
the monitoring module is used for monitoring a test request, wherein the test request is used for requesting to test at least one sub-service function of an application program to be tested, and the application program to be tested has a plurality of sub-service functions;
the test module is used for respectively testing each sub-service function indicated by the test request to obtain code coverage information of each sub-service function;
and the first determining module is used for determining the code coverage information of the application program to be tested according to the code coverage information of each sub-service function.
9. The apparatus of claim 8, wherein the number of threads for executing test requests is plural; the test module includes:
the thread determining submodule is used for determining the thread corresponding to each sub-service function;
and the testing sub-module is used for testing each sub-service function based on the thread corresponding to each sub-service function to obtain code coverage information corresponding to each sub-service function.
10. The apparatus according to claim 9, wherein the thread determining submodule is configured to select, from the threads, a thread corresponding to each sub-service function to be executed based on a preset scheduling cycle.
11. The apparatus of claim 10, wherein the state of each thread is a sleep state when no test request is monitored; the thread determining submodule is used for awakening the thread for executing each sub-service function from each thread based on the scheduling cycle and executing each sub-service function based on the awakened thread.
12. The apparatus of claim 11, wherein the test module further comprises:
and the adjusting module is used for adjusting the state of the awakened thread to be in a sleep state after the awakened thread executes each sub-service function.
13. The apparatus according to claim 11, wherein if each thread is in an awake state, the thread determining submodule is configured to determine a load of each thread, select a thread with a smallest load from the threads, and determine the thread as the thread executing each sub-service function.
14. The apparatus of any of claims 8 to 13, further comprising:
and the second determining module is used for determining a mapping relation according to the code coverage information of each sub-service function, wherein the mapping relation represents the mapping relation between different sub-service functions and different code coverage information.
15. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-7.
17. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-7.
CN202011568395.7A 2020-12-25 2020-12-25 Code coverage testing method and device for application program and electronic equipment Pending CN112685298A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011568395.7A CN112685298A (en) 2020-12-25 2020-12-25 Code coverage testing method and device for application program and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011568395.7A CN112685298A (en) 2020-12-25 2020-12-25 Code coverage testing method and device for application program and electronic equipment

Publications (1)

Publication Number Publication Date
CN112685298A true CN112685298A (en) 2021-04-20

Family

ID=75451997

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011568395.7A Pending CN112685298A (en) 2020-12-25 2020-12-25 Code coverage testing method and device for application program and electronic equipment

Country Status (1)

Country Link
CN (1) CN112685298A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326190A (en) * 2021-05-27 2021-08-31 北京百度网讯科技有限公司 Method and device for determining code coverage rate and electronic equipment
CN113360411A (en) * 2021-07-19 2021-09-07 中国工商银行股份有限公司 Code coverage rate detection method and device based on parallel variation test
CN113778690A (en) * 2021-09-27 2021-12-10 杭州安恒信息技术股份有限公司 Task allocation method, device, equipment and storage medium
CN114900569A (en) * 2022-05-17 2022-08-12 中国银行股份有限公司 Method and device for acquiring test script
CN117424843A (en) * 2023-12-18 2024-01-19 北京华峰测控技术股份有限公司 Management method, management device and ATE test system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103095518A (en) * 2011-11-08 2013-05-08 阿里巴巴集团控股有限公司 Coverage rate test processing method and device and coverage rate test server and system
CN109684221A (en) * 2018-12-27 2019-04-26 江苏满运软件科技有限公司 Test code coverage acquisition method, system, equipment and medium
CN110245073A (en) * 2019-05-21 2019-09-17 北京字节跳动网络技术有限公司 Client code coverage rate monitoring method, system, medium and electronic equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103095518A (en) * 2011-11-08 2013-05-08 阿里巴巴集团控股有限公司 Coverage rate test processing method and device and coverage rate test server and system
CN109684221A (en) * 2018-12-27 2019-04-26 江苏满运软件科技有限公司 Test code coverage acquisition method, system, equipment and medium
CN110245073A (en) * 2019-05-21 2019-09-17 北京字节跳动网络技术有限公司 Client code coverage rate monitoring method, system, medium and electronic equipment

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326190A (en) * 2021-05-27 2021-08-31 北京百度网讯科技有限公司 Method and device for determining code coverage rate and electronic equipment
CN113360411A (en) * 2021-07-19 2021-09-07 中国工商银行股份有限公司 Code coverage rate detection method and device based on parallel variation test
CN113778690A (en) * 2021-09-27 2021-12-10 杭州安恒信息技术股份有限公司 Task allocation method, device, equipment and storage medium
CN113778690B (en) * 2021-09-27 2024-03-22 杭州安恒信息技术股份有限公司 Task allocation method, device, equipment and storage medium
CN114900569A (en) * 2022-05-17 2022-08-12 中国银行股份有限公司 Method and device for acquiring test script
CN114900569B (en) * 2022-05-17 2024-05-03 中国银行股份有限公司 Test script acquisition method and device
CN117424843A (en) * 2023-12-18 2024-01-19 北京华峰测控技术股份有限公司 Management method, management device and ATE test system
CN117424843B (en) * 2023-12-18 2024-02-13 北京华峰测控技术股份有限公司 Management method, management device and ATE test system

Similar Documents

Publication Publication Date Title
CN112685298A (en) Code coverage testing method and device for application program and electronic equipment
CN111694646A (en) Resource scheduling method and device, electronic equipment and computer readable storage medium
CN106874100B (en) Computing resource allocation method and device
CN113114504B (en) Method, apparatus, device, medium and product for allocating resources
US20230128085A1 (en) Data aggregation processing apparatus and method, and storage medium
CN114936173B (en) Read-write method, device, equipment and storage medium of eMMC device
CN115658311A (en) Resource scheduling method, device, equipment and medium
CN114742000A (en) SoC chip verification system, verification method and device based on FPGA cluster
CN111782502A (en) Automatic testing method and device
CN114116173A (en) Method, device and system for dynamically adjusting task allocation
CN113986497A (en) Queue scheduling method, device and system based on multi-tenant technology
CN107634978B (en) Resource scheduling method and device
CN112860401A (en) Task scheduling method and device, electronic equipment and storage medium
CN115373860B (en) Scheduling method, device and equipment of GPU (graphics processing Unit) tasks and storage medium
CN116661960A (en) Batch task processing method, device, equipment and storage medium
CN115509931A (en) System-based performance test method and device, electronic equipment and storage medium
CN104468337A (en) Message transmission method and device, message management center device and data centers
CN114265692A (en) Service scheduling method, device, equipment and storage medium
CN113535020A (en) Method, apparatus, device, medium and product for generating application icons
CN113971083A (en) Task scheduling method, device, equipment, medium and product
CN113641688A (en) Node updating method, related device and computer program product
CN114598705B (en) Message load balancing method, device, equipment and medium
CN113220555B (en) Method, apparatus, device, medium, and article for processing data
CN110888741A (en) Resource scheduling method and device for application container, server and storage medium
US11782490B2 (en) Software-defined fail-safe power draw control for rack power distribution units

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination