Unit test method and device

A technology of unit testing and testing methods, applied in the direction of software testing/debugging, etc., can solve problems such as poor maintainability and low efficiency of unit test programs, and achieve the effects of improving efficiency, saving workload, and maintaining good maintainability

Active Publication Date: 2013-01-02
ADVANCED NEW TECH CO LTD
View PDF2 Cites 26 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0006] The technical problem to be solved by this application is to provide a method for unit testing to s

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Unit test method and device
  • Unit test method and device
  • Unit test method and device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0147] Corresponding to the method provided in Embodiment 1 of a unit test method of the present application, see Figure 7 , the present application also provides a unit test device embodiment 1, in this embodiment, the device may include:

[0148] The receiving module 701 is configured to receive an input expected field and a test value; the expected field is the return value type or the attribute type of the tested method in the original class selected by the user.

[0149] The search module 702 is configured to search the domain object from the pre-built domain object model library according to the tested method, and / or search the Mock class from the pre-generated Mock library.

[0150] A generation module 703, configured to use the domain object and / or the Mock class to generate the test method of the method under test.

[0151] Among them, in practical application, refer to Figure 8 As shown, the generating module 703 may specifically include:

[0152] The fourth obt...

Embodiment 2

[0160] Corresponding to the method provided in Embodiment 2 of a unit test method of the present application, see Figure 9 , the present application also provides a unit test device embodiment 2, in this embodiment, the device may include:

[0161] The Mock library generation module 901 is used to generate a Mock library.

[0162] refer to Figure 10 As shown, in practical applications, the generating Mock library module 901 may specifically include:

[0163] The first obtaining sub-module 1001 is used to obtain each original class that needs to be mocked in the source code to be tested.

[0164] The first reflection sub-module 1002 is configured to obtain the parameters of the methods under test in the class of each original class through reflection, and the class parameters include: the name of the method under test, parameter types and return value types.

[0165] The first generation sub-module 1003 is configured to generate each Mock class corresponding to the origina...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

An embodiment of the invention provides unit test method and device and solves the problems that efficiency of unit test is low and maintainability is poor in the prior art. The unit test method includes receiving an input expected field and an input test value; searching a domain object from a pre-constructed domain object model base by a tested method, and/or searching a Mock class from a pre-generated Mock base; using the domain object and/or the Mock class to generate a test method of the tested method; and performing unit test to an original class by the test method. The expected field is a return value type of an attribute type of the tested method in the original class selected by a user.

Description

technical field [0001] The present application relates to the field of software testing, in particular to a method and device for unit testing. Background technique [0002] Unit testing is the lowest level of testing activity to be performed during software development, in which an independent unit of software is tested in isolation from the rest of the program. Therefore, unit testing should not only be used in a one-time development process as an aid to error-free coding, unit testing must also be repeatable, whether it is during the software modification process or after porting to a new operating environment. In the unit test process, for some objects that are not easy to construct or obtain, you can create a virtual object for testing. This virtual object is called a Mock object. Mock objects are substitutes for actual objects during unit testing. [0003] The Mock object is the instantiation of the Mock class. In the prior art, the code writing of the Mock class in ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
IPC IPC(8): G06F11/36
Inventor 冯照临刘中胜
Owner ADVANCED NEW TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products