-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Does not include static mocks in regular listener logic as it might d…
…istort existing mock collectors that do not expect scoped mocks. Fixes #1988.
- Loading branch information
Showing
7 changed files
with
102 additions
and
6 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
31 changes: 31 additions & 0 deletions
31
subprojects/inline/src/test/java/org/mockitoinline/StaticRuleTest.java
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,31 @@ | ||
/* | ||
* Copyright (c) 2018 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitoinline; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.junit.MockitoJUnit; | ||
import org.mockito.junit.MockitoRule; | ||
|
||
import java.util.UUID; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
public final class StaticRuleTest { | ||
|
||
@Rule | ||
public MockitoRule mockitoRule = MockitoJUnit.rule(); | ||
|
||
@Mock | ||
private MockedStatic<UUID> mock; | ||
|
||
@Test | ||
public void runs() { | ||
mock.when(UUID::randomUUID).thenReturn(new UUID(123, 456)); | ||
assertEquals(UUID.randomUUID(), new UUID(123, 456)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
subprojects/inline/src/test/java/org/mockitoinline/StaticRunnerTest.java
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,28 @@ | ||
/* | ||
* Copyright (c) 2018 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitoinline; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import java.util.UUID; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public final class StaticRunnerTest { | ||
|
||
@Mock | ||
private MockedStatic<UUID> mock; | ||
|
||
@Test | ||
public void runs() { | ||
mock.when(UUID::randomUUID).thenReturn(new UUID(123, 456)); | ||
assertEquals(UUID.randomUUID(), new UUID(123, 456)); | ||
} | ||
} |