forked from mockito/mockito
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes mockito#2281: Make MockedConstruction stubs close on demand
MockedConstruction should behave like MockedStatic when we use @mock on it.
- Loading branch information
1 parent
bf480c3
commit 6d9e73f
Showing
2 changed files
with
40 additions
and
3 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
37 changes: 37 additions & 0 deletions
37
subprojects/junit-jupiter/src/test/java/org/mockitousage/CloseOnDemandTest.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,37 @@ | ||
package org.mockitousage; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.MockedConstruction; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
/** | ||
* Tests to assert that ScopedMock mocks are properly closed on scope exit. | ||
*/ | ||
@ExtendWith(MockitoExtension.class) | ||
class CloseOnDemandTest { | ||
|
||
@Test | ||
void create_mocked_static_1(@Mock MockedStatic<String> mockedStatic) { | ||
assertNotNull(mockedStatic); | ||
} | ||
|
||
@Test | ||
void create_mocked_static_2(@Mock MockedStatic<String> mockedStatic) { | ||
assertNotNull(mockedStatic); | ||
} | ||
|
||
@Test | ||
void create_mocked_construction_1(@Mock MockedConstruction<String> mockConstruction) { | ||
assertNotNull(mockConstruction); | ||
} | ||
|
||
@Test | ||
void create_mocked_construction_2(@Mock MockedConstruction<String> mockConstruction) { | ||
assertNotNull(mockConstruction); | ||
} | ||
} |