Mock Objects

xiaoxiao2021-03-06  74

In a Typical Junit Test, Some Data IS set up That is passed to the code under test, and the return value is verified. All this does is test data - or state.

.

As described above, the JUnit test is state, Mock Objects tests interact with other classes.

Mock Objects is a forgery implementation of class or interface, usually used by Mock's dependence (EMPTY shells), which is relatively simple, so you must not be tested

The Mock Objects Library Contains The Following Parts:

1. An Expectation Library to Help Define The Expections WHEN CREATINGMOCK OBJECTS

2. Alternative APIs for many of the common JDK and J2EE libraries, including network sockets, I / O, JDBC, Servlets, JMS, JNDI, and Java-Mail. These alternative APIs extend the conventional APIs to includeclean interface separations from implementations, which Allows Codethat Depends on these Interfaces To Be Passed Mock Implementations -as Well AS Any Other Custom IMPLEMENTATION - As Needed.

3. Mock Implementations for the Apis Mentioned Previously

4. A library for Dynamically Creating Mocks At Runtime From Your UnitTests WITHOUT HAVING TO Define Extra Classes. This Uses Dynamic Proxies.

The Mock Objects Library implements the MOCK function through the dynamic agent of CGLIB

转载请注明原文地址:https://www.9cbs.com/read-120329.html

New Post(0)