forked from mockito/mockito
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes mockito#2626 : Introduce MockSettings.mockMaker
- Loading branch information
1 parent
e962176
commit e322fa5
Showing
13 changed files
with
138 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.mockito; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker; | ||
import org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker; | ||
|
||
import java.util.Arrays; | ||
|
||
public final class CustomMockMakerTest { | ||
@Test | ||
public void test_custom_mock_maker() throws Exception { | ||
class TestClass { | ||
String noop() { return "UNUSED"; } | ||
final String finalMethod() { noop(); return "ORIGINAL"; } | ||
} | ||
|
||
TestClass inlineMock = Mockito.mock(TestClass.class, Mockito.withSettings() | ||
.outerInstance(this) | ||
.useConstructor() | ||
.mockMaker(InlineByteBuddyMockMaker.class)); | ||
TestClass subclassMock = Mockito.mock(TestClass.class, Mockito.withSettings() | ||
.outerInstance(this) | ||
.useConstructor() | ||
.mockMaker(ByteBuddyMockMaker.class)); | ||
for (TestClass mock : Arrays.asList(inlineMock, subclassMock)) { | ||
Mockito.when(mock.finalMethod()).thenReturn("MOCKED"); | ||
} | ||
|
||
Assert.assertEquals("MOCKED", inlineMock.finalMethod()); | ||
Assert.assertEquals("ORIGINAL", subclassMock.finalMethod()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters