CN114490398A - Method, device and equipment for testing consumer object - Google Patents

Method, device and equipment for testing consumer object Download PDF

Info

Publication number
CN114490398A
CN114490398A CN202210109445.8A CN202210109445A CN114490398A CN 114490398 A CN114490398 A CN 114490398A CN 202210109445 A CN202210109445 A CN 202210109445A CN 114490398 A CN114490398 A CN 114490398A
Authority
CN
China
Prior art keywords
consumer
information
server
simulation
name
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
CN202210109445.8A
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202210109445.8A priority Critical patent/CN114490398A/en
Publication of CN114490398A publication Critical patent/CN114490398A/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/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • 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/3692Test management for test results analysis

Abstract

The present disclosure provides a method, apparatus, and device for testing consumer objects, which relates to a unit testing technology, and includes: acquiring information of a consumer object to be tested, information of a server object called by the consumer object and information of a simulation object used for simulating the server object; acquiring target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object; assigning the value of the simulation object to the target parameter according to the information of the simulation object; and operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result. The method provided by the scheme can process the annotation set in the consumer without depending on a Dubbo frame, and can successfully call the simulation object to further complete the test.

Description

Method, device and equipment for testing consumer object
Technical Field
The present disclosure relates to unit testing technologies, and in particular, to a method, an apparatus, and a device for testing consumer objects.
Background
Currently, after the code is written, the code is usually tested based on a unit test method. Unit testing refers to a test mode for checking and verifying the smallest testable unit in software. The unit test can help to quickly locate the defects in the program and improve the coding efficiency and the robustness of the program.
In performing the unit test, the test may be performed in units of objects. In addition, in the test process, the target object is usually tested by using the return value of other objects, and for convenience of test, a simulation object is usually created to replace other objects irrelevant to the target object.
Currently, there are some system architectures that include a consumer and a server, where the consumer can invoke functionality provided by the server. If the system is a distributed system which is developed based on SpringBoot and the consumer uses the Dubbo frame to perform remote service call on the server, in the system, an object is defined in the consumer and is annotated, and when the consumer uses the Dubbo frame to perform remote service call on the server, the Dubbo frame processes the object corresponding to the annotation and returns data to the consumer.
However, if a unit test is performed on the consumer side of the system, it is necessary to create a simulation object instead of the server side object, and the simulation object directly returns data to the consumer side. At this time, when the consumer calls the server object, the simulation object is called to shield the Dubbo frame, so that the comment set in the consumer needs to be processed by the Spring frame.
Disclosure of Invention
The present disclosure provides a method, an apparatus, and a device for testing a consumer object, so as to solve the problem that in the prior art, if a unit test is performed on a consumer of the system, a simulation object needs to be created to replace a server object, and the simulation object directly returns data to the consumer. At this time, when the consumer calls the server object, the simulation object is called to shield the Dubbo frame, so that the comment set in the consumer needs to be processed by the Spring frame.
According to a first aspect of the present disclosure, there is provided a method for testing a consumer object, the consumer object being developed based on Spring, and the consumer object invoking a server object using a Dubbo framework;
the method comprises the following steps:
acquiring information of a consumer object to be tested, information of a server object called by the consumer object, and information of a simulation object used for simulating the server object;
acquiring target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object;
assigning the value of the simulation object to the target parameter according to the information of the simulation object;
and operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result.
In one implementation, the information of the consumer object includes a name of the consumer object; the information of the server object comprises the name of the server object called by the consumer object;
the obtaining of the target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object includes:
acquiring a proxy object of the consumer object in a preset object pool according to the name of the consumer object;
acquiring the consumer object according to the proxy object of the consumer object;
and acquiring a target parameter corresponding to the service party object from the plurality of parameters of the consumption party object according to the name of the service party object.
In an implementation manner, before the obtaining information of the consumer object to be tested, information of the server object called by the consumer object, and information of the simulation object for simulating the server object, the method further includes:
creating the simulation object for simulating the server object in response to an object creation instruction;
and responding to an assignment instruction, and assigning a value to the simulation object.
In one implementation, the creating the simulation object for simulating the server object includes:
acquiring the name of the service party object called by the consumer party object;
and creating a simulation object according to the name of the service party object, wherein the name of the simulation object is the same as that of the service party object.
In one implementation manner, the assigning the value of the simulation object to the target parameter according to the information of the simulation object includes:
setting the access right of the target parameter to be accessible;
setting a value of the mock object to a value of the target parameter of the consumer object.
According to a second aspect of the present disclosure, there is provided an apparatus for testing a consumer object, the consumer object being developed based on Spring, and the consumer object invoking a server object using a Dubbo framework;
the device comprises:
the system comprises an information acquisition unit, a service object simulation unit and a service object simulation unit, wherein the information acquisition unit is used for acquiring information of a consumer object to be tested, information of a service object called by the consumer object and information of a simulation object used for simulating the service object;
a target parameter acquiring unit, configured to acquire a target parameter corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object;
the assignment unit is used for assigning the value of the simulation object to the target parameter according to the information of the simulation object;
and the test unit is used for operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result.
In one implementation, the information of the consumer object includes a name of the consumer object; the information of the server object comprises the name of the server object called by the consumer object;
the target parameter acquiring unit includes:
the agent object acquisition module is used for acquiring the agent object of the consumer object in a preset object pool according to the name of the consumer object;
the consumer object acquisition module is used for acquiring the consumer object according to the proxy object of the consumer object;
and the target parameter acquisition module is used for acquiring a target parameter corresponding to the service party object from the plurality of parameters of the consumption party object according to the name of the service party object.
According to a third aspect of the present disclosure, there is provided an electronic device comprising a memory and a processor; wherein the content of the first and second substances,
the memory for storing a computer program;
the processor is configured to read the computer program stored in the memory, and execute the method for testing a consumer object according to the first aspect according to the computer program in the memory.
According to a fourth aspect of the present disclosure, there is provided a computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, implement the method for testing consumer objects according to the first aspect.
According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method for testing consumer objects as described in the first aspect.
The present disclosure provides a method, apparatus, and device for testing consumer objects, including: acquiring information of a consumer object to be tested, information of a server object called by the consumer object and information of a simulation object used for simulating the server object; acquiring target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object; assigning the value of the simulation object to the target parameter according to the information of the simulation object; and operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result. According to the method, the device and the equipment for testing the consumer object, the target parameters corresponding to the consumer object and the server object are obtained according to the information of the consumer object and the information of the server object called by the consumer object, the value of the simulation object is assigned to the target parameters, and the test is completed by utilizing the assigned target parameters. The method and the device can process the annotations set in the consumers without depending on a Dubbo framework, and can successfully call the simulation object to complete the test.
Drawings
FIG. 1 is a flow diagram illustrating a method for testing consumer objects in accordance with an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic flow chart diagram illustrating a method for testing consumer objects in accordance with another exemplary embodiment of the present disclosure;
FIG. 3 is a diagram illustrating a process for invoking a simulation object according to an exemplary embodiment of the present disclosure;
FIG. 4 is a block diagram illustrating an apparatus for testing consumer objects in accordance with an exemplary embodiment of the present disclosure;
FIG. 5 is a block diagram illustrating an apparatus for testing consumer objects in accordance with another exemplary embodiment of the present disclosure;
fig. 6 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
Detailed Description
Currently, after the code is written, the code is usually tested based on a unit test method. Unit testing refers to a test mode for checking and verifying the smallest testable unit in software. The unit test can help to quickly locate the defects in the program and improve the coding efficiency and the robustness of the program. In performing the unit test, the test may be performed in units of objects. In addition, in the test process, the target object is usually tested by using the return value of other objects, and for convenience of test, a simulation object is usually created to replace other objects irrelevant to the target object. Currently, there are some system architectures that include a consumer and a server, where the consumer can invoke functionality provided by the server. If the system is a distributed system which is developed based on SpringBoot and the consumer uses the Dubbo frame to perform remote service call on the server, in the system, an object is defined in the consumer and is annotated, and when the consumer uses the Dubbo frame to perform remote service call on the server, the Dubbo frame processes the object corresponding to the annotation and returns data to the consumer.
However, if a unit test is performed on the consumer side of the system, it is necessary to create a simulation object instead of the server side object, and the simulation object directly returns data to the consumer side. At this time, when the consumer calls the server object, the simulation object is called to shield the Dubbo frame, so that the comment set in the consumer needs to be processed by the Spring frame.
In order to solve the technical problem, in the scheme provided by the disclosure, according to the information of the consumer object and the information of the server object called by the consumer object, the target parameters corresponding to the consumer object and the server object are obtained, the value of the simulation object is assigned to the target parameters, and the test is completed by using the assigned target parameters. The method and the device can process the annotations set in the consumers without depending on a Dubbo framework, and can successfully call the simulation object to complete the test.
FIG. 1 is a flowchart illustrating a method for testing consumer objects according to an exemplary embodiment of the present disclosure. Wherein the consumer object is developed based on Spring, and the consumer object calls the server object by adopting a Dubbo framework.
Among them, Spring is an open source application framework on the Java platform, providing a container with control reversal feature. Wherein Java is a door-to-object programming language.
The Spring Boot is an extension of a Spring framework, and a unit testing framework is integrated.
The unit test refers to checking and verifying the minimum testable unit of the software, and the minimum testable unit in the scheme provided by the disclosure refers to a java method.
Among them, Dubbo is a distributed service framework, and aims to provide a Remote Procedure Call (RPC) scheme with high performance and transparency. The solution provided by the present disclosure divides the system into a consumer and a server according to the Dubbo framework, and the Dubbo framework uses a registry to process the service invocation from the consumer to the server.
Where a distributed system is a collection of independent computers, it appears to a user as if a single computer is accessed. The distributed system in the scheme provided by the disclosure can deploy the consumer and the server on different servers.
As shown in fig. 1, the method for testing a consumer object provided in this embodiment includes:
step 101, obtaining information of a consumer object to be tested, information of a server object called by the consumer object, and information of a simulation object for simulating the server object.
The method provided by the present disclosure may be executed by an electronic device with computing capability, such as a computer. The electronic device can acquire information of a consumer object to be tested, information of a server object called by the consumer object, and information of a simulation object for simulating the server object.
In particular, consumer objects are different from server objects, which often require a service that invokes a server object. For example, there is a shopping software that can provide payment operation, and the shopping software often needs a bank software to feed back payment information, wherein the shopping software can be a consumer object and the bank software can be a server object.
During unit testing, the server object that the consumer object needs to call does not feed back to the consumer object, so a simulation object needs to be created in advance to simulate the server object, so that the testing is completed.
The information of the consumer object to be tested can comprise information such as the name of the consumer object to be tested and a code corresponding to the consumer object to be tested; the information of the service object called by the consumer object may include information such as the name of the service object; the information of the simulation object for simulating the server object may include information of a name of the simulation object, a code of the simulation object, and the like.
And 102, acquiring target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object.
The target parameter may be an attribute in the consumer object, and the target parameter corresponds to the server object.
Specifically, the information of the consumer object may include a name of the consumer object; the name of the service object may be included in the information of the service object that the consumer object invokes. Wherein the name of the service side object is the same as the name of the target parameter.
Specifically, the consumer object may be obtained in a preset object pool according to the name of the consumer object; and then, acquiring target parameters in the consumer object according to the name of the server object called by the consumer.
And 103, assigning the value of the simulation object to the target parameter according to the information of the simulation object.
The information of the simulation object may include a value of the simulation object and a name of the simulation object.
Specifically, the simulation object may be created in advance and assigned with a value.
Wherein the name of the simulation object is the same as the name of the target object.
Specifically, the value of the simulation object having the same name as the target parameter may be assigned to the target parameter.
And 104, operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result.
In particular, the testing of the consumer object may be completed according to the assigned target parameters.
Specifically, the consumer object can be operated according to the assigned target parameter to obtain an operation result. And obtaining a comparison result by comparing the operation result with a preset accurate result. And determining a test result for testing the consumer object according to the comparison result.
The preset accurate result is preset according to actual conditions, and an accurate operation result can be obtained after the consumer object is operated.
The present disclosure provides a method for testing consumer objects, comprising: acquiring information of a consumer object to be tested, information of a server object called by the consumer object and information of a simulation object used for simulating the server object; acquiring target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object; assigning the value of the simulation object to the target parameter according to the information of the simulation object; and operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result. According to the method adopted by the disclosure, target parameters corresponding to the consumer object and the server object are obtained according to the information of the consumer object and the information of the server object called by the consumer object, the value of the simulation object is assigned to the target parameters, and the test is completed by using the assigned target parameters. The method and the device can process the annotations set in the consumers without depending on a Dubbo framework, and can successfully call the simulation object to complete the test.
FIG. 2 is a flowchart illustrating a method for testing consumer objects according to another exemplary embodiment of the present disclosure. Wherein, the consumer object is developed based on Spring, and the consumer object calls the server object by adopting a Dubbo framework.
As shown in fig. 2, the method for testing consumer objects provided by this embodiment includes:
step 201, in response to the object creation instruction, creating a simulation object for simulating the server object.
Specifically, during unit testing, the service object that the consumer object needs to invoke does not feed back to the consumer object, so a simulation object needs to be created in advance to simulate the service object, so that the testing is completed.
Specifically, in response to the object creation instruction, a simulation object for simulating the server object can be created in accordance with the object creation instruction.
In one implementation, the name of the server object called by the consumer object is obtained;
and creating a simulation object according to the name of the service side object, wherein the name of the simulation object is the same as that of the service side object.
The object creating instruction may include a name of a service object called by the consumer object. The name of the server object called by the consumer object may be obtained according to the object creation instruction. Then, a simulation object is created such that the name of the simulation object is the same as the name of the server object.
And 202, responding to the assignment instruction, and assigning the value to the simulation object.
Specifically, a value may be determined according to actual conditions and assigned to the simulation object.
Step 203, obtaining the information of the consumer object to be tested, the information of the server object called by the consumer object, and the information of the simulation object for simulating the server object.
Specifically, the principle and implementation of step 203 are similar to those of step 101, and are not described again.
Step 204, the information of the consumer object comprises the name of the consumer object; the information of the server object comprises the name of the server object called by the consumer object; and acquiring the proxy object of the consumer object in a preset object pool according to the name of the consumer object.
The preset object pool is a preset object pool. Software code (including proxy objects for consumer objects) and test code for testing the software may be included in the object pool.
Specifically, the proxy object of the consumer object wrapped by the Spring Boot framework is stored in the object pool. The proxy object of the consumer object may be obtained in a preset object pool according to the name of the consumer object.
Alternatively, an object proxy of a consumer object named as the name of the consumer object may be obtained from the local Spring IoC container using a getteam () method. However, the object obtained by the getteam () method is already wrapped by the Spring Boot framework, and the dynamic proxy object of the consumer can only be taken by the method.
Step 205, according to the agent object of the consumer object, the consumer object is obtained.
Specifically, the proxy object of the consumer object may be unpacked from the Spring Boot frame to obtain the consumer object.
Alternatively, the consumer object may be obtained by the gettarget () method. The agent types can be classified into cglib agents and jdk dynamic agents, and gettarget () can obtain consumer objects using different methods according to different agent types.
Step 206, according to the name of the service object, obtaining the target parameter corresponding to the service object from the plurality of parameters of the consumer object.
In particular, a consumer object may include a plurality of parameters. Wherein the parameter that is the same as the name of the server object is the target parameter.
Specifically, the target parameter may be obtained in the consumer object according to the name of the server object called by the consumer.
Optionally, according to the reflection mechanism, an attribute named as the name of the server object in the class corresponding to the consumer object may be obtained by a getdecleardfield () method. The attribute is the target parameter. Where attributes are components of a class, they may also be referred to as member variables. The instantiation of a class is an object.
The reflection mechanism refers to dynamically loading a class and acquiring detailed information of the class when a program runs, so as to operate attributes and methods of the class or the object. The essence is that after the class object is obtained by the JVM, the class object is decompiled, so that various information of the object is obtained.
Step 207, the access right of the target parameter is set to be accessible.
Alternatively, the access right of the target parameter may be changed to be accessible by a field.
Step 208, set the value of the mock object to the value of the target parameter of the consumer object.
In particular, the simulation object is injected into the consumer object. Specifically, the service of the service party is called in the class of the consumer party, and the calling is called through the object of the service party, so that the object of one service party needs to be declared in the class of the consumer party. If a service object b is defined in class A of the consumer, then b is an attribute of A. The simulation object c, which simulates the server object b and is assigned a value during simulation, is assigned to b, and is called an injection attribute, which is also understood as injecting the simulation object into the consumer object.
And 209, operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result.
Specifically, step 209 is similar to step 104 in principle and implementation and is not described again.
Fig. 3 is a schematic diagram illustrating a process of calling a simulation object according to an exemplary embodiment of the disclosure.
As shown in fig. 3, an object proxy of a consumer object named the name of the consumer object may be acquired from the local Spring IoC container using a getteam () method according to the name of the consumer object.
The consumer object is then obtained according to its object proxy, gettarget () method.
Then, according to the reflection mechanism, an attribute named as the name of the server object in the class corresponding to the consumer object, i.e., a target parameter, can be obtained by the getDecleardField () method.
Then, the access right of the target parameter may be changed to be accessible by a field. And setting the value of the simulation object as the value of the target parameter of the consumer object.
FIG. 4 is a block diagram illustrating an apparatus for testing consumer objects in accordance with an exemplary embodiment of the present disclosure. Wherein, the consumer object is developed based on Spring, and the consumer object calls the server object by adopting a Dubbo framework.
As shown in fig. 4, the present disclosure provides an apparatus 400 for testing consumer objects, the apparatus comprising:
an information obtaining unit 410, configured to obtain information of a consumer object to be tested, information of a server object called by the consumer object, and information of a simulation object for simulating the server object;
a target parameter obtaining unit 420, configured to obtain a target parameter corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object;
the assignment unit 430 is configured to assign a value of the simulation object to the target parameter according to the information of the simulation object;
the testing unit 440 is configured to run the consumer target according to the target parameter to obtain a running result, compare the running result with a preset accurate result, and determine a testing result for testing the consumer target according to the comparison result.
FIG. 5 is a block diagram illustrating an apparatus for testing consumer objects in accordance with another exemplary embodiment of the present disclosure. Wherein the consumer object is developed based on Spring, and the consumer object calls the server object by adopting a Dubbo framework.
As shown in fig. 5, on the basis of the above embodiment, in the apparatus 500 for testing consumer objects provided by the present disclosure, the target parameter obtaining unit 420 further includes:
the proxy object obtaining module 421 is configured to obtain a proxy object of the consumer object from a preset object pool according to the name of the consumer object;
a consumer object obtaining module 422, configured to obtain a consumer object according to a proxy object of the consumer object;
a target parameter obtaining module 423, configured to obtain, according to the name of the service object, a target parameter corresponding to the service object from among the multiple parameters of the consumer object;
wherein the information of the consumer object comprises a name of the consumer object; the information of the server object includes the name of the server object called by the consumer object.
Before obtaining the information of the consumer object to be tested, the information of the server object called by the consumer object, and the information of the simulation object used for simulating the server object, the method further comprises the following steps: a simulation object creating unit 450 for creating a simulation object for simulating the server object in response to the object creating instruction; and responding to the assignment instruction, and assigning the value to the simulation object.
The simulation object creating unit 450 is specifically configured to obtain a name of a service object called by a consumer object;
the simulation object is created according to the name of the server object, and the name of the simulation object is the same as that of the server object.
The assignment unit 430 is specifically configured to set the access right of the target parameter to be accessible;
the value of the target parameter of the consumer object is set to the value of the mock object.
Fig. 6 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
As shown in fig. 6, the electronic device provided in this embodiment includes:
a memory 601;
a processor 602; and
a computer program;
wherein the computer program is stored in the memory 601 and configured to be executed by the processor 602 to implement any of the above methods for testing consumer objects.
The present embodiments also provide a computer-readable storage medium having stored thereon a computer program for execution by a processor to implement any of the above methods for testing consumer objects.
The present embodiment also provides a computer program product comprising a computer program which, when executed by a processor, performs any of the above-described methods for testing consumer objects.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for testing a consumer object, wherein the consumer object is developed based on Spring and the consumer object invokes a server object using a Dubbo framework;
the method comprises the following steps:
acquiring information of a consumer object to be tested, information of a server object called by the consumer object, and information of a simulation object used for simulating the server object;
acquiring target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object;
assigning the value of the simulation object to the target parameter according to the information of the simulation object;
and operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result.
2. The method of claim 1, wherein the information of the consumer object comprises a name of the consumer object; the information of the server object comprises the name of the server object called by the consumer object;
the obtaining of the target parameters corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object includes:
acquiring a proxy object of the consumer object in a preset object pool according to the name of the consumer object;
acquiring the consumer object according to the proxy object of the consumer object;
and acquiring a target parameter corresponding to the service party object from the plurality of parameters of the consumption party object according to the name of the service party object.
3. The method of claim 1, wherein before obtaining the information of the consumer object to be tested, the information of the server object called by the consumer object, and the information of the simulation object for simulating the server object, further comprising:
creating the simulation object for simulating the server object in response to an object creation instruction;
and responding to an assignment instruction, and assigning a value to the simulation object.
4. The method of claim 3, wherein creating the simulation object for simulating the server object comprises:
acquiring the name of the service party object called by the consumer party object;
and creating a simulation object according to the name of the service party object, wherein the name of the simulation object is the same as that of the service party object.
5. The method of claim 1, wherein assigning the value of the simulated object to the target parameter according to the information of the simulated object comprises:
setting the access right of the target parameter to be accessible;
setting a value of the mock object to a value of the target parameter of the consumer object.
6. An apparatus for testing a consumer object, wherein the consumer object is developed based on Spring and the consumer object invokes a server object using a Dubbo framework;
the device comprises:
the system comprises an information acquisition unit, a service object simulation unit and a service object simulation unit, wherein the information acquisition unit is used for acquiring information of a consumer object to be tested, information of a service object called by the consumer object and information of a simulation object used for simulating the service object;
a target parameter acquiring unit, configured to acquire a target parameter corresponding to the consumer object and the server object according to the information of the consumer object and the information of the server object called by the consumer object;
the assignment unit is used for assigning the value of the simulation object to the target parameter according to the information of the simulation object;
and the test unit is used for operating the consumer object according to the target parameters to obtain an operation result, comparing the operation result with a preset accurate result, and determining a test result for testing the consumer object according to the comparison result.
7. The apparatus of claim 6, wherein the information of the consumer object comprises a name of the consumer object; the information of the server object comprises the name of the server object called by the consumer object;
the target parameter acquiring unit includes:
the agent object acquisition module is used for acquiring the agent object of the consumer object in a preset object pool according to the name of the consumer object;
the consumer object acquisition module is used for acquiring the consumer object according to the proxy object of the consumer object;
and the target parameter acquisition module is used for acquiring a target parameter corresponding to the service party object from the plurality of parameters of the consumption party object according to the name of the service party object.
8. An electronic device comprising a memory and a processor; wherein the content of the first and second substances,
the memory for storing a computer program;
the processor is used for reading the computer program stored in the memory and executing the method of any one of the preceding claims 1-5 according to the computer program in the memory.
9. A computer-readable storage medium having computer-executable instructions stored thereon which, when executed by a processor, implement the method of any one of claims 1-5.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, carries out the method of any one of the preceding claims 1-5.
CN202210109445.8A 2022-01-28 2022-01-28 Method, device and equipment for testing consumer object Pending CN114490398A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210109445.8A CN114490398A (en) 2022-01-28 2022-01-28 Method, device and equipment for testing consumer object

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210109445.8A CN114490398A (en) 2022-01-28 2022-01-28 Method, device and equipment for testing consumer object

Publications (1)

Publication Number Publication Date
CN114490398A true CN114490398A (en) 2022-05-13

Family

ID=81478272

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210109445.8A Pending CN114490398A (en) 2022-01-28 2022-01-28 Method, device and equipment for testing consumer object

Country Status (1)

Country Link
CN (1) CN114490398A (en)

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
CN109697060B (en) Video special effect system, generation method, device, equipment and storage medium thereof
KR101246967B1 (en) Method and apparatus for executing unit tests in application host environment
US11010283B2 (en) Mock-based unit test(s) for an end-to-end test of a code snippet
CN110008113B (en) Test method and device and electronic equipment
US10409700B2 (en) Flexible configuration and control of a testing system
JP4950454B2 (en) Stack hierarchy for test automation
CN101739333B (en) Method, tool and device for debugging application program
US8799875B2 (en) Streamlining unit testing through hot code swapping
US7647584B2 (en) Automation and isolation of software component testing
US9465718B2 (en) Filter generation for load testing managed environments
US7739698B2 (en) Multiplatform API usage tool
US9697109B2 (en) Dynamically configurable test doubles for software testing and validation
US7500149B2 (en) Generating finite state machines for software systems with asynchronous callbacks
CN106648556B (en) Method and device for front-end and back-end integrated development test
US6901583B1 (en) Method for testing of a software emulator while executing the software emulator on a target machine architecture
CN110673837B (en) Code repairing method and device, electronic equipment and computer readable storage medium
US8661414B2 (en) Method and system for testing an order management system
CN111797020A (en) Mock data method and device based on dynamic bytecode
CN114579452A (en) Interface influence detection method and related equipment
US9122805B2 (en) Resilient mock object creation for unit testing
CN111625225A (en) Program specified data output method and device
CN109240923B (en) Interface test script generation method and computer readable storage medium
CN114490398A (en) Method, device and equipment for testing consumer object
CN114691496A (en) Unit testing method, unit testing device, computing equipment and 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