Unit test method and device, test equipment and storage medium
A unit test and test technology, applied in the test field, can solve the problems of inapplicability, Mock object injection support and poor scalability, etc., to achieve the effect of easy writing and execution, and improved support and scalability
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0054] figure 1 It is a flow chart of a unit testing method provided by Embodiment 1 of the present invention, and this embodiment is applicable to unit testing. Specifically, the unit testing method can be executed by a unit testing device, which can be realized by means of software and / or hardware, and integrated into a testing device. Further, the test equipment includes, but is not limited to: electronic equipment such as desktop computers, notebook computers, servers, and industrial computers.
[0055] Such as figure 1 As shown, the method specifically includes the following steps:
[0056] S110. Determine a simulated object feature set according to the annotation configuration of the test class of the unit to be tested.
[0057] Wherein, the test class may refer to the class used to execute the test in the unit to be tested. Annotation configuration can refer to performing a feature description on the Bean in the test class, and configuring the Bean corresponding to ...
Embodiment 2
[0066] figure 2 It is a flow chart of a unit testing method provided by Embodiment 2 of the present invention. This embodiment optimizes on the basis of the above embodiments, instantiates objects that do not need to be simulated and creates Spy for objects that do not need to be simulated. The agent process is described in detail. It should be noted that for technical details not exhaustively described in this embodiment, reference may be made to any of the foregoing embodiments.
[0067] Specifically, such as figure 2 As shown, the method specifically includes the following steps:
[0068] S210. Define the post-processing module of the Bean factory through Spring, and create and register the original Bean definition based on the IOC mechanism during the initialization process.
[0069] Among them, the Bean factory post-processing module can refer to a processor that intervenes in the initialization process of the Bean factory. The initialization of the Bean factory can ...
Embodiment 3
[0099] Figure 4 It is a schematic structural diagram of a unit testing device provided by Embodiment 3 of the present invention. The unit testing device provided in this embodiment includes:
[0100] The test configuration module 310 is used to determine the Mock Bean feature set according to the annotation configuration of the test class of the unit to be tested;
[0101] Simulation post-processing module 320, for traversing the original bean definition of Spring registration according to the Mock Bean feature set, to determine the original bean definition that needs Mock; for the original bean definition that needs Mock, create a corresponding Mock Bean definition, And use the Mock Bean definition to replace the original Bean definition that needs Mock;
[0102] The injection module 330 is configured to inject the instance defined by the Mock Bean into the test class through Spring, so that the test module can test the unit to be tested.
[0103] The third embodiment of ...
PUM

Abstract
Description
Claims
Application Information

- R&D
- Intellectual Property
- Life Sciences
- Materials
- Tech Scout
- Unparalleled Data Quality
- Higher Quality Content
- 60% Fewer Hallucinations
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2025 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com