kotlin2 [kotlin/mockk] mockStatic 해제하기 - clearStaticMockk internal class MockkStaticTest { @Test fun `현재 시간 mock 테스트`() { mockkStatic(LocalDateTime::class) every { LocalDateTime.now() } returns LocalDateTime.of(LocalDate.of(1993, 1, 10), LocalTime.of(11, 57)) LocalDateTime.now().let { it.year shouldBe 1993 it.month shouldBe Month.JANUARY it.dayOfMonth shouldBe 10 } } @AfterEach fun clearStaticMockkLocalDateTime() { clearStaticMockk(LocalDateTime::class.. 2022. 1. 26. [kotlin/mockk] mockk로 LocalDatetime.now() mock 테스트 @Test fun test() { val testLocalDateTime = LocalDateTime.of(1993,1,10,11,57) mockkStatic(LocalDateTime::class) every { LocalDateTime.now() } returns testLocalDateTime LocalDateTime.now() shouldBe testLocalDateTime }mockkStatic : makes a static mock out of a class, or clears it if it was already transformed 출처 mockk.io 2022. 1. 12. 이전 1 다음