CN112015663A - Test data recording method, device, equipment and medium - Google Patents

Test data recording method, device, equipment and medium Download PDF

Info

Publication number
CN112015663A
CN112015663A CN202010968254.8A CN202010968254A CN112015663A CN 112015663 A CN112015663 A CN 112015663A CN 202010968254 A CN202010968254 A CN 202010968254A CN 112015663 A CN112015663 A CN 112015663A
Authority
CN
China
Prior art keywords
target
request
test data
use case
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.)
Granted
Application number
CN202010968254.8A
Other languages
Chinese (zh)
Other versions
CN112015663B (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.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank 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 Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202010968254.8A priority Critical patent/CN112015663B/en
Publication of CN112015663A publication Critical patent/CN112015663A/en
Application granted granted Critical
Publication of CN112015663B publication Critical patent/CN112015663B/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/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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 invention relates to the technical field of testing, and provides a method, a device, equipment and a medium for recording test data, which can track and capture internal variables in real time according to a tracking ID (identity) through a byte code enhancement technology, establish a target corresponding relation according to a target code function and a target identifier, establish a corresponding relation between a target case corresponding to each intercepted target request and the target code function, effectively solve the problem that the relation between the case and the code function cannot be established, store the target corresponding relation and a variable value into a database, and further realize the parallel recording of the test data. The application also relates to a blockchain technology, and the target correspondence and the variable value can be stored on the blockchain.

Description

Test data recording method, device, equipment and medium
Technical Field
The present invention relates to the field of test technologies, and in particular, to a method, an apparatus, a device, and a medium for recording test data.
Background
In testing, it is usually necessary to record the relationship between the use case and the code function to assist in locating errors, checking coverage of the use case, and the like.
In the prior art, an open-source tool is mainly used for recording the relation between use cases and code functions, but many open-source code coverage rate statistical tools can count codes covered in a certain period of time, but if a plurality of testers execute a plurality of test use cases in the period of time, the codes in the period of time cannot be distinguished from which use cases are covered respectively, the direct relation between the codes and the use cases cannot be directly established, and the functions covered by a certain use case cannot be visually checked.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, an apparatus, a device, and a medium for recording test data, which can effectively solve the problem that the relationship between the use case and the code function cannot be established, and implement parallel recording of the test data.
A test data recording method comprises the following steps:
responding to a test data recording instruction, and intercepting each request of the test system by adopting an Agent technology;
for each intercepted target request, acquiring a target identifier of the target request, wherein the target identifier is used for determining a target use case corresponding to the target request;
determining whether to track the target request according to the target identifier;
when the target request is determined to be tracked, configuring a tracking ID for the target request, and setting an internal variable in an execution thread of the target request;
recording the variable value of the internal variable according to the tracking ID by adopting a byte code enhancement technology;
responding to a recording ending instruction, acquiring a target code function from the variable value, and establishing a target corresponding relation according to the target code function and the target identification;
and storing the target corresponding relation and the variable value to a database.
According to a preferred embodiment of the present invention, the determining whether to track the target request according to the target identifier comprises:
calling a pre-configured global identification list, wherein the global identification list stores identifications of all requests needing to be tracked;
traversing the global identification list with the target identification;
determining to track the target request when traversing to an identifier matching the target identifier in the global identifier list.
According to a preferred embodiment of the present invention, the configuring a trace ID for the target request and setting an internal variable in an execution thread of the target request includes:
acquiring a request cookie of the target request;
configuring the tracking ID in the request cookie;
acquiring an execution thread of the target request;
setting an Inheritable ThreadLocal variable as the internal variable in the execution thread.
According to the preferred embodiment of the present invention, the obtaining the target code function from the variable value and establishing the target correspondence according to the target code function and the target identifier includes:
acquiring the target code function from the variable value by adopting a regular expression, wherein the target code function comprises a function name and a parameter;
determining a target use case corresponding to the target request according to the target identifier;
and associating the target use case with the target code function to obtain a corresponding relation between the target use case and the target code function as the target corresponding relation.
According to the preferred embodiment of the present invention, the test data recording method further includes:
clearing the value of the request cookie when determining not to track the target request and/or in response to the recording ending instruction.
According to the preferred embodiment of the present invention, the test data recording method further includes:
determining configuration code functions of the target use case, and determining a first number of the configuration code functions;
determining a second number of the target code functions;
calculating the quotient of the second quantity and the first quantity as the function coverage rate of the target use case, and storing the function coverage rate to a block chain;
when the function coverage rate is larger than or equal to a preset threshold value, determining that the quality of the target use case passes verification; or
And when the function coverage rate is smaller than the preset threshold value, determining that the quality of the target use case does not pass the verification, and feeding back the quality of the target use case to a specified terminal device.
According to the preferred embodiment of the present invention, the test data recording method further includes:
and when the target code function is monitored to be modified, feeding back the target use case serving as a use case to be regressed to the specified terminal equipment.
A test data recording apparatus, the test data recording apparatus comprising:
the intercepting unit is used for responding to the test data recording instruction and intercepting each request of the test system by adopting an Agent technology;
an obtaining unit, configured to obtain, for each intercepted target request, a target identifier of the target request, where the target identifier is used to determine a target use case corresponding to the target request;
the determining unit is used for determining whether to track the target request according to the target identifier;
the configuration unit is used for configuring a tracking ID for the target request and setting an internal variable in an execution thread of the target request when the target request is determined to be tracked;
the recording unit is used for recording the variable value of the internal variable according to the tracking ID by adopting a byte code enhancement technology;
the establishing unit is used for responding to a recording ending instruction, acquiring a target code function from the variable value and establishing a target corresponding relation according to the target code function and the target identification;
and the storage unit is used for storing the target corresponding relation and the variable value into a database.
An electronic device, the electronic device comprising:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the test data recording method.
A computer-readable storage medium having stored therein at least one instruction, the at least one instruction being executable by a processor in an electronic device to implement the test data recording method.
It can be seen from the above technical solutions that, the present invention can respond to a test data recording instruction, intercept each request of a test system by using an Agent technology, obtain a target identifier of the target request for each intercepted target request, the target identifier is used to determine a target case corresponding to the target request, determine whether to track the target request according to the target identifier, configure a tracking ID for the target request when determining to track the target request, set an internal variable in an execution thread of the target request, record a variable value of the internal variable according to the tracking ID by using a bytecode augmentation technology, track and capture the internal variable in real time according to the tracking ID by using the bytecode augmentation technology, record a variable value of the internal variable, and obtain a target code function from the variable value in response to a recording ending instruction, and establishing a target corresponding relation according to the target code function and the target identification so as to establish a corresponding relation between a target case and the target code function corresponding to each intercepted target request, effectively solving the problem that the relation between the case and the code function cannot be established in the prior art, storing the target corresponding relation and the variable value into a database, and further realizing the parallel recording of the test data.
Drawings
Fig. 1 is a flowchart of a test data recording method according to a preferred embodiment of the present invention.
Fig. 2 is a functional block diagram of a test data recording apparatus according to a preferred embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device implementing a test data recording method according to a preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a flowchart illustrating a test data recording method according to a preferred embodiment of the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The test data recording method is applied to one or more electronic devices, which are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and the hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), an intelligent wearable device, and the like.
The electronic device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network servers.
The Network where the electronic device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
And S10, responding to the test data recording instruction, and intercepting each request of the test system by adopting an Agent technology.
In this embodiment, the test data recording instruction may be triggered by a related developer or tester.
The Agent is equivalent to an interceptor, before the main method is executed, Agent codes are executed, and the codes in the Agent are monitoring codes which are injected into the codes needing to be monitored by using a byte code modification tool, so that the execution time, parameters and the like of the codes are captured.
Through the Agent technology, each request of the test system can be effectively intercepted, so that the parallel recording of the test data is realized in an auxiliary manner.
S11, for each intercepted target request, obtaining a target identifier of the target request, wherein the target identifier is used for determining a target use case corresponding to the target request.
In this embodiment, the target identifier may include, but is not limited to: IP, digital signature, etc., the present invention does not limit the form of the target identification.
And S12, determining whether to track the target request according to the target identifier.
It will be appreciated that not all requests have trace requirements, and therefore, it is first determined whether the target request has the trace necessity to avoid burdening the system with performing meaningless traces.
Specifically, the determining whether to track the target request according to the target identifier includes:
calling a pre-configured global identification list, wherein the global identification list stores identifications of all requests needing to be tracked;
traversing the global identification list with the target identification;
determining to track the target request when traversing to an identifier matching the target identifier in the global identifier list.
Through the implementation mode, whether the target request is tracked can be determined according to actual requirements, and the system load is effectively reduced.
In this embodiment, the method for recording test data further includes:
acquiring historical recording data, determining all requests to be recorded according to the historical recording data, acquiring identifiers of all the requests, and configuring the global identifier list according to the identifiers of all the requests; and/or
And receiving the identifier uploaded by the user, and configuring the global identifier list according to the received identifier.
S13, when the target request is determined to be tracked, configuring a tracking ID for the target request, and setting an internal variable in the execution thread of the target request.
The internal variables are used for recording data in a test process, namely data generated when the target use case is executed.
In at least one embodiment of the present invention, the configuring a trace ID for the target request and setting an internal variable in an execution thread of the target request includes:
acquiring a request cookie of the target request;
configuring the tracking ID in the request cookie;
acquiring an execution thread of the target request;
setting an Inheritable ThreadLocal variable as the internal variable in the execution thread.
The tracking ID may be a character string with a preset number of bits, and the tracking ID may be obtained by converting according to the target identifier.
For example: when the target identification bit 123 is located, a check bit 15 is added on the basis of the target identification, and the tracking ID is 12315.
It can be understood that, since the trace ID corresponds to the target request and the target request corresponds to the target identifier, the trace ID and the target identifier also have a one-to-one correspondence relationship, which can provide a basis for subsequently establishing a relationship between a use case and a code function.
Further, the inheritable thread local variable is an internal variable of the execution thread, and enables a child thread to inherit the value of a parent thread, so that the data placed in the inheritable thread local variable can be acquired by inheritance, that is, the variable value of the internal variable can be acquired by the child thread in the execution thread.
And S14, recording the variable value of the internal variable according to the tracking ID by adopting a byte code enhancement technology.
The bytecode enhancement technology may be a Java bytecode enhancement technology, which means that after Java bytecode is generated, the Java bytecode is modified to enhance the function thereof, and this way is equivalent to modifying the binary file of the application program. The Java bytecode enhancement technology is mainly to reduce redundant codes, improve performance, and the like.
In this embodiment, by the bytecode augmentation technology, the internal variable can be tracked and captured in real time according to the tracking ID, and the variable value of the internal variable can be recorded.
S15, responding to the recording ending instruction, obtaining the target code function from the variable value, and establishing the target corresponding relation according to the target code function and the target identification.
The recording ending instruction can also be triggered by related developers or testers.
In at least one embodiment of the present invention, the obtaining a target code function from the variable value, and establishing a target correspondence according to the target code function and the target identifier includes:
acquiring the target code function from the variable value by adopting a regular expression, wherein the target code function comprises a function name and a parameter;
determining a target use case corresponding to the target request according to the target identifier;
and associating the target use case with the target code function to obtain a corresponding relation between the target use case and the target code function as the target corresponding relation.
Through the implementation mode, the corresponding relation between the target use case corresponding to each intercepted target request and the target code function can be established, and the problem that the relation between the use case and the code function cannot be established in the prior art is effectively solved.
In at least one embodiment of the present invention, the test data recording method further includes:
clearing the value of the request cookie when determining not to track the target request and/or in response to the recording ending instruction.
Through the implementation mode, when the target request is determined not to be tracked or stopped being tracked, the cookie requesting space can be released in time, so that the running performance of the system is improved.
And S16, storing the target corresponding relation and the variable value into a database.
The problem of parallel recording of test data can be effectively solved by warehousing the corresponding relation between the intercepted use case and the function code of each request, so that the corresponding use case can be positioned through each code function, the corresponding code function can also be positioned through the use case, and each use case has a corresponding editor, so that a related responsible person can be further positioned.
In this embodiment, in order to improve the security of data, the target correspondence may be stored in a block chain.
In at least one embodiment of the present invention, the test data recording method further includes:
determining configuration code functions of the target use case, and determining a first number of the configuration code functions;
determining a second number of the target code functions;
calculating the quotient of the second quantity and the first quantity as the function coverage rate of the target use case, and storing the function coverage rate to a block chain;
when the function coverage rate is larger than or equal to a preset threshold value, determining that the quality of the target use case passes verification; or
And when the function coverage rate is smaller than the preset threshold value, determining that the quality of the target use case does not pass the verification, and feeding back the quality of the target use case to a specified terminal device.
The preset threshold may be configured by self-definition, such as: 97 percent.
The appointed terminal equipment can be equipment of a user editing the target use case, and then unqualified use cases can be fed back to corresponding responsible persons in time, so that the unqualified use cases can be modified in time, and a normal test process of images is avoided.
Therefore, the embodiment can not only check the function coverage rate of the use case, but also further automatically evaluate the quality of the use case to assist in more accurate testing.
In at least one embodiment of the present invention, the test data recording method further includes:
and when the target code function is monitored to be modified, feeding back the target use case serving as a use case to be regressed to the specified terminal equipment.
By the implementation method, the test case with the modified code function needing regression can be quickly located, the workload required by test return is effectively reduced, the test feedback speed is increased, and the risk of test omission is reduced.
It can be seen from the above technical solutions that, the present invention can respond to a test data recording instruction, intercept each request of a test system by using an Agent technology, obtain a target identifier of the target request for each intercepted target request, the target identifier is used to determine a target case corresponding to the target request, determine whether to track the target request according to the target identifier, configure a tracking ID for the target request when determining to track the target request, set an internal variable in an execution thread of the target request, record a variable value of the internal variable according to the tracking ID by using a bytecode augmentation technology, track and capture the internal variable in real time according to the tracking ID by using the bytecode augmentation technology, record a variable value of the internal variable, and obtain a target code function from the variable value in response to a recording ending instruction, and establishing a target corresponding relation according to the target code function and the target identification so as to establish a corresponding relation between a target case and the target code function corresponding to each intercepted target request, effectively solving the problem that the relation between the case and the code function cannot be established in the prior art, storing the target corresponding relation and the variable value into a database, and further realizing the parallel recording of the test data.
Fig. 2 is a functional block diagram of a test data recording apparatus according to a preferred embodiment of the present invention. The test data recording device 11 includes an intercepting unit 110, an obtaining unit 111, a determining unit 112, a configuring unit 113, a recording unit 114, a creating unit 115, and a storing unit 116. The module/unit referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and that can perform a fixed function, and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
In response to the test data recording instruction, the interception unit 110 intercepts each request of the test system using an Agent technology.
In this embodiment, the test data recording instruction may be triggered by a related developer or tester.
The Agent is equivalent to an interceptor, before the main method is executed, Agent codes are executed, and the codes in the Agent are monitoring codes which are injected into the codes needing to be monitored by using a byte code modification tool, so that the execution time, parameters and the like of the codes are captured.
Through the Agent technology, each request of the test system can be effectively intercepted, so that the parallel recording of the test data is realized in an auxiliary manner.
For each intercepted target request, the obtaining unit 111 obtains a target identifier of the target request, where the target identifier is used to determine a target use case corresponding to the target request.
In this embodiment, the target identifier may include, but is not limited to: IP, digital signature, etc., the present invention does not limit the form of the target identification.
The determining unit 112 determines whether to track the target request according to the target identifier.
It will be appreciated that not all requests have trace requirements, and therefore, it is first determined whether the target request has the trace necessity to avoid burdening the system with performing meaningless traces.
Specifically, the determining unit 112 determines whether to track the target request according to the target identifier includes:
calling a pre-configured global identification list, wherein the global identification list stores identifications of all requests needing to be tracked;
traversing the global identification list with the target identification;
determining to track the target request when traversing to an identifier matching the target identifier in the global identifier list.
Through the implementation mode, whether the target request is tracked can be determined according to actual requirements, and the system load is effectively reduced.
In the embodiment, historical recording data is obtained, all requests needing to be recorded are determined according to the historical recording data, identifiers of all the requests are obtained, and the global identifier list is configured according to the identifiers of all the requests; and/or
And receiving the identifier uploaded by the user, and configuring the global identifier list according to the received identifier.
When it is determined to trace the target request, the configuration unit 113 configures a trace ID for the target request, and sets an internal variable in an execution thread of the target request.
The internal variables are used for recording data in a test process, namely data generated when the target use case is executed.
In at least one embodiment of the present invention, the configuring unit 113 configures a trace ID for the target request, and setting an internal variable in an execution thread of the target request includes:
acquiring a request cookie of the target request;
configuring the tracking ID in the request cookie;
acquiring an execution thread of the target request;
setting an Inheritable ThreadLocal variable as the internal variable in the execution thread.
The tracking ID may be a character string with a preset number of bits, and the tracking ID may be obtained by converting according to the target identifier.
For example: when the target identification bit 123 is located, a check bit 15 is added on the basis of the target identification, and the tracking ID is 12315.
It can be understood that, since the trace ID corresponds to the target request and the target request corresponds to the target identifier, the trace ID and the target identifier also have a one-to-one correspondence relationship, which can provide a basis for subsequently establishing a relationship between a use case and a code function.
Further, the inheritable thread local variable is an internal variable of the execution thread, and enables a child thread to inherit the value of a parent thread, so that the data placed in the inheritable thread local variable can be acquired by inheritance, that is, the variable value of the internal variable can be acquired by the child thread in the execution thread.
The recording unit 114 records the variable values of the internal variables according to the tracking ID using a bytecode augmentation technique.
The bytecode enhancement technology may be a Java bytecode enhancement technology, which means that after Java bytecode is generated, the Java bytecode is modified to enhance the function thereof, and this way is equivalent to modifying the binary file of the application program. The Java bytecode enhancement technology is mainly to reduce redundant codes, improve performance, and the like.
In this embodiment, by the bytecode augmentation technology, the internal variable can be tracked and captured in real time according to the tracking ID, and the variable value of the internal variable can be recorded.
In response to the instruction for ending recording, the establishing unit 115 obtains the target code function from the variable value, and establishes a target corresponding relationship according to the target code function and the target identifier.
The recording ending instruction can also be triggered by related developers or testers.
In at least one embodiment of the present invention, the establishing unit 115 obtains an object code function from the variable value, and establishing an object correspondence relationship according to the object code function and the object identifier includes:
acquiring the target code function from the variable value by adopting a regular expression, wherein the target code function comprises a function name and a parameter;
determining a target use case corresponding to the target request according to the target identifier;
and associating the target use case with the target code function to obtain a corresponding relation between the target use case and the target code function as the target corresponding relation.
Through the implementation mode, the corresponding relation between the target use case corresponding to each intercepted target request and the target code function can be established, and the problem that the relation between the use case and the code function cannot be established in the prior art is effectively solved.
In at least one embodiment of the present invention, the value of the request cookie is cleared when it is determined that the target request is not tracked and/or in response to the end recording instruction.
Through the implementation mode, when the target request is determined not to be tracked or stopped being tracked, the cookie requesting space can be released in time, so that the running performance of the system is improved.
The saving unit 116 saves the target correspondence and the variable value to a database.
The problem of parallel recording of test data can be effectively solved by warehousing the corresponding relation between the intercepted use case and the function code of each request, so that the corresponding use case can be positioned through each code function, the corresponding code function can also be positioned through the use case, and each use case has a corresponding editor, so that a related responsible person can be further positioned.
In this embodiment, in order to improve the security of data, the target correspondence may be stored in a block chain.
In at least one embodiment of the present invention, a configuration code function of the target use case is determined, and a first number of the configuration code function is determined;
determining a second number of the target code functions;
calculating the quotient of the second quantity and the first quantity as the function coverage rate of the target use case, and storing the function coverage rate to a block chain;
when the function coverage rate is larger than or equal to a preset threshold value, determining that the quality of the target use case passes verification; or
And when the function coverage rate is smaller than the preset threshold value, determining that the quality of the target use case does not pass the verification, and feeding back the quality of the target use case to a specified terminal device.
The preset threshold may be configured by self-definition, such as: 97 percent.
The appointed terminal equipment can be equipment of a user editing the target use case, and then unqualified use cases can be fed back to corresponding responsible persons in time, so that the unqualified use cases can be modified in time, and a normal test process of images is avoided.
Therefore, the embodiment can not only check the function coverage rate of the use case, but also further automatically evaluate the quality of the use case to assist in more accurate testing.
In at least one embodiment of the present invention, when it is monitored that the target code function is modified, the target use case is fed back to the specified terminal device as a use case to be regressed.
By the implementation method, the test case with the modified code function needing regression can be quickly located, the workload required by test return is effectively reduced, the test feedback speed is increased, and the risk of test omission is reduced.
It can be seen from the above technical solutions that, the present invention can respond to a test data recording instruction, intercept each request of a test system by using an Agent technology, obtain a target identifier of the target request for each intercepted target request, the target identifier is used to determine a target case corresponding to the target request, determine whether to track the target request according to the target identifier, configure a tracking ID for the target request when determining to track the target request, set an internal variable in an execution thread of the target request, record a variable value of the internal variable according to the tracking ID by using a bytecode augmentation technology, track and capture the internal variable in real time according to the tracking ID by using the bytecode augmentation technology, record a variable value of the internal variable, and obtain a target code function from the variable value in response to a recording ending instruction, and establishing a target corresponding relation according to the target code function and the target identification so as to establish a corresponding relation between a target case and the target code function corresponding to each intercepted target request, effectively solving the problem that the relation between the case and the code function cannot be established in the prior art, storing the target corresponding relation and the variable value into a database, and further realizing the parallel recording of the test data.
Fig. 3 is a schematic structural diagram of an electronic device implementing a test data recording method according to a preferred embodiment of the present invention.
The electronic device 1 may comprise a memory 12, a processor 13 and a bus, and may further comprise a computer program, such as a test data recording program, stored in the memory 12 and executable on the processor 13.
It will be understood by those skilled in the art that the schematic diagram is merely an example of the electronic device 1, and does not constitute a limitation to the electronic device 1, the electronic device 1 may have a bus-type structure or a star-type structure, the electronic device 1 may further include more or less hardware or software than those shown in the figures, or different component arrangements, for example, the electronic device 1 may further include an input and output device, a network access device, and the like.
It should be noted that the electronic device 1 is only an example, and other existing or future electronic products, such as those that can be adapted to the present invention, should also be included in the scope of the present invention, and are included herein by reference.
The memory 12 includes at least one type of readable storage medium, which includes flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 12 may in some embodiments be an internal storage unit of the electronic device 1, for example a removable hard disk of the electronic device 1. The memory 12 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the electronic device 1. Further, the memory 12 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 12 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of a test data recording program, etc., but also to temporarily store data that has been output or is to be output.
The processor 13 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 13 is a Control Unit (Control Unit) of the electronic device 1, connects various components of the electronic device 1 by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (for example, executing a test data recording program and the like) stored in the memory 12 and calling data stored in the memory 12.
The processor 13 executes an operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the above-mentioned embodiments of the test data recording method, such as the steps shown in fig. 1.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an intercepting unit 110, an obtaining unit 111, a determining unit 112, a configuring unit 113, a recording unit 114, a creating unit 115, a saving unit 116.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a computer device, or a network device) or a processor (processor) to execute parts of the test data recording method according to the embodiments of the present invention.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
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: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one arrow is shown in FIG. 3, but this does not indicate only one bus or one type of bus. The bus is arranged to enable connection communication between the memory 12 and at least one processor 13 or the like.
Although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 13 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
Fig. 3 only shows the electronic device 1 with components 12-13, and it will be understood by a person skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
Referring to fig. 1, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a test data recording method, and the processor 13 can execute the plurality of instructions to implement:
responding to a test data recording instruction, and intercepting each request of the test system by adopting an Agent technology;
for each intercepted target request, acquiring a target identifier of the target request, wherein the target identifier is used for determining a target use case corresponding to the target request;
determining whether to track the target request according to the target identifier;
when the target request is determined to be tracked, configuring a tracking ID for the target request, and setting an internal variable in an execution thread of the target request;
recording the variable value of the internal variable according to the tracking ID by adopting a byte code enhancement technology;
responding to a recording ending instruction, acquiring a target code function from the variable value, and establishing a target corresponding relation according to the target code function and the target identification;
and storing the target corresponding relation and the variable value to a database.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the instruction, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A test data recording method is characterized by comprising the following steps:
responding to a test data recording instruction, and intercepting each request of the test system by adopting an Agent technology;
for each intercepted target request, acquiring a target identifier of the target request, wherein the target identifier is used for determining a target use case corresponding to the target request;
determining whether to track the target request according to the target identifier;
when the target request is determined to be tracked, configuring a tracking ID for the target request, and setting an internal variable in an execution thread of the target request;
recording the variable value of the internal variable according to the tracking ID by adopting a byte code enhancement technology;
responding to a recording ending instruction, acquiring a target code function from the variable value, and establishing a target corresponding relation according to the target code function and the target identification;
and storing the target corresponding relation and the variable value to a database.
2. The method of claim 1, wherein the determining whether to track the target request based on the target identification comprises:
calling a pre-configured global identification list, wherein the global identification list stores identifications of all requests needing to be tracked;
traversing the global identification list with the target identification;
determining to track the target request when traversing to an identifier matching the target identifier in the global identifier list.
3. The method for recording test data according to claim 1, wherein the configuring a trace ID for the target request and setting an internal variable in an execution thread of the target request comprises:
acquiring a request cookie of the target request;
configuring the tracking ID in the request cookie;
acquiring an execution thread of the target request;
setting an Inheritable ThreadLocal variable as the internal variable in the execution thread.
4. The method for recording test data according to claim 1, wherein the obtaining an object code function from the variable value and establishing an object correspondence according to the object code function and the object identifier comprises:
acquiring the target code function from the variable value by adopting a regular expression, wherein the target code function comprises a function name and a parameter;
determining a target use case corresponding to the target request according to the target identifier;
and associating the target use case with the target code function to obtain a corresponding relation between the target use case and the target code function as the target corresponding relation.
5. The test data recording method of claim 1, wherein the test data recording method further comprises:
clearing the value of the request cookie when determining not to track the target request and/or in response to the recording ending instruction.
6. The test data recording method of claim 1, wherein the test data recording method further comprises:
determining configuration code functions of the target use case, and determining a first number of the configuration code functions;
determining a second number of the target code functions;
calculating the quotient of the second quantity and the first quantity as the function coverage rate of the target use case, and storing the function coverage rate to a block chain;
when the function coverage rate is larger than or equal to a preset threshold value, determining that the quality of the target use case passes verification; or
And when the function coverage rate is smaller than the preset threshold value, determining that the quality of the target use case does not pass the verification, and feeding back the quality of the target use case to a specified terminal device.
7. The test data recording method of claim 1, wherein the test data recording method further comprises:
and when the target code function is monitored to be modified, feeding back the target use case serving as a use case to be regressed to the specified terminal equipment.
8. A test data recording apparatus, characterized in that the test data recording apparatus comprises:
the intercepting unit is used for responding to the test data recording instruction and intercepting each request of the test system by adopting an Agent technology;
an obtaining unit, configured to obtain, for each intercepted target request, a target identifier of the target request, where the target identifier is used to determine a target use case corresponding to the target request;
the determining unit is used for determining whether to track the target request according to the target identifier;
the configuration unit is used for configuring a tracking ID for the target request and setting an internal variable in an execution thread of the target request when the target request is determined to be tracked;
the recording unit is used for recording the variable value of the internal variable according to the tracking ID by adopting a byte code enhancement technology;
the establishing unit is used for responding to a recording ending instruction, acquiring a target code function from the variable value and establishing a target corresponding relation according to the target code function and the target identification;
and the storage unit is used for storing the target corresponding relation and the variable value into a database.
9. An electronic device, characterized in that the electronic device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement a test data recording method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein at least one instruction that is executable by a processor in an electronic device to implement the test data recording method of any one of claims 1 to 7.
CN202010968254.8A 2020-09-15 2020-09-15 Test data recording method, device, equipment and medium Active CN112015663B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010968254.8A CN112015663B (en) 2020-09-15 2020-09-15 Test data recording method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010968254.8A CN112015663B (en) 2020-09-15 2020-09-15 Test data recording method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN112015663A true CN112015663A (en) 2020-12-01
CN112015663B CN112015663B (en) 2024-03-15

Family

ID=73521560

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010968254.8A Active CN112015663B (en) 2020-09-15 2020-09-15 Test data recording method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN112015663B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112416798A (en) * 2020-12-04 2021-02-26 深圳前海微众银行股份有限公司 Data processing method, device, equipment and storage medium
CN112749094A (en) * 2021-01-14 2021-05-04 中国工商银行股份有限公司 Test case generation method and device
CN113157592A (en) * 2021-05-24 2021-07-23 杭州笨马网络技术有限公司 Visual defect positioning method
CN115712243A (en) * 2022-11-04 2023-02-24 北京和利时工业软件有限公司 Correction method, device, equipment and medium
WO2023093139A1 (en) * 2021-11-25 2023-06-01 中移(苏州)软件技术有限公司 Resource creation method and apparatus, and electronic device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020199172A1 (en) * 2001-06-07 2002-12-26 Mitchell Bunnell Dynamic instrumentation event trace system and methods
CN102855179A (en) * 2011-06-30 2013-01-02 国际商业机器公司 Program debugging method and system in virtual machine environment
US20150007138A1 (en) * 2013-06-26 2015-01-01 Sap Ag Method and system for incrementally updating a test suite utilizing run-time application executions
CN110489315A (en) * 2019-07-18 2019-11-22 威富通科技有限公司 A kind of tracking of operation requests, tracking device and server
CN110874324A (en) * 2019-10-14 2020-03-10 平安普惠企业管理有限公司 Test result data storage method and device, terminal equipment and storage medium
CN111400189A (en) * 2020-03-25 2020-07-10 平安银行股份有限公司 Code coverage rate monitoring method and device, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020199172A1 (en) * 2001-06-07 2002-12-26 Mitchell Bunnell Dynamic instrumentation event trace system and methods
CN102855179A (en) * 2011-06-30 2013-01-02 国际商业机器公司 Program debugging method and system in virtual machine environment
US20150007138A1 (en) * 2013-06-26 2015-01-01 Sap Ag Method and system for incrementally updating a test suite utilizing run-time application executions
CN110489315A (en) * 2019-07-18 2019-11-22 威富通科技有限公司 A kind of tracking of operation requests, tracking device and server
CN110874324A (en) * 2019-10-14 2020-03-10 平安普惠企业管理有限公司 Test result data storage method and device, terminal equipment and storage medium
CN111400189A (en) * 2020-03-25 2020-07-10 平安银行股份有限公司 Code coverage rate monitoring method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
高远;杨欣;李凯;: "基于JTest的自动化单元测试技术", 指挥信息系统与技术, no. 04, pages 95 - 99 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112416798A (en) * 2020-12-04 2021-02-26 深圳前海微众银行股份有限公司 Data processing method, device, equipment and storage medium
CN112416798B (en) * 2020-12-04 2024-04-09 深圳前海微众银行股份有限公司 Data processing method, device, equipment and storage medium
CN112749094A (en) * 2021-01-14 2021-05-04 中国工商银行股份有限公司 Test case generation method and device
CN113157592A (en) * 2021-05-24 2021-07-23 杭州笨马网络技术有限公司 Visual defect positioning method
WO2023093139A1 (en) * 2021-11-25 2023-06-01 中移(苏州)软件技术有限公司 Resource creation method and apparatus, and electronic device and storage medium
CN115712243A (en) * 2022-11-04 2023-02-24 北京和利时工业软件有限公司 Correction method, device, equipment and medium

Also Published As

Publication number Publication date
CN112015663B (en) 2024-03-15

Similar Documents

Publication Publication Date Title
CN112015663B (en) Test data recording method, device, equipment and medium
CN112559535B (en) Multithreading-based asynchronous task processing method, device, equipment and medium
CN111914029A (en) Block chain-based medical data calling method and device, electronic equipment and medium
CN113468049A (en) Test method, device, equipment and medium based on configurable interface
CN112948275A (en) Test data generation method, device, equipment and storage medium
CN113806434A (en) Big data processing method, device, equipment and medium
CN111694843A (en) Missing number detection method and device, electronic equipment and storage medium
CN114116400A (en) Application exception handling method, device, equipment and medium based on log printing
CN112287318B (en) Cross-application login method, device, equipment and medium
CN114519084A (en) Block chain-based medical data inspection method, device, equipment and medium
CN111277626B (en) Server upgrading method and device, electronic equipment and medium
CN114185502B (en) Log printing method, device, equipment and medium based on production line environment
CN114036068A (en) Update detection method, device, equipment and storage medium based on privacy security
CN114826725A (en) Data interaction method, device, equipment and storage medium
CN113505079A (en) Application program testing method, device, equipment and medium
CN114124835A (en) Interface-based data transmission method, device, equipment and medium
CN114510400A (en) Task execution method and device, electronic equipment and storage medium
CN114399397A (en) Renewal tracking method, device, equipment and medium
CN112667244A (en) Data verification method and device, electronic equipment and computer readable storage medium
CN112905470A (en) Interface calling method and device, computer equipment and medium
CN113360398B (en) Hybrid application program testing method, device, equipment and medium
CN112000945A (en) Artificial intelligence based authorization method, device, equipment and medium
CN114138378A (en) Non-invasive current-limiting fusing method, device, equipment and medium
CN117830010A (en) Order state consistency detection method, device, equipment and storage medium
CN115001805A (en) Single sign-on method, device, equipment and 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
GR01 Patent grant
GR01 Patent grant