stubs()
attribute is specified, the methods/constructors to be stubbed out should instead
have corresponding @Mock
methods with empty bodies.@Deprecated @Retention(value=RUNTIME) @Target(value=TYPE) public @interface MockClass
Modifier and Type | Required Element and Description |
---|---|
Class<?> |
realClass
Deprecated.
The real class whose methods/constructors will be redefined according to the corresponding mock methods in the
mock class.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
inverse
Deprecated.
Indicates whether the stubbing filters are to be inverted or not.
|
String[] |
stubs
Deprecated.
One or more stubbing filters which specify the set of methods and constructors in the real class that are to be
stubbed out with empty implementations.
|
public abstract Class<?> realClass
Class
object provided can point to an interface.
In that case, a proxy implementation class will be created and then used as the target class for mocking.
The only way for a test to use such a mocked class will be through the proxy instance returned by
Mockit.setUpMock(Object)
, so it only makes sense to use an interface for this attribute when the mock
class is set up through that method.public abstract String[] stubs
[nameRegex][(paramTypeName...)]
, where
nameRegex
is a regular expression for matching method names, and
paramTypeName
is the name of a primitive or reference parameter type.
Actually, any suffix of the type name is enough, like "String" instead of the full class name
"java.lang.String".
If nameRegex
is omitted the filter matches only constructors.
If (paramTypeName...)
is omitted the filter matches methods with any parameters.
Note that an empty filter (stubs = ""
) will match no methods or constructors in the real class,
or all methods and constructors if used with inverse = true
.
To specify the static initializers of the class, inform the filter "<clinit>".public abstract boolean inverse
© 2006-2013 Rogério Liesenfeld