CN116302966A - Dynamic pile inserting method in Java unit test - Google Patents

Dynamic pile inserting method in Java unit test Download PDF

Info

Publication number
CN116302966A
CN116302966A CN202310089505.9A CN202310089505A CN116302966A CN 116302966 A CN116302966 A CN 116302966A CN 202310089505 A CN202310089505 A CN 202310089505A CN 116302966 A CN116302966 A CN 116302966A
Authority
CN
China
Prior art keywords
point
declaration
embedded
points
list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310089505.9A
Other languages
Chinese (zh)
Inventor
邓一波
李文俊
龚旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Wanmi Information Technology Co ltd
Original Assignee
Nanjing Wanmi Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Wanmi Information Technology Co ltd filed Critical Nanjing Wanmi Information Technology Co ltd
Priority to CN202310089505.9A priority Critical patent/CN116302966A/en
Publication of CN116302966A publication Critical patent/CN116302966A/en
Pending legal-status Critical Current

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/3696Methods or tools to render software testable
    • 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/3688Test management for test execution, e.g. scheduling of test suites
    • 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

Abstract

The invention discloses a dynamic pile inserting method in Java unit test, which belongs to the technical field of big data, and comprises the steps of defining three types of point interfaces, embedded point declarations and embedded points, solving the technical problem of providing different point realization contents according to different user test scenes by declaration points and embedded points.

Description

Dynamic pile inserting method in Java unit test
Technical Field
The invention belongs to the technical field of big data, and particularly relates to a dynamic pile inserting method in Java unit testing.
Background
After the JAVA codes are written, the main unit test scheme is to perform unit test through a junit framework.
However, when the code is tested, coupling exists between the methods, the method to be tested can not call other methods in order to fulfill the function requirement, and the called method can not be normally used during the test due to the following reasons:
1. the called method is developed by other people, is not realized at present, and is only an interface;
2. the called method depends on the running environment, and the testing environment cannot normally run, such as network service, database service and the like.
At this time, if the method is to be tested, the non-executable methods called inside the method need to be bypassed, and the method is finished through the methods of Mock (instrumentation).
The JAVA common open source Mock framework has Mockito, JMock and JMockit and the like.
The current prior art cannot address the test requirements of the following class 3 scenario:
scene 1: the extreme test condition generates a file according to the current timestamp file, and if the file exists, the establishment failure is prompted. However, since an existing file cannot be artificially constructed at the moment of file establishment, the establishment failure scene cannot be tested. The user cannot be finished to truly test whether the execution result in the scene meets the expected requirement. (the same scenario includes extreme scenario constructions such as, but not limited to, disk full, memory full, thread full, etc.)
Scene 2: simulation of simultaneous calls via different threads cannot be accomplished under a multi-threaded scenario.
Scene 3: when the task runs to half, suddenly stopping (such as analog service power-off, abnormal restarting); the prior art fails to test whether half of the tasks that were performed will be re-performed when the service was restarted.
Disclosure of Invention
The invention aims to provide a dynamic pile inserting method in Java unit test, which solves the technical problem of providing different points to realize content according to different user test scenes by means of declaring points and embedding points.
In order to achieve the above purpose, the invention adopts the following technical scheme: a method for dynamic instrumentation in Java unit test comprises the following steps:
step 1: establishing a code input module to be tested and a Java unit code test server, wherein a user inputs a code to be tested in the code input module to be tested, and the code input module to be tested transmits the code to be tested to the Java unit code test server through the Internet;
a test code cache module, a statement point module and a buried point module are established in a Java unit code test server, and the test code cache module acquires and stores codes to be tested;
step 2: defining the name of a point interface in a declaration point module, wherein the types of the points comprise three types: universal type point, alternative type point and interrupt type point;
respectively defining three types of point interfaces;
step 3: in the statement point module, the buried point statement is carried out, and the concrete operation is as follows:
step S3-1: acquiring a global point diagram from a memory, and acquiring a point list of storage points;
step S3-2: judging whether a user opens a dynamic pile inserting function: if not, not performing any operation and returning; if so, executing the step S3-3;
step S3-3: declaring the embedded point at any position of the code to be tested, and generating a keyword of the point;
step 4: in the embedded point module, embedded points are carried out in the code to be detected, and the method specifically comprises the following steps:
step S4-1: acquiring a global point diagram from a memory;
step S4-2: judging whether a user opens a dynamic pile inserting function: if not, not performing any operation and returning; if so, executing the step S4-3;
step S4-3: inquiring the combination of the last-last class in the method stack when the point declaration is called, the last-last method in the method stack when the point declaration is called, the last-last class in the method stack when the point declaration is called, the last-last method in the method stack when the point declaration is called and the operation name defined by the point declaration as the key words of the point;
step S4-4: according to the key words of the points, a point list is called from the point diagram, and whether the points exist or not is inquired in the point list: if not, the point is put into the memory, and the step S4-5 is executed; if so, executing the step S4-7;
step S4-5: re-invoking the point list from the point diagram through the key words of the points;
step S4-6: circularly adding the embedded points into a point list according to the repeated embedding times of the points;
step S4-7: ending the burying point;
step 5: the statement point module recalls a point list from the point diagram through the key words of the points;
step 6: judging whether the obtained point list is empty, if so, directly returning to the state, otherwise, continuing;
step 7: and deleting and acquiring a point buried by the user from the point list, and executing the point at the statement corresponding to the buried point.
Preferably, the method corresponding to the defined three types of point interfaces specifically comprises the following steps:
the method corresponding to the point interface of the universal point is to take a parameter list transmitted by a user when the point is embedded as a parameter, and execute certain preset condition construction or any exception throwing in the point when the point is called;
the method corresponding to the point interface of the replacement point is to take an original return value of executing a certain method at the user declaration place and a parameter list transmitted when the user declares the embedded point as parameters, and execute the replacement of the original return value when the point is called;
the method corresponding to the point interface of the interrupt point is to take a parameter list which is transmitted when a user declares the embedded point as a parameter, judge whether the interrupt is needed according to the transmitted parameter when the user calls the embedded point, and return the first value of the list to true if the interrupt is needed; the return value of the parameter list is whether interruption is carried out or whether the return in advance has influence on the test code flow;
preferably, when executing step 3, three methods are respectively adopted to declare the embedded point according to the type of the point, and the method specifically comprises the following steps:
method 3-1: the method for declaring the embedded universal point specifically uses the number of times of upward acquisition of the < method stack > and the operation name of the point as parameters, and performs the process of searching the matched point from the memory and performing the process at the declaration;
method 3-2: the method for declaring the embedded replacement point is specifically to take the number of times of upward acquisition of the < method stack >, the operation name of the point, the original return value of a method executed at the declaration and a parameter list transmitted when the embedded point is declared as parameters, execute the method in the declaration, search the matched point from the memory and execute the method;
method 3-3: the method for declaring the embedded interrupt type point specifically uses the number of times of upward acquisition of the < method stack >, the operation name of the point and the parameter list transmitted when the embedded point is declared as parameters, executes the method to find the matched point from the memory at the declaration position, executes the matched point and returns the execution result.
Preferably, in each of the method 3-1, the method 3-2 and the method 3-3, the key of the forming point is combined with the number of times of < method stack > and the operation name of the point for querying the point at the declaration.
Preferably, the dot pattern has the structure:
Map<String,ArrayList<IBuryingPointTException>>pointMap;
wherein the key of the map is used for storing the key of the point, and the value of the map is used for storing the point list pointList of the point.
The method for dynamically inserting piles in Java unit test solves the technical problem that different points are provided for realizing contents according to different user test scenes in a manner of declaring points and embedding points, is comprehensive in coverage, and can be used for covering more test scenes by inserting piles compared with JMockit, including scenes such as extreme test condition construction, test under a multithreading scene, process/service shutdown test and the like, is flexible, and can be used for comparing the declaration position of the embedded points of the JMockit to follow service codes instead of unit test codes.
Drawings
FIG. 1 is a flow chart of declaring an executed call after finding a buried generic point declaration at the code side to be tested of the present invention;
FIG. 2 is a flow chart of the present invention in which points are embedded after finding embedded universal point declarations at the code side to be tested.
Detailed Description
Description of the terminology:
junit: JUnit, a regression testing framework (regression testing framework). The Junit test is a programmer test, the so-called white-box test, because the programmer knows How the software under test (How) performs the function and What (What) functions. Junit is a set of frameworks that inherit the TestCase class and can be used for unit testing.
The method comprises the following steps: the minimum execution unit of the Java thread running code is a method, the method is similar to the function concept of C++, the method in the Java can call other methods and can also declare variables, the life cycle of the method comprises the method start, and the method end/exception in the running of the method; the methods in java belong to the Class (Class).
An interface: an Interface (english) is an abstract type in the JAVA programming language, which is a collection of abstract methods, and the Interface is usually declared by Interface. One class implements the abstract method defined in the interface by inheriting the way the interface is.
The method call stack: the method call stack represents the behavior of the method call sequence. He identifies the calling sequence of the method, such as the method1 of Class1.during the operation of the method, and calls the Class2.method2 method; then the method call stack is denoted as class1.method1 (pushed onto the stack) →class2.method2 (pushed onto the stack) →class1.method1 (pulled off the stack).
Thread: the java process operates by the thread, and besides the main thread, the java can establish a thread by inheriting the java.land.thread class, and the established thread is started by the start () method.
Agentlib is a java language used to pass through a specific jar package file, through the java command line parameter-Agentlib or through the java virtual machine API.
The agentlib is implanted into the java virtual machine to obtain the java.
After the implantation is successful, when the java process starts, a java. Lang. Instrumentation (java encoder) object is provided as a parameter to a compiler receiving class configured in the agentlib configuration file.
1-2, a method for dynamic instrumentation in Java unit testing, comprising the steps of:
step 1: establishing a code input module to be tested and a Java unit code test server, wherein a user inputs a code to be tested in the code input module to be tested, and the code input module to be tested transmits the code to be tested to the Java unit code test server through the Internet;
a test code cache module, a statement point module and a buried point module are established in a Java unit code test server, and the test code cache module acquires and stores codes to be tested;
step 2: defining the name of a point interface in a declaration point module, wherein the types of the points comprise three types: universal type point, alternative type point and interrupt type point;
respectively defining three types of point interfaces;
the method corresponding to the three defined point interfaces specifically comprises the following steps:
the method corresponding to the point interface of the universal point is to take a parameter list transmitted by a user when the point is embedded as a parameter, and execute certain preset condition construction or any exception throwing in the point when the point is called;
the interface name of the universal Point is:
com.freez.utils.clazz.IBuryingPointTException;
the interface defines:
< T extends Exception > void buryingPointTException (object..params) method of thws T;
the parameter params is a parameter list which is transmitted when a user declares to embed the point, and the method execution semantics are that when the point is called, the user can construct a certain preset condition in the point and can throw any abnormality;
the method corresponding to the point interface of the replacement point is to take an original return value of executing a certain method at the user declaration place and a parameter list transmitted when the user declares the embedded point as parameters, and execute the replacement of the original return value when the point is called;
the interface name of the replacement Point is:
com.freez.utils.clazz.IBuryingPointReplace;
the interface defines a < T > T buryingPointReplace (T main objects, objects.) method, the parameter main objects being the original return value for the user's declaration to perform a method, the parameter other objects being the list of parameters that the user has passed in when declaring embedding the point; the method performs semantics in that when this point is called, the original return value can be replaced.
The method corresponding to the point interface of the interrupt point is to take a parameter list which is transmitted when a user declares the embedded point as a parameter, judge whether the interrupt is needed according to the transmitted parameter when the user calls the embedded point, and return the first value of the list to true if the interrupt is needed; the return value of the parameter list is whether interruption is carried out or whether the return in advance has influence on the test code flow;
the interface name of the interrupt Point is:
com.freez.utils.clazz.IBuryingPointTerminate;
the interface defines a boundary [ ] terminate (object..params) method, the parameter Params is a list of parameters which are input when the user declares to embed the point, and the return value is whether to interrupt and return in advance or not to influence the test code flow; the method comprises the following steps: when this point is called, it can be determined, based on the incoming parameters, if an interrupt is required, if so, the first value of the list should be returned to true.
Step 3: in the statement point module, the buried point statement is carried out, and the concrete operation is as follows:
step S3-1: acquiring a global point diagram from a memory, and acquiring a point list of storage points;
step S3-2: judging whether a user opens a dynamic pile inserting function: if not, not performing any operation and returning; if so, executing the step S3-3;
step S3-3: declaring the embedded point at any position of the code to be tested, and generating a keyword of the point;
the embedded point declaration is carried out by three methods according to the type of the point, and the method specifically comprises the following steps:
method 3-1: the method for declaring the embedded universal point specifically uses the number of times of upward acquisition of the < method stack > and the operation name of the point as parameters, and performs the process of searching the matched point from the memory and performing the process at the declaration;
the method name for declaring the embedded universal point is:
public static void buryingPointTException(int maxDeep,String opt,Object[]params)throws Throwabl;
the parameter maxDeep is used for upwardly acquiring the times of the < method stack >, the parameter opt is used for defining the operation name of the point, and the maxDeep and opt are combined to form a storage key of the point and used for inquiring the point at the declaration; parameter params is a list of parameters that the user enters when declaring to embed the point; the method semantics are that at this statement, the matching points are looked up from memory and executed.
Method 3-2: the method for declaring the embedded replacement point is specifically to take the number of times of upward acquisition of the < method stack >, the operation name of the point, the original return value of a method executed at the declaration and a parameter list transmitted when the embedded point is declared as parameters, execute the method in the declaration, search the matched point from the memory and execute the method;
the name of the method for declaring the embedded replacement point is:
public static<T>T buryingPointReplace(int maxDeep,String opt,T mainObject,Object[]otherParams);
the parameter maxDeep is used for upwardly acquiring the times of the < method stack >, the parameter opt is used for defining the operation name of the point, and the maxDeep and opt are combined to form a storage keyword of the point and used for inquiring the point at the statement place; the parameter mainObject is the original return value for executing a method at the user declaration, the parameter params is the list of parameters that the user enters when declaring to embed the point, and the semantics of the method is that at this declaration, the matching point is looked up from memory and executed.
Method 3-3: the method for declaring the embedded interrupt type point specifically uses the number of times of upward acquisition of the < method stack >, the operation name of the point and the parameter list transmitted when the embedded point is declared as parameters, executes the method to find the matched point from the memory at the declaration position, executes the matched point and returns the execution result.
The method for declaring the embedded interrupt point is named:
public static boolean[]buryingPointTerminate(int maxDeep,String opt,Object[]params);
the parameter maxDeep is used for upwardly acquiring the times of < method stack >, the parameter opt is used for defining the operation name of a point, the maxDeep and opt are combined to form a storage keyword of the point and used for inquiring the point at the declaration position, the parameter params is a parameter list transmitted by a user when the user declares to embed the point, the return value is a point execution result, the method semantics is that the matched point is searched from a memory at the declaration position and is executed, and the execution result is returned.
Preferably, in each of the method 3-1, the method 3-2 and the method 3-3, the key of the forming point is combined with the number of times of < method stack > and the operation name of the point for querying the point at the declaration.
Step 4: in the embedded point module, embedded points are carried out in the code to be detected, and the method specifically comprises the following steps:
step S4-1: acquiring a global point diagram from a memory;
step S4-2: judging whether a user opens a dynamic pile inserting function: if not, not performing any operation and returning; if so, executing the step S4-3;
step S4-3: inquiring the combination of the last-last class in the method stack when the point declaration is called, the last-last method in the method stack when the point declaration is called, the last-last class in the method stack when the point declaration is called, the last-last method in the method stack when the point declaration is called and the operation name defined by the point declaration as the key words of the point;
the method for embedding the universal point is named as follows:
public static void addBuryingPointTException(Class<?>penultimateClass,String penultimateClassMethod,Class<?>lastClass,String lastClassMethod,String opt,IBuryingPointTException buryingPoint,int addCount);
the method comprises the steps of calling a parameter penult time eclass as a last-to-last class in a method stack when the point declaration is called, calling a parameter penult time eclassmethod as a last-to-last method in the method stack when the point declaration is called, calling a parameter lastClassmethod as a last-to-last class in the method stack when the point declaration is called, calling a parameter lastClassmethod as a last-to-last method in the method stack when the point declaration is called, combining an operation name defined by the parameter opt as the point declaration, penultimateClass, penultimateClassMethod, lastClass, lastClassMethod and opt to form a storage keyword of a point, and inquiring the point by the declaration; the parameter buryingPoint is the realization class of the imported universal point interface, and the parameter addCount is the number of times that the point is repeatedly embedded; the method semantics are that the general point of the user is put into the memory to wait for the execution of the corresponding declaration.
The method for embedding the replacement point is named as:
public static void addBuryingPointReplace(Class<?>penultimateClass,String penultimateClassMethod,Class<?>lastClass,String lastClassMethod,String opt,IBuryingPointReplace buryingPointReplace,int addCount);
the method comprises the steps that a parameter penult is the last-to-last class in a method stack when a point declaration is called, a parameter penult is the last-to-last party in the method stack when the point declaration is called, a parameter lastClassmethod is the last-to-last class in the method stack when the point declaration is called, a parameter lastClassmethod is the last-to-last method in the method stack when the point declaration is called, a parameter opt is an operation name defined by the point declaration, and penultimateClass, penultimateClassMethod, lastClass, lastClassMethod and opt are combined to form a storage keyword of a point, wherein the storage keyword is used for inquiring the point by the declaration; the parameter buryingPointReplace is the realization class of the replacement point interface which is transmitted by a user, and the parameter addCount is the number of times that the point is repeatedly buried; the method semantics are that the replacement point of the user is put into the memory to wait for the execution of the corresponding declaration place.
The method for embedding the interruption point is named as:
public static void addBuryingPointTerminate(Class<?>penultimateClass,String penultimateClassMethod,Class<?>lastClass,String lastClassMethod,String opt,IBuryingPointTerminate buryingPointTerminate,int addCount);
the method comprises the steps of calling a parameter penult time eclass as a last-to-last class in a method stack when the point declaration is called, calling a parameter penult time eclassmethod as a last-to-last method in the method stack when the point declaration is called, calling a parameter lastClassmethod as a last-to-last class in the method stack when the point declaration is called, calling a parameter lastClassmethod as a last-to-last method in the method stack when the point declaration is called, combining an operation name defined by the parameter opt as the point declaration, penultimateClass, penultimateClassMethod, lastClass, lastClassMethod and opt to form a storage keyword of a point, and inquiring the point by the declaration; the parameter buryingPointTerminate is the realization class of the interrupt type point interface which is input by a user, and the parameter addCount is the number of times that the point is repeatedly buried; the method semantics are that interrupt points of a user are put into a memory to wait for execution of corresponding declarations.
Step S4-4: according to the key words of the points, a point list is called from the point diagram, and whether the points exist or not is inquired in the point list: if not, the point is put into the memory, and the step S4-5 is executed; if so, executing the step S4-7;
step S4-5: re-invoking the point list from the point diagram through the key words of the points;
step S4-6: circularly adding the embedded points into a point list according to the repeated embedding times of the points;
step S4-7: ending the burying point;
step 5: the statement point module recalls a point list from the point diagram through the key words of the points;
step 6: judging whether the obtained point list is empty, if so, directly returning to the state, otherwise, continuing;
step 7: and deleting and acquiring a point buried by the user from the point list, and executing the point at the statement corresponding to the buried point.
The dot pattern has the structure that:
Map<String,ArrayList<IBuryingPointTException>>pointMap;
wherein the key of the map is used for storing the key of the point, and the value of the map is used for storing the point list pointList of the point.
The method for dynamically inserting piles in Java unit test solves the technical problem that different points are provided for realizing contents according to different user test scenes in a manner of declaring points and embedding points, is comprehensive in coverage, and can be used for covering more test scenes by inserting piles compared with JMockit, including scenes such as extreme test condition construction, test under a multithreading scene, process/service shutdown test and the like, is flexible, and can be used for comparing the declaration position of the embedded points of the JMockit to follow service codes instead of unit test codes.

Claims (5)

1. A method for dynamic instrumentation in Java unit test is characterized in that: the method comprises the following steps:
step 1: establishing a code input module to be tested and a Java unit code test server, wherein a user inputs a code to be tested in the code input module to be tested, and the code input module to be tested transmits the code to be tested to the Java unit code test server through the Internet;
a test code cache module, a statement point module and a buried point module are established in a Java unit code test server, and the test code cache module acquires and stores codes to be tested;
step 2: defining the name of a point interface in a declaration point module, wherein the types of the points comprise three types: universal type point, alternative type point and interrupt type point;
respectively defining three types of point interfaces;
step 3: in the statement point module, the buried point statement is carried out, and the concrete operation is as follows:
step S3-1: acquiring a global point diagram from a memory, and acquiring a point list of storage points;
step S3-2: judging whether a user opens a dynamic pile inserting function: if not, not performing any operation and returning; if so, executing the step S3-3;
step S3-3: declaring the embedded point at any position of the code to be tested, and generating a keyword of the point;
step 4: in the embedded point module, embedded points are carried out in the code to be detected, and the method specifically comprises the following steps:
step S4-1: acquiring a global point diagram from a memory;
step S4-2: judging whether a user opens a dynamic pile inserting function: if not, not performing any operation and returning; if so, executing the step S4-3;
step S4-3: inquiring the combination of the last-last class in the method stack when the point declaration is called, the last-last method in the method stack when the point declaration is called, the last-last class in the method stack when the point declaration is called, the last-last method in the method stack when the point declaration is called and the operation name defined by the point declaration as the key words of the point;
step S4-4: according to the key words of the points, a point list is called from the point diagram, and whether the points exist or not is inquired in the point list: if not, the point is put into the memory, and the step S4-5 is executed; if so, executing the step S4-7;
step S4-5: re-invoking the point list from the point diagram through the key words of the points;
step S4-6: circularly adding the embedded points into a point list according to the repeated embedding times of the points;
step S4-7: ending the burying point;
step 5: the statement point module recalls a point list from the point diagram through the key words of the points;
step 6: judging whether the obtained point list is empty, if so, directly returning to the state, otherwise, continuing;
step 7: and deleting and acquiring a point buried by the user from the point list, and executing the point at the statement corresponding to the buried point.
2. The method for dynamic instrumentation in Java unit testing according to claim 1, wherein: the method corresponding to the three defined point interfaces specifically comprises the following steps:
the method corresponding to the point interface of the universal point is to take a parameter list transmitted by a user when the point is embedded as a parameter, and execute certain preset condition construction or any exception throwing in the point when the point is called;
the method corresponding to the point interface of the replacement point is to take an original return value of executing a certain method at the user declaration place and a parameter list transmitted when the user declares the embedded point as parameters, and execute the replacement of the original return value when the point is called;
the method corresponding to the point interface of the interrupt point is to take a parameter list which is transmitted when a user declares the embedded point as a parameter, judge whether the interrupt is needed according to the transmitted parameter when the user calls the embedded point, and return the first value of the list to true if the interrupt is needed; the return value of the parameter list is whether interruption is carried out or whether early return has influence on the test code flow.
3. The method for dynamic instrumentation in Java unit testing according to claim 1, wherein: when executing the step 3, the embedded point declaration is respectively carried out by adopting three methods according to the type of the point, and the method specifically comprises the following steps:
method 3-1: the method for declaring the embedded universal point specifically uses the number of times of upward acquisition of the < method stack > and the operation name of the point as parameters, and performs the process of searching the matched point from the memory and performing the process at the declaration;
method 3-2: the method for declaring the embedded replacement point is specifically to take the number of times of upward acquisition of the < method stack >, the operation name of the point, the original return value of a method executed at the declaration and a parameter list transmitted when the embedded point is declared as parameters, execute the method in the declaration, search the matched point from the memory and execute the method;
method 3-3: the method for declaring the embedded interrupt type point specifically uses the number of times of upward acquisition of the < method stack >, the operation name of the point and the parameter list transmitted when the embedded point is declared as parameters, executes the method to find the matched point from the memory at the declaration position, executes the matched point and returns the execution result.
4. A method for dynamic instrumentation in Java unit testing as claimed in claim 3, wherein: in each of the method 3-1, the method 3-2 and the method 3-3, keywords of the formed points are combined with the number of times of < method stack > and the operation name of the points for querying the points at the declaration.
5. The method for dynamic instrumentation in Java unit testing according to claim 1, wherein: the dot pattern has the structure that:
Map<String,ArrayList<IBuryingPointTException>>pointMap;
wherein the key of the map is used for storing the key of the point, and the value of the map is used for storing the point list pointList of the point.
CN202310089505.9A 2023-02-09 2023-02-09 Dynamic pile inserting method in Java unit test Pending CN116302966A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310089505.9A CN116302966A (en) 2023-02-09 2023-02-09 Dynamic pile inserting method in Java unit test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310089505.9A CN116302966A (en) 2023-02-09 2023-02-09 Dynamic pile inserting method in Java unit test

Publications (1)

Publication Number Publication Date
CN116302966A true CN116302966A (en) 2023-06-23

Family

ID=86785957

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310089505.9A Pending CN116302966A (en) 2023-02-09 2023-02-09 Dynamic pile inserting method in Java unit test

Country Status (1)

Country Link
CN (1) CN116302966A (en)

Similar Documents

Publication Publication Date Title
US7299454B2 (en) Method for multi-language debugging
US10223082B2 (en) Analysis of dynamic elements in bounded time
US7966602B1 (en) Incremental modification detector, and methods, systems, and apparatus for implementing the same
US7478366B2 (en) Debugger and method for debugging computer programs across multiple programming languages
US7882492B2 (en) Intelligent computer program debugger, and system and method for implementing the same
US20020129337A1 (en) Debugger probe for object oriented programming
US7395526B2 (en) Method and system for managing application server lifecycle
Visser et al. Using predicate abstraction to reduce object-oriented programs for model checking
CN105528231A (en) Intermediate auxiliary function-based method and intermediate auxiliary function-based system for dynamically updating software
CN111782513A (en) Satellite ground universal automatic test method based on DLL
CN101794243A (en) Method for strengthening java application program by utilizing operation system structuralization exception processing
CN113419741A (en) Online interface code generation method based on Springboot
Pasquier et al. Practical multiverse debugging through user-defined reductions: Application to uml models
CN116302966A (en) Dynamic pile inserting method in Java unit test
Leske et al. A promising approach for debugging remote promises
US20040230955A1 (en) System for multi-language debugging
Larson Erlang for Concurrent Programming: What role can programming languages play in dealing with concurrency? One answer can be found in Erlang, a language designed for concurrency from the ground up.
CN112199110B (en) Restart-free operation and maintenance upgrading method, system, device and medium
Ábrahám et al. Inductive proof outlines for monitors in java
Tanter et al. Scoping strategies for distributed aspects
Leske et al. Improving live debugging of concurrent threads through thread histories
CN115268983B (en) Hot repair method and device for embedded Internet of things equipment vulnerability
Piessens et al. Support for Metadata-driven Selection of Run-time Services in .NET is Promising but Immature
Pukall JAVADAPTOR: unrestricted dynamic updates of Java applications
CN116225883A (en) Code debugging method based on Java virtual machine

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