mocking the time
This commit is contained in:
parent
092400f7a0
commit
6c6b23066b
1 changed files with 12 additions and 2 deletions
|
@ -14,6 +14,7 @@ import org.powermock.api.mockito.PowerMockito
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class VersionCheckerUtilsKtTest {
|
class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
|
@ -183,6 +184,15 @@ class VersionCheckerUtilsKtTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@PrepareForTest(System::class)
|
||||||
|
fun `set time`() {
|
||||||
|
PowerMockito.spy(System::class.java)
|
||||||
|
PowerMockito.`when`(System.currentTimeMillis()).thenReturn(100L)
|
||||||
|
|
||||||
|
assertEquals(100L, System.currentTimeMillis())
|
||||||
|
}
|
||||||
|
|
||||||
private fun prepareBus(): Bus {
|
private fun prepareBus(): Bus {
|
||||||
PowerMockito.mockStatic(MainApp::class.java)
|
PowerMockito.mockStatic(MainApp::class.java)
|
||||||
val mainApp = mock<MainApp>(MainApp::class.java)
|
val mainApp = mock<MainApp>(MainApp::class.java)
|
||||||
|
|
Loading…
Reference in a new issue