Package spock.mock
Class MockMakers
java.lang.Object
spock.mock.MockMakers
Provides constants and factory methods for known built-in
IMockMaker
implementations.
You can select the mock maker during mock creation:
YourClass yourMock = Mock(mockMaker: MockMakers.byteBuddy)
- Since:
- 2.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IMockMakerSettings
Uses Byte Buddy to create mocks.static final IMockMakerSettings
Uses CGLIB to create mocks.static final IMockMakerSettings
Uses the JavaProxy
API to create mocks of interfaces.static final IMockMakerSettings
Uses Mockito to create mocks, which also supports final classes, enums and final methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic IMockMakerSettings
Uses Mockito to create mocks, which also supports final classes, enums and final methods.
-
Field Details
-
byteBuddy
Uses Byte Buddy to create mocks.The supported mocking features are:
INTERFACE
CLASS
ADDITIONAL_INTERFACES
EXPLICIT_CONSTRUCTOR_ARGUMENTS
-
cglib
Uses CGLIB to create mocks.The supported mocking features are:
INTERFACE
CLASS
ADDITIONAL_INTERFACES
EXPLICIT_CONSTRUCTOR_ARGUMENTS
-
javaProxy
Uses the JavaProxy
API to create mocks of interfaces.The supported mocking features are:
INTERFACE
ADDITIONAL_INTERFACES
-
mockito
Uses Mockito to create mocks, which also supports final classes, enums and final methods.The supported mocking features are:
INTERFACE
CLASS
ADDITIONAL_INTERFACES
EXPLICIT_CONSTRUCTOR_ARGUMENTS
FINAL_CLASS
FINAL_METHOD
It uses
MockMakers.INLINE
under the hood, please see the Mockito manual for all pros and cons, when usingMockMakers.INLINE
.
-
-
Method Details
-
mockito
public static IMockMakerSettings mockito(@DelegatesTo(type="org.mockito.MockSettings",strategy=1) Closure<?> settingsCode) Uses Mockito to create mocks, which also supports final classes, enums and final methods.The supported mocking features are:
INTERFACE
CLASS
ADDITIONAL_INTERFACES
EXPLICIT_CONSTRUCTOR_ARGUMENTS
FINAL_CLASS
FINAL_METHOD
It uses
MockMakers.INLINE
under the hood, please see the Mockito manual for all pros and cons, when usingMockMakers.INLINE
.- Parameters:
settingsCode
- the code to execute to configureMockSettings
for further configuration of the mock to create
-