Mockito2 [Error] Mockito cannot mock/spy because: final class org.mockito.exceptions.base.MockitoException: Cannot mock/spy class com.example.study.AuthServiceTest$UserRepository Mockito cannot mock/spy because : - final class 위와 같은 에러 발생. Mockito cannot mock/spy because : - final class // build.gradle dependencies { // ... testImplementation 'org.mockito:mockito-inline:2.13.0' // add } build.gradle에 mockito-inline을 추가. 참고 : How to mock a final class with .. 2019. 4. 15. [Kotlin][Mockito] IllegalStateException 에러 참고 원문 : Befriending Kotlin and Mockito Test Code @MockBean lateinit var memberService: MemberService @Test fun Test() { // .... Mockito.`when`(memberService.getMemberId(any(MemberRequest::class.java))) .thenReturn(0) } MemberRequest를 파라미터로 하고 memberId(Int 형)를 반환하는 getMemberId 함수를 테스트해보았다. memberService.getMemberId(any(MemberRequest::class.java)) 부분에서 에러. Error java.lang.IllegalStateException: an.. 2019. 3. 5. 이전 1 다음