CN111831549B - Incremental code coverage rate determining method, device, equipment and storage medium - Google Patents

Incremental code coverage rate determining method, device, equipment and storage medium Download PDF

Info

Publication number
CN111831549B
CN111831549B CN202010499277.9A CN202010499277A CN111831549B CN 111831549 B CN111831549 B CN 111831549B CN 202010499277 A CN202010499277 A CN 202010499277A CN 111831549 B CN111831549 B CN 111831549B
Authority
CN
China
Prior art keywords
test
code
incremental
requirement
tracking identifier
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
CN202010499277.9A
Other languages
Chinese (zh)
Other versions
CN111831549A (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.)
Shenzhen Handhui Technology Group Co ltd
Original Assignee
Shenzhen Handhui Technology Group 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 Shenzhen Handhui Technology Group Co ltd filed Critical Shenzhen Handhui Technology Group Co ltd
Priority to CN202010499277.9A priority Critical patent/CN111831549B/en
Publication of CN111831549A publication Critical patent/CN111831549A/en
Application granted granted Critical
Publication of CN111831549B publication Critical patent/CN111831549B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software

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 application is applicable to the technical field of computers, and provides a method, a device, equipment and a storage medium for determining incremental code coverage rate. The method comprises the steps of responding to received test requirements respectively sent by a plurality of test terminals, generating a corresponding tracking identifier for each test requirement and sending the tracking identifier to the corresponding test terminal; responding to the received test operation instructions respectively sent by the plurality of test terminals, and generating a test operation code corresponding to each test operation instruction; determining a global incremental code for each test requirement based on the version information of each test requirement; and determining the incremental code coverage rate of the test requirement corresponding to the target tracking identifier based on the global incremental code containing the target tracking identifier and the test operation code. According to the incremental code coverage rate determining method, the tracking identification is set, the incremental code coverage rates of a plurality of test requirements can be determined at the same time, and the test efficiency is greatly improved.

Description

Incremental code coverage rate determining method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for determining incremental code coverage.
Background
With the development of the internet, the iteration of the application product is faster and faster, and in order to improve the reliability of the application product, the release flow of the application product can be divided into a plurality of stages connected in series, so that the processing such as ordered architecture, deployment, testing and the like can be performed on each stage, and the application product can be rapidly and safely deployed in a production environment.
In this case, the coverage rate of the newly added codes is determined in the test process, so that codes which are not covered in the test, invalid codes which may exist and the like can be effectively analyzed, and the test quality can be effectively guaranteed.
At present, only one set of test environment is usually deployed for an enterprise, and all test requirements are performed in the same test environment, so that parallel operation of multiple test requirements cannot be realized, the incremental code coverage rate of different stages cannot be determined at the same time, and the product test efficiency is reduced.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, an apparatus, a device, and a storage medium for determining an incremental code coverage, which solve the technical problem in the prior art that incremental code coverage detection cannot be performed in parallel.
In a first aspect, an embodiment of the present application provides a method for determining incremental code coverage, including:
responding to the received test requirements respectively sent by the plurality of test terminals, generating a corresponding tracking identifier for each test requirement, and sending the tracking identifier to the corresponding test terminal; each test requirement comprises version information of a service to be tested;
responding to the received test operation instructions respectively sent by the plurality of test terminals, and generating a test operation code corresponding to each test operation instruction; each test operation instruction corresponds to a test requirement, and each test operation code comprises a tracking identifier of the test requirement which can be realized;
determining a global incremental code for each test requirement based on the version information of each test requirement; each global increment code comprises a tracking identifier corresponding to a test requirement;
determining the increment code coverage rate of the test requirement corresponding to the target tracking identifier based on the global increment code containing the target tracking identifier and the test operation code; the target tracking identifier is any one of all tracking identifiers.
In a possible implementation manner of the first aspect, generating, in response to a received test execution instruction sent by each of the plurality of test terminals, a test execution code corresponding to each test execution instruction includes:
receiving test operation instructions respectively sent by a plurality of test terminals, and generating a change code file of each test operation instruction;
and aiming at each test operation instruction, acquiring a tracking identifier of the test requirement which can be realized by the test operation instruction, and combining the tracking identifier and the change code file of the test operation instruction to generate a test operation code corresponding to the test operation instruction.
In one possible implementation of the first aspect, the change code file includes a file name of the change code line and a line number of the change code line.
In one possible implementation manner of the first aspect, determining, based on a global delta code including a target tracking identifier and a test run code, a delta code coverage rate of a test requirement corresponding to the target tracking identifier includes:
determining a first code line number of a global incremental code containing a target tracking identifier;
determining a second code line number of candidate code lines in the test running code containing the target tracking identification; the candidate code behavior test running code comprises a code line which is overlapped with a global increment code containing a target tracking identifier;
and determining the quotient of the second code line number and the first code line number as the incremental code coverage rate of the test requirement corresponding to the target tracking identification.
In a possible implementation manner of the first aspect, after determining, based on the global delta code including the target tracking identifier and the test run code, a delta code coverage rate of a test requirement corresponding to the target tracking identifier, the method further includes:
and sending the incremental code coverage rate of each test requirement to the corresponding test terminal.
In a second aspect, an embodiment of the present application provides a method for determining an incremental code coverage, including:
sending a test requirement containing version information of a service to be tested to a server; the test requirement is used for indicating the server to generate a tracking identifier corresponding to the test requirement and determining a global increment code corresponding to the test requirement according to the version information; wherein the global delta code contains the tracking identifier;
receiving and storing the tracking identifier fed back by the server;
responding to test operation information of a test user for realizing the test requirement, generating a test operation instruction corresponding to the test requirement and sending the test operation instruction to a server; and the test operation instruction is used for instructing the server to generate a test operation code containing the tracking identifier, and determining the incremental code coverage rate of the test requirement corresponding to the tracking identifier according to the global incremental code containing the tracking identifier and the test operation code.
In a possible implementation manner of the second aspect, receiving and saving the tracking identifier fed back by the server includes:
receiving the tracking identification fed back by the server, and determining the running mode of the test requirement;
writing the tracking identification into a cache of a browser for executing the web service under the condition that the running mode is the web service;
in the case where the mode of operation of the test requirements is a command line instruction, the trace flag is written to the system environment variable.
In a third aspect, an embodiment of the present application provides an incremental code coverage determining apparatus, including:
the identification generation module is used for responding to the received test requirements respectively sent by the plurality of test terminals, generating a corresponding tracking identification for each test requirement and sending the tracking identification to the corresponding test terminal; each test requirement comprises version information of a service to be tested;
the test code generating module is used for responding to the received test operation instructions respectively sent by the plurality of test terminals and generating a test operation code corresponding to each test operation instruction; each test operation instruction corresponds to a test requirement, and each test operation code comprises a tracking identifier of the test requirement which can be realized;
the global code generation module is used for determining a global increment code of each test requirement based on the version information of each test requirement; each global increment code comprises a tracking identifier corresponding to a test requirement;
the coverage rate determining module is used for determining the coverage rate of the incremental code of the test requirement corresponding to the target tracking identifier based on the global incremental code containing the target tracking identifier and the test operation code; the target tracking identifier is any one of all tracking identifiers.
In a fourth aspect, an embodiment of the present application provides an incremental code coverage determining apparatus, including:
the sending module is used for sending a test requirement containing the service version information to be tested to the server; the test requirement is used for indicating the server to generate a tracking identifier corresponding to the test requirement and determining a global increment code corresponding to the test requirement according to the version information; wherein the global delta code contains the tracking identifier;
the receiving module is used for receiving and storing the tracking identifier fed back by the server;
the instruction generating module is used for responding to the received test operation information for realizing the test requirement, generating a test operation instruction corresponding to the test requirement and sending the test operation instruction to the server; and the test operation instruction is used for instructing the server to generate a test operation code containing the tracking identifier, and determining the incremental code coverage rate of the test requirement corresponding to the tracking identifier according to the global incremental code containing the tracking identifier and the test operation code.
In a fifth aspect, an embodiment of the present application provides an incremental code coverage determining apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of any one of the methods in the first aspect when executing the computer program.
In a sixth aspect, an embodiment of the present application provides an incremental code coverage determining apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of any one of the methods in the second aspect when executing the computer program.
In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and when being executed by a processor, the computer program implements the steps of any one of the methods in the first aspect; or implementing the steps of the method of any of the second aspects above.
In an eighth aspect, embodiments of the present application provide a computer program product, which, when run on a terminal device, causes the terminal device to execute the method of any one of the above first aspects; or performing the method of any of the second aspects above.
The incremental code coverage rate determining method provided by the embodiment of the application generates a tracking identifier for each test requirement, so that the test operation instructions, the test operation codes and the global incremental codes corresponding to different test requirements are distinguished, the step of obtaining the test operation codes corresponding to a plurality of test requirements respectively can be executed in parallel, and/or the step of obtaining the global incremental codes of a plurality of test requirements can be executed in parallel, and then the incremental code coverage rate of the test requirement corresponding to the target tracking identifier can be determined based on the global incremental codes including the target tracking identifier and the test operation codes. According to the incremental code coverage rate determining method provided by the embodiment of the application, the test requirements corresponding to the parameters (the global incremental code and the test operation code) for determining the incremental code coverage rate can be distinguished all the time by setting the tracking identifier, so that the incremental code coverage rates of a plurality of test requirements can be determined at the same time, and the test efficiency is greatly improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic diagram of an application scenario of an incremental code coverage determining method according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating a method for incremental code coverage determination according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating a method for generating test run code according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating an example of determining incremental code coverage for a test requirement according to an embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a method for incremental code coverage determination according to another embodiment of the present application;
fig. 6 is a signaling diagram of a method for determining incremental code coverage according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an incremental code coverage determining apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an incremental code coverage determining apparatus according to another embodiment of the present application;
FIG. 9 is a diagram illustrating a hardware component of an incremental code coverage determination apparatus according to an embodiment of the present application;
fig. 10 is a schematic hardware composition diagram of an incremental code coverage determining device according to another embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
In order to improve the reliability of application products, after each requirement in the product is developed, the requirement is basically released to a production environment through a test of a test user. The test user generally performs black box test, that is, a test case is designed according to the influence range of the required function, only the case related to the requirement is executed, but whether the codes of the tested version are executed cannot be known, in addition, the test also meets the test requirement irrelevant to the interactive function, and the omission is more easily generated when the case is designed. Based on this, it is important to test coverage checks and metrics for newly added code of each version of code.
At present, only one set of test environment is usually deployed for an enterprise, all test requirements are carried out in the same test environment, and parallel operation of a plurality of test requirements cannot be realized, so that the incremental code coverage rate of each test requirement cannot be determined at the same time, and the test efficiency of a product is reduced.
Based on the problems, the incremental code coverage rate determining method is provided, different testing requirements are distinguished through the tracking identification, the incremental code coverage rate is determined through parallel testing of a plurality of testing terminals, and the testing efficiency is greatly improved.
Fig. 1 is a schematic structural diagram of an application system of an incremental code coverage rate determining method according to an embodiment of the present application. As shown in fig. 1, the system includes a plurality of test terminals 20 (test terminal 1, test terminal 2.. Test terminal n), where the test terminal 20 may be a mobile phone, a tablet, or the like, and in this schematic diagram, the test terminal 1, the test terminal 2, and the test terminal n are taken as examples, and each test terminal 20 may respond to an execution test case operation of a test user to generate a test operation instruction corresponding to a test requirement.
In addition, the system further includes a server 10, where the server 10 may receive the test requirements sent by the multiple test terminals 20 at the same time, and calculate and obtain incremental code coverage rates corresponding to different test requirements or the same test requirement sent by different test terminals 20.
The server 10 may be deployed with a code version management system, a business execution system, and an incremental code coverage calculation system.
The code version management system can obtain the global incremental code corresponding to the version information according to the version information of the code. The service execution system may obtain the change code file corresponding to the received test requirement in response to the test terminal 20 sending a test instruction corresponding to the test requirement. The delta code coverage calculation system may determine delta code coverage based on the global delta code and the change code file.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. It is worth mentioning that the specific embodiments listed below may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
Fig. 2 is a schematic flowchart of an incremental code coverage rate determining method provided in an embodiment of the present application, where an execution subject of the embodiment is the server in fig. 1, and as shown in fig. 2, the incremental code coverage rate determining method includes:
s11, responding to the received test requirements sent by the plurality of test terminals respectively, generating a corresponding tracking identifier for each test requirement, and sending the tracking identifier to the corresponding test terminal, wherein each test requirement comprises version information of the service to be tested.
In this embodiment, the test requirement may refer to a functional requirement to be tested after the product development is completed. Each test requirement contains the version information of the service to be tested.
Optionally, the test requirement may further include text information describing the functional requirement.
In this embodiment, the tracking identifier may be a uniquely identifiable identifier such as a number and an ID.
In this embodiment, the plurality of test terminals may respectively send the test requirements at different times, or may respectively send the test requirements at the same time.
In one example, at least two test terminals respectively send test requirements at the same time, at this time, the server simultaneously receives the test requirements sent by the at least two test terminals respectively, and generates a corresponding trace identifier for each test requirement, thereby implementing parallel processing of the test requirements.
Optionally, the test requirements respectively sent by the multiple test terminals may be the same test requirement, or may also be different test requirements. The same test requirement may refer to a test requirement containing the same version information.
In one example, when at least two test requirements include the same version information, the server generates the same trace identifier for the at least two test requirements including the same version information, and sends the trace identifier to the test terminals corresponding to the at least two test requirements respectively.
S12, responding to the received test operation instructions respectively sent by the plurality of test terminals, and generating a test operation code corresponding to each test operation instruction; each test operation instruction corresponds to a test requirement, and each test operation code comprises a tracking identifier of the test requirement which can be realized.
In this embodiment, the test operation instruction may refer to an operation instruction generated by the test terminal executing a test case, where the test case is a functional operation designed by a test user and used for implementing a test requirement, for example, clicking an interface function control, setting an input field, and performing a business process operation.
In this embodiment, the test requirement corresponding to the test operation instruction is any one of the plurality of test requirements for generating the corresponding trace identifier in step 11. The specific characteristic is that the test operation instruction comprises a tracking identifier for characterizing the test requirement.
In this embodiment, when the server receives a test operation instruction sent by the test terminal, it is determined whether the test operation instruction includes a tracking identifier of a test requirement that can be implemented, and if the test operation instruction includes the tracking identifier of the test requirement that can be implemented, a test operation code corresponding to the test operation instruction is generated, so that the test operation code includes the tracking identifier of the test requirement that can be implemented.
Optionally, if the test run instruction does not include the trace identifier of the achievable test requirement, the step of generating the test run code is not performed.
In this embodiment, the test execution code may include a change code involved in executing the test execution instruction, and the test execution code may be obtained by a service execution system deployed on the server.
S13, determining a global increment code of each test requirement based on the version information of each test requirement; wherein each global delta code contains a trace identification corresponding to a test requirement.
In this embodiment, the global incremental code may refer to all codes related to the version information, and the global incremental code corresponding to the version information may be obtained by a code version management system deployed on a server.
For example, the code version management system obtains all the code corresponding to the version information and formats the all the code into a delta code file containing the name of the change code file and the code lines of the change code in each file.
S14, determining the incremental code coverage rate of the test requirement corresponding to the target tracking identifier based on the global incremental code containing the target tracking identifier and the test operation code; the target tracking identifier is any one of all tracking identifiers.
Optionally, the server may further determine, based on the global incremental code and the test run code that include the same target trace identifier, the incremental code coverage of the test requirement corresponding to different trace identifiers, so as to implement parallel determination of the incremental code coverage of multiple test requirements.
In this embodiment, after determining the incremental code coverage of the test requirement corresponding to the target tracking identifier, the server may send the incremental code coverage to the corresponding test terminal.
And the corresponding test terminal is a test terminal for sending the test requirement corresponding to the target tracking identifier.
The incremental code coverage rate determining method provided by the embodiment of the application generates a tracking identifier for each test requirement, so that the test operation instructions, the test operation codes and the global incremental codes corresponding to different test requirements are distinguished, the step of obtaining the test operation codes corresponding to a plurality of test requirements respectively can be executed in parallel, and/or the step of obtaining the global incremental codes of a plurality of test requirements can be executed in parallel, and then the incremental code coverage rate of the test requirement corresponding to the target tracking identifier can be determined based on the global incremental code containing the target tracking identifier and the test operation codes. According to the incremental code coverage rate determining method provided by the embodiment of the application, the test requirements corresponding to the parameters (the global incremental code and the test running code) for determining the incremental code coverage rate can be distinguished all the time by setting the tracking identifier, so that the incremental code coverage rates of a plurality of test requirements can be determined at the same time, and the test efficiency is greatly improved.
FIG. 3 is a flowchart illustrating a method for generating test run code according to an embodiment of the present application; one possible implementation of step 12 in the embodiment of fig. 2 is described, and as shown in fig. 3, step 12 includes:
and S121, receiving test operation instructions sent by the plurality of test terminals respectively, and generating a change code file of each test operation instruction.
The change code file comprises a file name of a change code line and a line number of the change code line.
Optionally, the change code file may further include a statement to which the change code line belongs, an identifier of whether the statement is covered, a name of the function in which the change code line is located, a starting line number of the function in which the change code line is located, and an identifier of whether the function in which the change code line is covered.
The test operation instruction may include a trace identifier of the test requirement that can be realized, or the test terminal sends the trace identifier of the test requirement that can be realized by the test operation instruction when sending the test operation instruction.
And S122, acquiring a tracking identifier of the test requirement which can be realized by the test operation instruction aiming at each test operation instruction, and combining the tracking identifier and the change code file of the test operation instruction to generate a test operation code corresponding to the test operation instruction.
In this embodiment, after the server combines the tracking identifier with the change code file of the test operation instruction to generate the test operation code corresponding to the test operation instruction, the test operation code may be reported to the incremental code coverage rate calculation system, so that the incremental code coverage rate calculation system performs coverage rate calculation.
FIG. 4 is a flowchart illustrating a method for determining incremental code coverage for a test requirement according to an embodiment of the present application; one possible implementation of step 14 in the embodiment of fig. 2 is described, and as shown in fig. 4, step 14 includes:
s141, determining a first code line number of the global increment code containing the target tracking identification.
In this embodiment, the number of first code lines may refer to the number of lines of all code lines in the global incremental code.
By way of example, the test terminal 1 aims at obtaining an incremental code coverage of the test requirements a,
the server assigns a tracking identification ID of 1 to the test requirement a,
test requirement a contains version information of 2.3.1.
The following table 1 shows that the server obtains the global increment code according to the version information of the test requirement a:
TABLE 1 Global incremental code for test requirement A with ID of 1
Figure BDA0002524165950000111
Wherein, the ID is the ID of the tracking identification, a/b/c are the names of the changed files, and the numerical value in the code line is the line number in the changed code line.
Where the number of lines relating to lines of code in file a is 9, the number of lines relating to lines of code in file b is 5, and the number of lines relating to lines of code in file c is 9, then the first number of lines of code is the sum of the three numbers of lines of file a, b, c, i.e. 23.
S142, determining a second code line number of the candidate code lines in the test running code containing the target tracking identification; and testing a code line which is overlapped with the global increment code containing the target tracking identification in the running code by the candidate code line.
In this embodiment, the candidate code line may be a code line in the test run code that coincides with a code line in the global delta code that includes the target tracking identifier.
The superposition means that the file names and the line numbers of the two code lines are the same.
For example, the test run code includes line 3 and line 4 in the a file, and the global delta code includes line 4, line 5, and line 6 in the a file, then the code line where the line 3 of the a file in the test run code coincides with the code line in the global delta may be determined as a candidate code line.
Optionally, if the test requirements sent by the at least two test terminals are the same and the test requirements correspond to the target tracking identifiers, the at least two test running codes include the target tracking identifiers, and at this time, the candidate code acts on a set of code lines in the at least two test running codes, which are overlapped with the code lines in the global increment codes including the target tracking identifiers.
In this embodiment, the second code line number may refer to the line number of all candidate code lines.
Illustratively, the test terminal 1 aims to obtain the incremental code coverage of the test requirement a, the server assigns the trace identifier ID to the test requirement a to be 1, and the version information contained in the test requirement a is 2.3.1.
The test operation code generated by the server according to the test operation instruction for realizing the test requirement a is shown in the following table 2:
table 2 test run code corresponding to test requirement a
Figure BDA0002524165950000121
As can be seen from table 1 and table 2, the candidate code lines in the changed code lines that coincide with the code line in the global delta code containing ID1 are [220,221,222,223] in file a and [55,56,57,58,59,60,61,62,63] in file c, respectively, and the second code line number of the candidate code line is 13.
It should be understood that, since the test case executed by the test terminal 1 may contain operations that do not belong to the requirement a, the code lines in the test run code may contain code lines that are not involved in the global delta code.
S143, obtaining a quotient value of the number of the second code lines and the number of the first code lines in the test running code, and determining the increment code coverage rate of the test requirement corresponding to the target tracking identification.
In this embodiment, the server performs quotient calculation processing on the second code line number and the first code line number, to obtain a quotient value of the second code line number and the first code line number.
Fig. 5 is a schematic flowchart of a method for determining incremental code coverage according to another embodiment of the present application, where an execution subject of the embodiment is any one of the test terminals in fig. 1, for example, the test terminal 1. As shown in fig. 5, the incremental code coverage determining method includes:
s21, sending a test requirement containing the version information of the service to be tested to a server; the test requirement is used for instructing the server to generate a tracking identifier corresponding to the test requirement, and determining a global increment code corresponding to the test requirement according to the version information.
Wherein the global delta code contains the tracking identification.
And S22, receiving and storing the tracking identification fed back by the server.
In this embodiment, the tracking identifier fed back by the server is a tracking identifier corresponding to the test requirement sent by the test terminal.
In this embodiment, the step of receiving and storing the tracking identifier fed back by the server by the test terminal 1 may include the following steps:
step 1: and receiving the tracking identification fed back by the server, and determining the running mode of the test requirement.
Step 2: in the case where the operation mode is a web service, the trace identification is written to a cache of a browser for executing the web service.
And step 3: in the case where the mode of operation of the test requirements is a command line instruction, the trace flag is written to the system environment variable.
The operation mode is used for representing the operation mode of the test case for realizing the test requirement, and may include a web service, a command line instruction, and the like.
The web service may refer to a test terminal generating a test execution instruction in response to an operation of a test user on a browser. The command line instruction may refer to a test terminal generating a test execution instruction in response to a command input by a test user in a command line.
Alternatively, the cache may refer to a cookie of the browser.
It should be understood that the system environment variables of different test terminals may be different and isolated from each other. After the test terminal 1 modifies the system environment variables, the values of the same variables of the test terminal 2 are not affected.
S23, responding to the received test operation information for realizing the test requirement, generating a test operation instruction corresponding to the test requirement and sending the test operation instruction to a server; and the test operation instruction is used for instructing the server to generate a test operation code containing the tracking identifier, and determining the incremental code coverage rate of the test requirement corresponding to the tracking identifier according to the global incremental code containing the tracking identifier and the test operation code.
For the specific implementation and beneficial effects of this embodiment, reference may be made to the related descriptions of the embodiments in fig. 2 to fig. 4, which are not described herein again.
Fig. 6 is a signaling diagram of a method for determining incremental code coverage according to an embodiment of the present application; one possible embodiment of the server for simultaneously determining the incremental code coverage of the respectively transmitted test requirements transmitted by a plurality of test terminals is described. In the present embodiment, a test terminal 1 and a test terminal 2 are taken as examples for schematic description. As shown in fig. 6, the incremental code coverage determination method includes:
s301, the testing terminal 1 sends a testing requirement 1 containing version information of the service to be tested to the server.
S302, the testing terminal 2 sends a testing requirement 2 containing version information of the service to be tested to the server.
It should be understood that the version information contained in test requirement 2 and test requirement 1 may be the same.
S303, the server generates a trace identifier 1 for the test requirement 1 sent by the test terminal 1, and generates a trace identifier 2 for the test requirement 2 sent by the test terminal 2.
If the version information included in the test requirement 1 and the test requirement 2 is the same, the trace flag 1 and the trace flag 2 are the same.
S304, the server generates a global increment code 1 according to the version information contained in the test requirement 1, and simultaneously generates a global increment code 2 according to the version information contained in the test requirement 2.
Wherein, the global increment code 1 contains a tracing identifier 1, and the global increment code 2 contains a tracing identifier 2
S305, the server sends the tracking identifier 2 to the test terminal 2.
S306, the server sends the tracking identifier 2 to the test terminal 1.
S307, the test terminal 2 stores the tracking identifier 2.
The test terminal 2 saves the trace identifier 2, which may refer to writing the trace identifier to a cache of a browser for executing the web service and writing the trace identifier to a system environment variable.
S308, the test terminal 1 stores the tracking identifier 1.
S309, the test terminal 1 responds to the test operation of the test user 1 for realizing the test requirement 1, and generates a test operation instruction 1 corresponding to the test requirement 1.
And S310, the test terminal 1 sends a test operation instruction 1 to the server.
S311, the test terminal 2 responds to the test operation of the test user 2 for implementing the test requirement 2, and generates a test operation instruction 2 corresponding to the test requirement 2.
And S312, the test terminal 2 sends the test operation instruction 2 to the server.
S313, the server generates a test operation code 1 corresponding to the test operation instruction 1 and a test operation code 2 corresponding to the test operation instruction 2, respectively.
The test running code 1 includes a trace identifier 1, and the test running code 2 includes a trace identifier 2.
S314, the server determines the incremental code coverage rate of the test requirement corresponding to the target tracking identifier based on the global incremental code containing the target tracking identifier and the test operation code.
The target tracking identifier is a tracking identifier 1 or a tracking identifier 2.
Since the global increment code and the test running code corresponding to the test requirement 1 sent by the test terminal 1 both include the trace identifier 1, and the global increment code and the test running code corresponding to the test requirement 2 sent by the test terminal 2 both include the trace identifier 2, the server can perform parallel computation to obtain the increment code coverage rates of the test requirements corresponding to the trace identifier 1 and the trace identifier 2, respectively.
The specific adding process in this embodiment may refer to the descriptions of the embodiments in fig. 2 to fig. 5, and is not described herein again.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Based on the incremental code coverage rate determining method provided by the above embodiment, an embodiment of the apparatus for implementing the above method embodiment is further provided in the embodiment of the present invention.
Fig. 7 is a schematic structural diagram of an incremental code coverage rate determining apparatus according to an embodiment of the present application. Suitable for use in the server of the embodiment of fig. 1. As shown in fig. 7, the incremental code coverage determination apparatus 40 includes an identification generation module 401, a test code generation module 402, a global code generation module 403, and a coverage determination module 404; wherein the content of the first and second substances,
the identifier generating module 401 is configured to generate a corresponding trace identifier for each test requirement in response to the received test requirements sent by the plurality of test terminals respectively, and send the trace identifier to the corresponding test terminal; each test requirement comprises version information of a service to be tested;
a test code generating module 402, configured to generate a test operation code corresponding to each test operation instruction in response to the received test operation instruction respectively sent by the multiple test terminals; each test operation instruction corresponds to a test requirement, and each test operation code comprises a tracking identifier of the test requirement which can be realized;
a global code generation module 403, configured to determine a global incremental code of each test requirement based on the version information of each test requirement; each global increment code comprises a tracking identification corresponding to the test requirement;
a coverage rate determining module 404, configured to determine, based on the global incremental code including the target tracking identifier and the test run code, an incremental code coverage rate of the test requirement corresponding to the target tracking identifier; the target tracking identifier is any one of all tracking identifiers.
Optionally, the test code generating module 402 generates, in response to the received test operation instructions respectively sent by the multiple test terminals, a test operation code corresponding to each test operation instruction, including: receiving test operation instructions respectively sent by a plurality of test terminals, and generating a change code file of each test operation instruction; and aiming at each test operation instruction, acquiring a tracking identifier of the test requirement which can be realized by the test operation instruction, and combining the tracking identifier and the change code file of the test operation instruction to generate a test operation code corresponding to the test operation instruction.
Optionally, the change code file includes a file name of the change code line and a line number of the change code line.
Optionally, the coverage determining module 404 determines, based on the global delta code containing the target tracking identifier and the test run code, a delta code coverage of the test requirement corresponding to the target tracking identifier, including:
determining a first code line number of a global incremental code containing a target tracking identifier;
determining a second code line number of candidate code lines in the test running code containing the target tracking identification; the candidate code behavior test running code comprises a code line which is overlapped with a global increment code containing a target tracking identifier;
and determining the quotient of the second code line number and the first code line number as the incremental code coverage rate of the test requirement corresponding to the target tracking identification.
Optionally, the incremental code coverage determining apparatus 40 further includes a coverage sending module, and the sending module is configured to send the incremental code coverage of each test requirement to the corresponding test terminal.
The device for determining the coverage of the incremental code provided in the embodiment shown in fig. 7 may be used to implement the technical solutions in the method embodiments shown in fig. 2 to fig. 4, and the implementation principles and technical effects are similar, which are not described herein again.
Fig. 8 is a schematic structural diagram of an incremental code coverage determining apparatus according to another embodiment of the present application. Suitable for use in any of the test terminals in the embodiment of fig. 1. As shown in fig. 8, the apparatus 50 for determining incremental code coverage includes a sending module 501, a receiving module 502, and an instruction generating module 503; wherein the content of the first and second substances,
a sending module 501, configured to send a test requirement including version information of a service to be tested to a server; the test requirement is used for indicating the server to generate a tracking identifier corresponding to the test requirement and determining a global increment code corresponding to the test requirement according to the version information; wherein the global delta code contains the tracking identification.
And a receiving module 502, configured to receive and store the tracking identifier fed back by the server.
The instruction generating module 503 is configured to generate a test operation instruction corresponding to the test requirement in response to the received test operation information for implementing the test requirement, and send the test operation instruction to the server; and the test operation instruction is used for instructing the server to generate a test operation code containing the tracking identifier, and determining the incremental code coverage rate of the test requirement corresponding to the tracking identifier according to the global incremental code containing the tracking identifier and the test operation code.
Optionally, the receiving module 502 receives and stores the tracking identifier fed back by the server, including:
receiving the tracking identification fed back by the server, and determining the running mode of the test requirement; writing the tracking identification into a cache of a browser for executing the web service under the condition that the running mode is the web service; in the case where the test requirement is run in a command line instruction, a trace flag is written to the system environment variable.
The apparatus for determining incremental code coverage provided in the embodiment shown in fig. 8 may be configured to implement the technical solution in the embodiment of the method shown in fig. 5, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 9 is a schematic diagram of an incremental code coverage determining device according to an embodiment of the present application. As shown in fig. 9, the incremental code coverage determination device 60 of this embodiment includes: at least one first processor 601, a first memory 602, and a computer program stored in said first memory 602 and executable on said first processor 601. The incremental code coverage determination device 60 device further comprises a first communication means 603, wherein the first processor 601, the first memory 602 and the first communication means 603 are connected by a first bus 604.
The first processor 601, when executing the computer program, implements the steps in each incremental code coverage determination method embodiment in fig. 2 to 4, for example, steps S11 to S14 in the embodiment shown in fig. 2. Alternatively, the first processor 601, when executing the computer program, implements the functions of the modules/units in the apparatus embodiment for incremental code coverage determination in the above-described fig. 7 embodiment.
It should be understood that the incremental code coverage determination device provided by the embodiment of the present application may be the server in fig. 1.
Fig. 10 is a schematic diagram of an incremental code coverage determining apparatus according to another embodiment of the present application. As shown in fig. 10, the incremental code coverage determination device 70 of this embodiment includes: at least one second processor 701, a second memory 702 and a computer program stored in said second memory 702 and executable on said second processor 701. The incremental code coverage determination device 70 further comprises a second communication means 703, wherein the second processor 701, the second memory 702 and the second communication means 703 are connected by a second bus 704.
The second processor 701 implements the steps in the embodiment of the incremental code coverage determination method shown in fig. 5 when executing the computer program, or the processor 701 implements the functions of each module/unit in the embodiment of the apparatus for determining incremental code coverage shown in fig. 8 when executing the computer program.
It should be understood that the incremental code coverage determination device provided by the embodiment of the present application may be any one of the test terminals in fig. 1.
Those skilled in the art will appreciate that fig. 9 and 10 are merely examples of incremental code coverage determination devices and do not constitute limitations on the terminal device, and may include more or fewer components than those shown, or some components in combination, or different components, such as input-output devices, network access devices, buses, etc.
The first Processor 601 and the second Processor 701 may be a Central Processing Unit (CPU), other general purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, a discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The first memory 602 and the second memory 702 may be internal memory units of the incremental code coverage determination device or may be external memory devices of the incremental code coverage determination device.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps in the foregoing method embodiments may be implemented.
Embodiments of the present application provide a computer program product, which when running on a mobile terminal, enables the mobile terminal to implement the steps in the above method embodiments when executed.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing apparatus/terminal apparatus, a recording medium, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other ways. For example, the above-described apparatus/network device embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logical function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (9)

1. A method for incremental code coverage determination, comprising:
responding to the received test requirements respectively sent by the plurality of test terminals, generating a corresponding tracking identifier for each test requirement, and sending the tracking identifier to the corresponding test terminal; each test requirement comprises version information of a service to be tested;
responding to the received test operation instructions respectively sent by the plurality of test terminals, and generating a test operation code corresponding to each test operation instruction; each test operation instruction corresponds to a test requirement, and each test operation code comprises a tracking identifier of the test requirement which can be realized;
determining a global delta code for each of the test requirements based on the version information for each of the test requirements; each global increment code comprises a tracking identifier corresponding to a test requirement, and the increment codes are all codes corresponding to the version information;
determining an incremental code coverage rate of a test requirement corresponding to a target tracking identifier based on a global incremental code containing the target tracking identifier and a test operation code; the target tracking identifier is any one of all tracking identifiers;
the determining the incremental code coverage of the test requirement corresponding to the target tracking identifier based on the global incremental code containing the target tracking identifier and the test run code comprises:
determining a first code line number of the global incremental code containing the target tracking identification;
determining a second code line number of candidate code lines in the test running code containing the target tracking identification; a code line which is overlapped with the global increment code containing the target tracking identifier in the candidate code behavior test running code;
and determining the quotient of the second code line number and the first code line number as the incremental code coverage rate of the test requirement corresponding to the target tracking identifier.
2. The method for determining incremental code coverage according to claim 1, wherein the generating a test operation code corresponding to each test operation instruction in response to the received test operation instructions respectively sent by the plurality of test terminals includes:
receiving test operation instructions respectively sent by the plurality of test terminals, and generating a change code file of each test operation instruction;
and aiming at each test operation instruction, acquiring a tracking identifier of the test requirement which can be realized by the test operation instruction, and combining the tracking identifier and a change code file of the test operation instruction to generate a test operation code corresponding to the test operation instruction.
3. The incremental code coverage determination method of claim 2, wherein the change code file includes a file name of a change code line and a line number of the change code line.
4. The method for determining incremental code coverage as claimed in claim 1, wherein after determining the incremental code coverage of the test requirement corresponding to the target tracking identifier based on the global incremental code including the target tracking identifier and the test run code, the method further comprises:
and sending the incremental code coverage rate of each test requirement to a corresponding test terminal.
5. A method for incremental code coverage determination, comprising:
sending a test requirement containing version information of a service to be tested to a server; the test requirement is used for indicating the server to generate a tracking identifier corresponding to the test requirement, and determining a global increment code corresponding to the test requirement according to the version information; the global increment code comprises the tracking identification, and the increment code is all codes corresponding to the version information;
receiving and storing the tracking identifier fed back by the server;
responding to the received test operation information for realizing the test requirement, generating a test operation instruction corresponding to the test requirement and sending the test operation instruction to the server; the test operation instruction is used for instructing the server to generate a test operation code containing the tracking identifier, and determining the increment code coverage rate of the test requirement corresponding to the tracking identifier according to the global increment code containing the tracking identifier and the test operation code;
the method further comprises the following steps:
the server determines an incremental code coverage rate of a test requirement corresponding to a target tracking identifier based on a global incremental code containing the target tracking identifier and a test run code, and the incremental code coverage rate comprises the following steps:
determining a first code line number of the global incremental code containing the target tracking identification;
determining a second code line number of candidate code lines in the test running code containing the target tracking identification; a code line which is overlapped with the global increment code containing the target tracking identifier in the candidate code behavior test running code;
and determining the quotient of the second code line number and the first code line number as the incremental code coverage rate of the test requirement corresponding to the target tracking identification.
6. The incremental code coverage determination method of claim 5 wherein said receiving and storing said tracking identification of said server feedback comprises:
receiving the tracking identification fed back by the server, and determining the running mode of the test requirement;
if the running mode is web service, writing the tracking identification into a cache of a browser for executing the web service;
and writing the tracking identification into a system environment variable under the condition that the running mode of the test requirement is a command line instruction.
7. An incremental code coverage determination device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, characterized in that said processor implements the steps of the method according to any of claims 1 to 4 when executing said computer program.
8. An incremental code coverage determination device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, characterized in that said processor implements the steps of the method according to claim 5 or 6 when executing said computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4, or carries out the steps of the method according to claim 5 or 6.
CN202010499277.9A 2020-06-04 2020-06-04 Incremental code coverage rate determining method, device, equipment and storage medium Active CN111831549B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010499277.9A CN111831549B (en) 2020-06-04 2020-06-04 Incremental code coverage rate determining method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010499277.9A CN111831549B (en) 2020-06-04 2020-06-04 Incremental code coverage rate determining method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111831549A CN111831549A (en) 2020-10-27
CN111831549B true CN111831549B (en) 2023-04-14

Family

ID=72898357

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010499277.9A Active CN111831549B (en) 2020-06-04 2020-06-04 Incremental code coverage rate determining method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111831549B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540913B (en) * 2020-11-27 2024-02-09 山东云海国创云计算装备产业创新中心有限公司 Method, system, equipment and readable storage medium for determining code coverage rate

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8578344B2 (en) * 2010-06-17 2013-11-05 Microsoft Corporation Incremental compositional dynamic test generation
CN108519945A (en) * 2018-03-21 2018-09-11 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage device
CN108491331B (en) * 2018-04-13 2023-03-21 平安普惠企业管理有限公司 Software testing method, device, equipment and computer storage medium
CN110221963A (en) * 2019-04-29 2019-09-10 北京三快在线科技有限公司 Code coverage acquisition methods and device
CN110704303B (en) * 2019-09-05 2021-07-20 深圳开源互联网安全技术有限公司 Method and device for acquiring test coverage information

Also Published As

Publication number Publication date
CN111831549A (en) 2020-10-27

Similar Documents

Publication Publication Date Title
CN108512939B (en) Block chain consensus method, device and related equipment
CN111899008B (en) Resource transfer method, device, equipment and system
CN108460068B (en) Method, device, storage medium and terminal for importing and exporting report
CN112035344A (en) Multi-scenario test method, device, equipment and computer readable storage medium
CN109408309B (en) Multi-terminal testing method and device
US20220100486A1 (en) Model deployment method, model deployment device and terminal equipment
CN111190750B (en) Data processing method and system
CN111831549B (en) Incremental code coverage rate determining method, device, equipment and storage medium
CN108920601B (en) Data matching method and device
CN117216758B (en) Application security detection system and method
CN113626765A (en) Energy data processing method, device, equipment and storage medium
CN110532810B (en) Information processing method and device, electronic equipment and readable storage medium
CN112965711A (en) Job test method and apparatus, electronic device, and storage medium
CN111897826A (en) Parameter information updating method and device, electronic equipment and readable storage medium
CN109324838B (en) Execution method and execution device of single chip microcomputer program and terminal
CN110851207A (en) State transition management method and device, electronic equipment and computer readable storage medium
CN108429636B (en) Method and device for positioning abnormal system and electronic equipment
CN115460265A (en) Interface calling method, device, equipment and medium
CN111949510B (en) Test processing method, device, electronic equipment and readable storage medium
CN114443375A (en) Test method and device, electronic device and computer readable storage medium
CN111639936A (en) Transaction information acquisition method and device, electronic equipment and readable storage medium
CN117076546B (en) Data processing method, terminal device and computer readable storage medium
CN115408459A (en) Data exchange method and device and electronic equipment
CN114253805A (en) Software release method and device, electronic equipment and storage medium
CN115914231A (en) Intelligent contract processing method, device, equipment and computer readable storage medium

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

Address after: 518000 Room 01, 20th Floor, Cuilin Building, No. 10, Kaifeng Road, Maling Community, Meilin Street, Futian District, Shenzhen, Guangdong

Applicant after: Shenzhen Handhui Technology Group Co.,Ltd.

Address before: 518000 20 / F, Cuilin building, 10 Kaifeng Road, Maling community, Meilin street, Futian District, Shenzhen City, Guangdong Province

Applicant before: Shenzhen muchenglin Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant