Method and device for generating Mock base during unit test
A technology of unit testing and method body, applied in software testing/debugging and other directions, can solve problems such as poor maintainability and low reliability of Mock library, and achieve the effect of improving efficiency, saving manpower and material costs, and maintaining good maintainability.
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0110] Corresponding to the method provided in Example 1 of a method for generating a Mock library in a unit test of the present application, see Figure 5 , the present application also provides a device embodiment 1 for generating a Mock library in a unit test. In this embodiment, the device may include:
[0111] The obtaining original class module 501 is used to obtain each original class that needs to be Mocked in the source code to be tested.
[0112] Obtaining a class parameter module 502, configured to obtain class parameters of each original class through reflection, where the class parameters include: method name, parameter type and return value type.
[0113] The generating module 503 is configured to generate each Mock class corresponding to the original class according to the class parameters.
[0114] refer to Figure 6 As shown, the generating module 503 may specifically include:
[0115] The first generation submodule 601 is configured to generate the class h...
Embodiment 2
[0128] Corresponding to the method provided in Example 1 of a method for generating a Mock library in a unit test of the present application, see Figure 8 , the present application also provides a device embodiment 2 for generating a Mock library in a unit test. In this embodiment, the device also needs to include:
[0129] The throwing module 801 is configured to execute the process of throwing an exception when the Mock method needs to throw an exception.
[0130] And, the testing module 802 is configured to perform unit testing according to the Mock library.
[0131] In this embodiment, when the method needs to throw an exception, the process of throwing an exception can be executed, which meets the different needs in practice. At the same time, the unit test is performed based on the Mock library generated by the embodiment of the present application, which can also improve the unit test. s efficiency.
[0132] The device described in this embodiment can be integrated i...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com