CN112395204B - Method, system, related device and medium for obtaining test coverage rate - Google Patents

Method, system, related device and medium for obtaining test coverage rate Download PDF

Info

Publication number
CN112395204B
CN112395204B CN202011398668.8A CN202011398668A CN112395204B CN 112395204 B CN112395204 B CN 112395204B CN 202011398668 A CN202011398668 A CN 202011398668A CN 112395204 B CN112395204 B CN 112395204B
Authority
CN
China
Prior art keywords
application
tested
port
coverage rate
test
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.)
Active
Application number
CN202011398668.8A
Other languages
Chinese (zh)
Other versions
CN112395204A (en
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.)
Jingdong Technology Information Technology Co Ltd
Original Assignee
Jingdong Technology Information 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 Jingdong Technology Information Technology Co Ltd filed Critical Jingdong Technology Information Technology Co Ltd
Priority to CN202011398668.8A priority Critical patent/CN112395204B/en
Publication of CN112395204A publication Critical patent/CN112395204A/en
Application granted granted Critical
Publication of CN112395204B publication Critical patent/CN112395204B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

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 embodiment of the disclosure discloses a method, a device, a system, electronic equipment and a medium for acquiring test coverage rate. One embodiment of the method comprises the following steps: in response to receiving a test coverage rate acquisition request sent by a target end, scanning an application to be tested deployed in a local machine; allocating a corresponding port for the scanned at least one application to be tested; starting the at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request, and executing a test case; acquiring coverage rate files corresponding to the at least one application to be tested; and sending the acquired coverage rate file to the target end through the allocated corresponding port. According to the embodiment, the test coverage rate of a plurality of applications is collected remotely and simultaneously, the complexity of collecting the test coverage rate is reduced, the operation error rate is reduced, and the manpower is saved.

Description

Method, system, related device and medium for obtaining test coverage rate
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method, an apparatus, a system, an electronic device, and a medium for acquiring test coverage.
Background
Test coverage is one of the important metrics for evaluating test integrity. The test coverage rate is divided into a unit test coverage rate and a functional test coverage rate. The functional test coverage rate is used for counting indexes such as a method, a code row, a branch, a class and the like covered by an executed use case by a tester in the test process, and is used as an important reference for improving the test process and measuring the test quality. In the existing test coverage rate collection method, different configuration files are usually set manually for different applications, the applications are started and tested on a server, and then the test coverage rate files of each application are collected by using an API (Application Programming Interface) of an open-source coverage rate tool jacoco or a jenkins plug-in of a third-party tool. Resulting in complex operation and low efficiency.
Disclosure of Invention
The embodiment of the disclosure provides a method, a device, electronic equipment and a medium for acquiring test coverage rate.
In a first aspect, embodiments of the present disclosure provide a method for obtaining test coverage, the method comprising: in response to receiving a test coverage rate acquisition request sent by a target end, scanning an application to be tested deployed in a local machine; allocating a corresponding port for the scanned at least one application to be tested; starting at least one application to be tested according to a test mode indicated by the test coverage rate acquisition request, and executing a test case; acquiring coverage rate files corresponding to at least one application to be tested; and sending the acquired coverage rate file to the target end through the allocated corresponding port.
In a second aspect, embodiments of the present disclosure provide an apparatus for acquiring test coverage, the apparatus comprising: the scanning unit is configured to respond to the receiving of a test coverage rate acquisition request sent by the target end and scan the application to be tested which is deployed in the local machine; an allocation unit configured to allocate respective ports for the scanned at least one application to be tested; the execution unit is configured to start at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request and execute the test case; the acquisition unit is configured to acquire coverage rate files corresponding to at least one application to be tested; and the sending unit is configured to send the acquired coverage rate file to the target end through the allocated corresponding port.
In a third aspect, embodiments of the present disclosure provide a system for obtaining test coverage, the system comprising: the main control end is configured to send a test coverage rate acquisition request to the controlled end; receiving a coverage rate file sent by a controlled terminal; a controlled end configured to implement the method as described in the first aspect.
In a fourth aspect, embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device having one or more programs stored thereon; the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the implementations of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the implementations of the first aspect.
According to the method, the device, the system, the electronic equipment and the medium for acquiring the test coverage rate, which are provided by the embodiment of the disclosure, through remote receiving of the test coverage rate acquisition request, different ports are automatically allocated for different applications to transmit the collected coverage rate files, so that the test coverage rate of a plurality of applications is remotely and simultaneously collected, the complexity of collecting the test coverage rate is reduced, the operation error rate is reduced, and the manpower is saved.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
FIG. 2 is a flow chart of one embodiment of a method for obtaining test coverage according to the present disclosure;
FIG. 3 is a schematic illustration of one application scenario of a method for obtaining test coverage in accordance with an embodiment of the present disclosure;
FIG. 4 is a flow chart of yet another embodiment of a method for obtaining test coverage according to the present disclosure;
FIG. 5 is a schematic structural view of one embodiment of an apparatus for acquiring test coverage according to the present disclosure;
FIG. 6 is a schematic diagram of the architecture of one embodiment of a system for obtaining test coverage according to the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 to which the methods of the present disclosure for obtaining test coverage or apparatus for obtaining test coverage may be applied.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages or the like. Various communication client applications, such as a software test class application, a web browser application, a shopping class application, a search class application, an instant messaging tool, a mailbox client, an image recognition class application, and the like, may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and communicating remotely, including but not limited to smartphones, tablets, laptop and desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. Which may be implemented as multiple software or software modules (e.g., software or software modules for providing distributed services) or as a single software or software module. The present invention is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for software test class applications on the terminal devices 101, 102, 103. The background server can analyze and process the received test coverage rate acquisition request, generate a processing result (such as a coverage rate file), and feed back the generated processing result to the terminal equipment.
The server may be hardware or software. When the server is hardware, the server may be implemented as a distributed server cluster formed by a plurality of servers, or may be implemented as a single server. When the server is software, it may be implemented as a plurality of software or software modules (e.g., software or software modules for providing distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be noted that, the method for acquiring the test coverage provided by the embodiment of the present disclosure is generally performed by the server 105, and accordingly, the device for acquiring the test coverage is generally disposed in the server 105. It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to fig. 2, a flow 200 of one embodiment of a method for obtaining test coverage according to the present disclosure is shown. The method for acquiring the test coverage rate comprises the following steps:
step 201, in response to receiving a test coverage rate acquisition request sent by a target end, scanning an application to be tested deployed in the local machine.
In this embodiment, in response to receiving the test coverage obtaining request sent by the target end, the execution body (such as the server 105 shown in fig. 1) of the method for obtaining the test coverage may scan the application to be tested deployed locally. At least one application to be tested can be deployed in the execution body. The target terminal may be any electronic device that is pre-specified according to actual application requirements, for example, a terminal device used by a tester. The target may also be an electronic device according to rules, for example, a device that passes authentication (such as a device that successfully performs telnet using a username and password).
Step 202, allocating a corresponding port for the scanned at least one application to be tested.
In this embodiment, the executing body may allocate a corresponding port to at least one application to be tested scanned in step 201 in various manners. As an example, the executing body may select an application to be tested from the scanned at least one application to be tested, and select a port from the ports that are not occupied by the executing body as a port allocated to the selected application to be tested. By analogy, the execution subject may assign a corresponding port to each of the scanned at least one application to be tested.
In some optional implementations of this embodiment, the executing entity may allocate a corresponding port to the scanned at least one application to be tested by:
in a first step, the number of scanned applications to be tested is determined as the target number.
In these implementations, the execution body may first determine the number of scanned applications to be tested as the target number. As an example, the execution subject may determine the target number as 5 if the execution subject co-scans to 5 applications to be tested.
And secondly, selecting a target number of unoccupied ports from the local ports.
In these implementations, the executing entity may select the target number of unoccupied ports from the native ports in various ways. As an example, the executing body may first obtain a local port state list. The local port state list may include a correspondence between an identifier of a port and indication information for indicating whether the port is occupied. The execution body may randomly select, from the local port state list, a target number of ports corresponding to indication information for indicating that the ports are unoccupied.
Based on the optional implementation manner, the execution body may call a target number of threads, and select unoccupied ports in parallel from the native ports. Therefore, the time required for determining the idle port can be reduced, and the efficiency of collecting the test coverage rate is improved.
Optionally, the executing body may also select the unoccupied ports in parallel from the local ports through the following steps: for a thread in the target number of threads, acquiring an initial port identification corresponding to the thread, and executing the following port determination steps: determining whether the port indicated by the initial port identification is occupied; responsive to determining that the port indicated by the initial port identification is unoccupied, determining the port as an available port; in response to determining to be occupied, determining the identifier generated after the number corresponding to the initial port identifier is increased by the target number as a new initial port identifier, and continuing to execute the port determination step.
In these implementations, the execution body may obtain the initial port identifier corresponding to the thread in various manners. The initial port identifier may be, for example, first selected by the execution body from a local port identifier list. As an example, the initial port identifiers corresponding to the 5 threads may be 8101, 8102, 8103, 8104, and 8105, respectively. As yet another example, the initial port identifiers corresponding to the 5 threads may be A, B, C, D, E respectively.
As an example, for thread 1, it is first determined whether 8101 port is occupied. In response to determining that the 8101 port is unoccupied, the execution body may determine the 8101 port as an available port. In response to determining that the 8101 port is occupied, the execution body may further determine whether the 8106 (8101+5) port is occupied. As yet another example, in response to determining that port a is occupied, the execution body may further determine whether the port corresponding to number 6 (1+5) (e.g., the F port) is occupied according to the identification a corresponding to number 1. Similarly, for the 2 nd, 3 rd, 4 th, and 5 th threads, it may be determined whether the 8102 port, the 8103 port, the 8104 port, and the 8105 port are occupied, respectively.
Based on the above-mentioned alternative implementation manner, because the ports which need to be determined whether to be occupied by different threads cannot collide, the waste of computing resources and time caused by that a plurality of threads simultaneously determine whether the same port is occupied or not can be avoided, the efficiency of port allocation is improved, and further the efficiency of multi-application test coverage rate file collection is improved.
Thirdly, establishing a corresponding relation between the identification of the selected unoccupied port and the scanned at least one application to be tested.
In these implementations, the executing entity may establish, in various manners, a correspondence between the identification of the selected unoccupied port and the scanned at least one application to be tested. As an example, the executing body may correspond to the scanned sequence of the application to be tested according to the determined sequence of the unoccupied ports, so as to establish the correspondence. As another example, the executing entity may also randomly establish a one-to-one correspondence between the determined identity of the unoccupied port and the scanned at least one application to be tested.
Based on the optional implementation manner, independent ports can be allocated to each application, so that the problem of port occupation conflict during multi-application test coverage rate collection is avoided.
Step 203, starting at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request, and executing the test case.
In this embodiment, the executing body may start the at least one application to be tested according to the test mode indicated by the test coverage rate obtaining request. As an example, the execution subject may launch the application to be tested indicated by the identification of the application to be tested included in the test coverage request.
In some optional implementations of this embodiment, according to the test manner indicated by the test coverage rate obtaining request, the executing body may start at least one application to be tested and execute the test case by:
first, for an application to be tested in at least one application to be tested, modifying a configuration file of the application to be tested through a port corresponding to the application to be tested.
In these implementations, for an application to be tested in the at least one application to be tested, the executing entity may modify the configuration file of the corresponding application to be tested through the port allocated in the step 202. As an example, the configuration file may include a startup script of a java application container in which the application to be tested is deployed.
And secondly, starting the corresponding application according to the configuration file and executing the test case.
In these implementations, the executing body may start the corresponding application according to the configuration file modified in the first step. Then, the execution body may execute a test case corresponding to the started application to test the started application.
Step 204, obtaining coverage rate files corresponding to at least one application to be tested.
In this embodiment, the executing body may obtain, by using various manners, a coverage file corresponding to at least one application to be tested. As an example, the executing body may obtain, through various test coverage file collection tools (for example, jacoco), a coverage file corresponding to the application to be tested corresponding to the test case executed in the step 203. Specifically, the executing body may implant a jacoco plug-in for the corresponding application to be tested through the port allocated in the step 202, so as to collect test coverage data.
And step 205, the acquired coverage rate file is sent to the target end through the allocated corresponding port.
In this embodiment, the executing body may send the acquired coverage rate file to the target end through the corresponding port allocated to each corresponding application to be tested.
With continued reference to fig. 3, fig. 3 is a schematic illustration of an application scenario of a method for obtaining test coverage according to an embodiment of the present disclosure. In the application scenario of fig. 3, a tester 301 uses a terminal device 302 to send a test coverage acquisition request 303 for collecting test coverage files of an application a and an application C to a backend server 304 where the application a and the application C are deployed. The background server 304 then scans the applications to be tested (application a, application B, application C) 305 deployed locally. Then, the backend server 304 allocates ports 8101, 8105, and 8103 for the application a, application B, and application C described above, respectively (as shown at 306 in fig. 3). The background server 304 then launches application a and application C and executes the corresponding test cases (as shown at 307 in fig. 3). Thus, the background server 304 may generate coverage file 3081 for application A and coverage file 3082 for application C. Finally, the background server 304 may send the coverage file 3081 of the application a to the terminal 302 through the assigned 8101 port; the coverage file 3082 of application C is sent to the terminal 302 via the assigned 8103 port.
At present, one of the prior art is to manually set different configuration files for different applications, start the applications on a server and test, and then use the api or jenkins plug-in of jacoco to collect the test coverage rate files of each application. Resulting in complex operation and low efficiency. By means of the method, different ports are automatically allocated for different applications to transmit collected coverage rate files through remote receiving of the test coverage rate acquisition requests, and therefore test coverage rates of multiple applications are collected remotely and simultaneously, complexity of test coverage rate collection is reduced, operation error rate is reduced, and manpower is saved.
With further reference to fig. 4, a flow 400 of yet another embodiment of a method for obtaining test coverage is shown. The process 400 of the method for obtaining test coverage includes the steps of:
in response to receiving the remote connection request, a public key of the sender is extracted from the remote connection request, step 401.
In this embodiment, in response to receiving the remote connection request, an execution subject of the method for acquiring test coverage (e.g., the server 105 in fig. 1) may extract the public key of the transmitting end from the remote connection request.
Step 402, determining whether a public key exists in a preset authorization list.
In this embodiment, the executing body may search the public key extracted in the step 401 from a locally stored preset authorization list, and determine whether the public key exists in the preset authorization list.
Step 403, in response to determining that the public key exists in the preset authorization list, performing identity verification on the sender.
In this embodiment, in response to determining that the public key exists in the preset authorization list, the executing body may perform authentication on the transmitting end. The authentication may include various ways, among others. As an example, the execution body may transmit, to the transmitting end, encrypted information in which original information is encrypted by a public key of the transmitting end. And comparing the decryption information returned by the sending end and aiming at the encryption information with the original information. In response to determining agreement, the executing entity may determine that the sender passes the identity authentication.
Step 404, in response to determining that the sender passes the authentication, establishing a connection with the sender.
In this embodiment, in response to determining that the sender passes the authentication in step 403, the executing entity may establish a connection with the sender.
And step 405, in response to receiving the test coverage rate acquisition request sent by the sending end, scanning the application to be tested deployed in the local machine.
In this embodiment, in response to receiving the test coverage rate obtaining request sent by the sending end, the executing body may scan an application to be tested deployed in the executing body.
It should be noted that, the executing entity may determine the sending end passing through the authentication as the target end as described in the foregoing embodiment.
Step 406, allocating a corresponding port for the scanned at least one application to be tested.
Step 407, starting at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request, and executing the test case.
Step 408, obtaining at least one coverage rate file corresponding to the application to be tested.
And 409, sending the obtained coverage rate file to the target end through the allocated corresponding port.
The steps 405 to 409 are identical to the steps 201 to 205 in the foregoing embodiments, and the descriptions of the steps 201 to 205 and the optional implementation manner thereof also apply to the steps 405 to 409, which are not repeated herein.
As can be seen from fig. 4, the flow 400 of the method for obtaining test coverage in this embodiment represents the step of determining whether to connect with the information sender according to the extracted public key and authentication. Therefore, the solution described in this embodiment may log in the server where the application to be tested is deployed in a remote password-free manner. Compared with the existing mode that user name passwords and the like are adopted and authentication is required each time, the method is more efficient on the premise that safety is guaranteed when a plurality of applications and the like are tested and need to be operated frequently.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of an apparatus for obtaining test coverage, which corresponds to the method embodiment shown in fig. 2 or fig. 4, and which is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus 500 for acquiring a test coverage provided in the present embodiment includes a scanning unit 501, an allocation unit 502, an execution unit 503, an acquisition unit 504, and a transmission unit 505. The scanning unit 501 is configured to respond to a test coverage rate acquisition request sent by a target end, and scan an application to be tested deployed on the local machine; an allocation unit 502 configured to allocate respective ports for the scanned at least one application to be tested; an execution unit 503 configured to start at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request, and execute a test case; an obtaining unit 504, configured to obtain coverage files corresponding to at least one application to be tested; and a transmitting unit 505 configured to transmit the acquired coverage file to the target terminal through the allocated corresponding port.
In the present embodiment, in the apparatus 500 for acquiring a test coverage: the specific processes of the scanning unit 501, the allocation unit 502, the executing unit 503, the acquiring unit 504, and the sending unit 505 and the technical effects thereof may refer to the descriptions related to step 201, step 202, step 203, step 204, and step 205 in the corresponding embodiments of fig. 2, and are not repeated herein.
In some optional implementations of this embodiment, the scanning unit 501 may include an extraction module (not shown in the figure), a first determination module (not shown in the figure), a verification module (not shown in the figure), a connection module (not shown in the figure), and a scanning module (not shown in the figure). Wherein the extracting module may be configured to extract the public key of the sender from the remote connection request in response to receiving the remote connection request. The first determining module may be configured to determine whether a public key exists in a preset authorization list. The verification module may be configured to perform identity verification on the sender in response to determining that the public key exists in the preset authorization list. The connection module may be configured to establish a connection with the sender in response to determining that the sender is authenticated. The scanning module may be configured to scan an application to be tested deployed locally in response to receiving a test coverage acquisition request sent by the sender.
In some alternative implementations of the present embodiment, the allocation unit 502 may include a second determining module (not shown in the figure), a selecting module (not shown in the figure), and a relationship establishing module (not shown in the figure), where the second determining module may be configured to determine the number of scanned applications to be tested as the target number.
In some optional implementations of this embodiment, the selecting module may be further configured to: and calling a target number of threads, and selecting unoccupied ports from the native ports in parallel.
In some optional implementations of this embodiment, the selecting module may be further configured to: for a thread in the target number of threads, acquiring an initial port identification corresponding to the thread, and executing the following port determination steps: determining whether the port indicated by the initial port identification is occupied; responsive to determining that the port indicated by the initial port identification is unoccupied, determining the port as an available port; in response to determining to be occupied, determining the identification generated after the number corresponding to the initial port identification is increased by the target number as a new initial port identification, and continuing to perform the port determination step.
In some alternative implementations of the present embodiment, the execution unit 503 may include a modification module (not shown in the figure) and an execution module (not shown in the figure). Wherein the modification module may be configured to: and for an application to be tested in at least one application to be tested, modifying the configuration file of the application to be tested through a port corresponding to the application to be tested. The execution module may be configured to: and starting the corresponding application according to the configuration file, and executing the test case.
The device provided in the foregoing embodiment of the present disclosure allocates different ports for the application to be tested scanned by the scanning unit 501 through the allocation unit 502, and sends, through the sending unit 505, the coverage file generated by the test collected by the obtaining unit 504 to the master terminal via the allocated ports. Therefore, the test coverage rate of a plurality of applications is collected remotely and simultaneously, the complexity of collecting the test coverage rate is reduced, the operation error rate is reduced, and the manpower is saved.
With further reference to FIG. 6, a timing 600 of interactions between various devices in one embodiment of a method for obtaining test coverage is shown. The system for obtaining test coverage may include: a master (e.g., terminal devices 101, 102, 103 shown in fig. 1), and a slave (e.g., server 105 shown in fig. 1). The master control terminal may be configured to send a test coverage rate acquisition request to the controlled terminal; and receiving the coverage rate file sent by the controlled terminal. The controlled end may be configured to implement the method for obtaining test coverage as described in the embodiment of fig. 2.
In some optional implementations of this embodiment, the master may be further configured to: a remote connection request is sent to a controlled terminal; and (5) performing identity verification. The controlled end may be configured to implement the method for obtaining test coverage as described in the foregoing embodiment of fig. 4.
As shown in fig. 6, in step 601, the master end sends a test coverage rate acquisition request to the slave end.
In this embodiment, the master control terminal may include an electronic device, such as a user terminal, for initiating a remote connection. The test coverage rate acquisition request may include an identifier for indicating an application for which the acquired test coverage rate is intended.
In some optional implementations of this embodiment, the step 601 may specifically include the following steps:
in step 6011, the master control end sends a remote connection request to the slave control end.
In step 6012, in response to receiving the remote connection request, the controlled terminal extracts the public key of the master terminal from the remote connection request.
In step 6013, the controlled end determines whether the public key exists in the preset authorization list.
Step 6014, in response to determining that the public key exists in the preset authorization list, performing identity verification on the master control terminal.
Step 6015, the master control end performs identity verification.
In step 6016, in response to determining that the master passes the authentication, a connection with the master is established.
In step 6017, in response to receiving the test coverage rate obtaining request sent by the master control end, the controlled end scans the application to be tested deployed in the local machine.
Based on the optional implementation manner, the scheme can log in the server deployed with the application to be tested in a remote secret-free mode. Compared with the existing mode that user name passwords and the like are adopted and authentication is required each time, the method is more efficient on the premise that safety is guaranteed when a plurality of applications and the like are tested and need to be operated frequently.
In step 602, in response to receiving a test coverage rate acquisition request sent by the target end, the controlled end scans an application to be tested deployed locally.
In step 603, the controlled end allocates a corresponding port for the scanned at least one application to be tested.
In step 604, according to the test mode indicated by the test coverage rate obtaining request, the controlled end starts at least one application to be tested, and executes the test case.
In step 605, the controlled end obtains at least one coverage file corresponding to the application to be tested.
In step 606, the controlled end sends the obtained coverage rate file to the master end through the assigned corresponding port
In step 607, the master receives the coverage file sent by the slave.
The steps 602 to 606 are identical to the steps 201 to 205 and the optional implementation manners thereof in the foregoing embodiments, and the descriptions of the steps 201 to 205 and the optional implementation manners thereof also apply to the steps 602 to 606, which are not repeated herein.
According to the system for acquiring the test coverage rate, which is provided by the embodiment of the application, the main control end sends the test coverage rate acquisition request to the remotely logged controlled end, and the controlled end automatically distributes different ports for different applications to transmit the collected coverage rate files by remotely receiving the test coverage rate acquisition request, so that the test coverage rate of a plurality of applications can be collected remotely and simultaneously, the complexity of collecting the test coverage rate is reduced, the operation error rate is reduced, and the manpower is saved.
Referring now to fig. 7, a schematic diagram of an electronic device (e.g., server in fig. 1) 700 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, etc., and a fixed terminal such as a digital TV, a desktop computer, etc. The server illustrated in fig. 7 is merely an example, and should not be construed as limiting the functionality and scope of use of the embodiments of the present disclosure in any way.
As shown in fig. 7, the electronic device 700 may include a processing means (e.g., a central processor, a graphics processor, etc.) 701, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage means 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
In general, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 707 including, for example, a liquid crystal display (LCD, liquid Crystal Display), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 shows an electronic device 700 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 7 may represent one device or a plurality of devices as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 709, or installed from storage 708, or installed from ROM 702. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 701.
It should be noted that, the computer readable medium according to the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having 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. In an embodiment of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Whereas in embodiments of the present disclosure, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (Radio Frequency), and the like, or any suitable combination thereof.
The computer-readable medium may be contained in the electronic device (server or terminal device); or may exist alone without being incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the server to: in response to receiving a test coverage rate acquisition request sent by a target end, scanning an application to be tested deployed in a local machine; allocating a corresponding port for the scanned at least one application to be tested; starting at least one application to be tested according to a test mode indicated by the test coverage rate acquisition request, and executing a test case; acquiring coverage rate files corresponding to at least one application to be tested; and sending the acquired coverage rate file to the target end through the allocated corresponding port.
Computer program code for carrying out operations of embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments described in the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor comprises a scanning unit, an allocation unit, an execution unit, an acquisition unit and a transmission unit. The names of these units do not constitute a limitation on the unit itself in some cases, and for example, the scanning unit may also be described as "in response to receiving a test coverage acquisition request sent by the target end, scan a unit of an application to be tested deployed locally".
The above description is of the preferred embodiments of the present disclosure only
And to an illustration of the technical principles employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.

Claims (13)

1. A method for obtaining test coverage, comprising:
in response to receiving a test coverage rate acquisition request sent by a target end, scanning an application to be tested deployed in a local machine, including: responding to a received remote connection request, and extracting a public key of a transmitting end from the remote connection request; determining whether the public key exists in a preset authorization list; in response to determining that the public key exists in the preset authorization list, carrying out identity verification on the sending end; establishing a connection with the sender in response to determining that the sender passes the authentication; in response to receiving a test coverage rate acquisition request sent by the sending end, scanning an application to be tested deployed in the local machine;
Allocating a corresponding port for the scanned at least one application to be tested;
starting the at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request, and executing a test case;
acquiring coverage rate files corresponding to the at least one application to be tested;
and sending the acquired coverage rate file to the target end through the allocated corresponding port.
2. The method of claim 1, wherein the assigning the scanned at least one application to be tested with the corresponding port comprises:
determining the number of scanned applications to be tested as a target number;
selecting the target number of unoccupied ports from the local ports;
and establishing a corresponding relation between the identification of the selected unoccupied port and the scanned at least one application to be tested.
3. The method of claim 2, wherein the selecting the target number of unoccupied ports from the local ports comprises:
and calling the target number of threads, and selecting unoccupied ports from the native ports in parallel.
4. A method according to claim 3, wherein said selecting unoccupied ports in parallel from said native ports comprises:
For a thread in the target number of threads, acquiring an initial port identification corresponding to the thread, and executing the following port determining steps: determining whether the port indicated by the initial port identification is occupied; responsive to determining that it is unoccupied, determining a port indicated by the initial port identification as an available port; and in response to determining to be occupied, determining the identifier generated after the number corresponding to the initial port identifier is increased by the target number as a new initial port identifier, and continuing to execute the port determination step.
5. The method according to one of claims 2-4, wherein the launching the at least one application to be tested in the test manner indicated by the test coverage acquisition request, and executing a test case, comprises:
for an application to be tested in the at least one application to be tested, modifying a configuration file of the application to be tested through a port corresponding to the application to be tested;
and starting the corresponding application according to the configuration file, and executing the test case.
6. An apparatus for acquiring test coverage, comprising:
the scanning unit is configured to respond to receiving a test coverage rate acquisition request sent by a target end, scans an application to be tested deployed on the local machine, and comprises the following steps: responding to a received remote connection request, and extracting a public key of a transmitting end from the remote connection request; determining whether the public key exists in a preset authorization list; in response to determining that the public key exists in the preset authorization list, carrying out identity verification on the sending end; establishing a connection with the sender in response to determining that the sender passes the authentication; in response to receiving a test coverage rate acquisition request sent by the sending end, scanning an application to be tested deployed in the local machine;
An allocation unit configured to allocate respective ports for the scanned at least one application to be tested;
the execution unit is configured to start the at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request and execute a test case;
the acquisition unit is configured to acquire coverage rate files corresponding to the at least one application to be tested;
and the sending unit is configured to send the acquired coverage rate file to the target end through the allocated corresponding port.
7. A system for acquiring test coverage, comprising:
the main control end is configured to send a test coverage rate acquisition request to the controlled end; receiving a coverage rate file sent by the controlled terminal;
the controlled end is configured to: in response to receiving a test coverage rate acquisition request sent by a target end, scanning an application to be tested deployed in a local machine, including: responding to a received remote connection request, and extracting a public key of a transmitting end from the remote connection request; determining whether the public key exists in a preset authorization list; in response to determining that the public key exists in the preset authorization list, carrying out identity verification on the sending end; establishing a connection with the sender in response to determining that the sender passes the authentication; in response to receiving a test coverage rate acquisition request sent by the sending end, scanning an application to be tested deployed in the local machine; allocating a corresponding port for the scanned at least one application to be tested; starting the at least one application to be tested according to the test mode indicated by the test coverage rate acquisition request, and executing a test case; acquiring coverage rate files corresponding to the at least one application to be tested; and sending the acquired coverage rate file to the target end through the allocated corresponding port.
8. The system of claim 7, wherein the controlled end is further configured to: determining the number of scanned applications to be tested as a target number; selecting the target number of unoccupied ports from a local port identification list; and establishing a corresponding relation between the identification of the selected unoccupied port and the scanned at least one application to be tested.
9. The system of claim 8, wherein the controlled end is further configured to: and calling the target number of threads, and selecting unoccupied ports in parallel from the local port identification list.
10. The system of claim 9, wherein the controlled end is further configured to: for a thread in the target number of threads, acquiring an initial port identification corresponding to the thread, and executing the following port determining steps: determining whether the port indicated by the initial port identification is occupied; responsive to determining that it is unoccupied, determining a port indicated by the initial port identification as an available port; and in response to determining to be occupied, determining the identifier generated after the number corresponding to the initial port identifier is increased by the target number as a new initial port identifier, and continuing to execute the port determination step.
11. The system of one of claims 8-10, wherein the controlled end is further configured to: for an application to be tested in the at least one application to be tested, modifying a configuration file of the application to be tested through a port corresponding to the application to be tested; and starting the corresponding application according to the configuration file, and executing the test case.
12. A server, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
13. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-5.
CN202011398668.8A 2020-12-04 2020-12-04 Method, system, related device and medium for obtaining test coverage rate Active CN112395204B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011398668.8A CN112395204B (en) 2020-12-04 2020-12-04 Method, system, related device and medium for obtaining test coverage rate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011398668.8A CN112395204B (en) 2020-12-04 2020-12-04 Method, system, related device and medium for obtaining test coverage rate

Publications (2)

Publication Number Publication Date
CN112395204A CN112395204A (en) 2021-02-23
CN112395204B true CN112395204B (en) 2024-04-16

Family

ID=74604236

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011398668.8A Active CN112395204B (en) 2020-12-04 2020-12-04 Method, system, related device and medium for obtaining test coverage rate

Country Status (1)

Country Link
CN (1) CN112395204B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360411A (en) * 2021-07-19 2021-09-07 中国工商银行股份有限公司 Code coverage rate detection method and device based on parallel variation test

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105404585A (en) * 2015-12-01 2016-03-16 腾讯科技(深圳)有限公司 Method and apparatus for acquiring code coverage rate
CN107015906A (en) * 2016-06-23 2017-08-04 阿里巴巴集团控股有限公司 Method of testing and device, port generation method and port maker and test system
CN109542775A (en) * 2018-11-05 2019-03-29 广州云测信息技术有限公司 A kind of generation and execution method and device of test script
CN111104333A (en) * 2019-12-20 2020-05-05 广州品唯软件有限公司 Coverage rate test method, test device and computer readable storage medium
CN111831530A (en) * 2019-04-15 2020-10-27 北京字节跳动网络技术有限公司 Test method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8543873B2 (en) * 2010-01-06 2013-09-24 Silicon Image, Inc. Multi-site testing of computer memory devices and serial IO ports
WO2015147690A1 (en) * 2014-03-28 2015-10-01 Oracle International Corporation System and method for determination of code coverage for software applications in a network environment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105404585A (en) * 2015-12-01 2016-03-16 腾讯科技(深圳)有限公司 Method and apparatus for acquiring code coverage rate
CN107015906A (en) * 2016-06-23 2017-08-04 阿里巴巴集团控股有限公司 Method of testing and device, port generation method and port maker and test system
CN109542775A (en) * 2018-11-05 2019-03-29 广州云测信息技术有限公司 A kind of generation and execution method and device of test script
CN111831530A (en) * 2019-04-15 2020-10-27 北京字节跳动网络技术有限公司 Test method and device
CN111104333A (en) * 2019-12-20 2020-05-05 广州品唯软件有限公司 Coverage rate test method, test device and computer readable storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
一种嵌入式软件逻辑覆盖测试方法研究;肖永健;刘永恒;徐军;;计算机测量与控制(第04期);全文 *
基于覆盖率验证方法的IP核测试平台设计;黄颖然;中国优秀硕士学位论文全文数据库 信息科技辑(第01期);全文 *

Also Published As

Publication number Publication date
CN112395204A (en) 2021-02-23

Similar Documents

Publication Publication Date Title
CN109995877B (en) Information pushing method and device
CN107623690B (en) Login method, device and storage medium
US20140136851A1 (en) Biometric-based wireless device association
CN111666539B (en) Real estate resource management method, device, server and storage medium
CN110430292B (en) Method and device for inviting login of network platform, electronic equipment and readable medium
CN113630253A (en) Login method, device, computer system and readable storage medium
CN109828830B (en) Method and apparatus for managing containers
CN112395204B (en) Method, system, related device and medium for obtaining test coverage rate
CN109218338B (en) Information processing system, method and device
CN113285843A (en) Container network configuration method and device, computer readable medium and electronic equipment
CN113032805A (en) Data access method and device, electronic equipment and storage medium
CN110602700B (en) Seed key processing method and device and electronic equipment
CN109145591B (en) Plug-in loading method of application program
CN111030900A (en) Authentication-free login method and device and electronic equipment
US20220086169A1 (en) Automatic mobile device management (mdm) enrollment
CN108696557B (en) Information processing system, method and device
CN111092949B (en) Method and device for registering equipment
CN115098840A (en) Identity authentication method, device, equipment, medium and product
CN109450887B (en) Data transmission method, device and system
CN109412931B (en) Method, device and terminal equipment for performing knowledge question answering by using instant messaging mode
CN108804713B (en) Image output method, electronic device, and computer-readable medium
CN108471635B (en) Method and apparatus for connecting wireless access points
CN111831530A (en) Test method and device
CN111786936A (en) Method and device for authentication
CN110941805A (en) Identity authentication method and device

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
CB02 Change of applicant information

Address after: 100176 601, 6th floor, building 2, No. 18, Kechuang 11th Street, Daxing Economic and Technological Development Zone, Beijing

Applicant after: Jingdong Technology Information Technology Co.,Ltd.

Address before: 100176 601, 6th floor, building 2, No. 18, Kechuang 11th Street, Daxing Economic and Technological Development Zone, Beijing

Applicant before: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant