본문 바로가기
Back-End (web)

[Error] Mockito cannot mock/spy because: final class

by 햄과함께 2019. 4. 15.
320x100
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 mockito

320x100

'Back-End (web)' 카테고리의 다른 글

Spock 테스트 정리  (0) 2019.05.23
[spring] webClient error 처리  (3) 2019.05.08
[Kotlin] If 문 Type mismatch  (0) 2019.03.25
[Kotlin] Class<T>에 List<Int> 넣기  (0) 2019.03.15
[Kotlin][Mockito] IllegalStateException 에러  (2) 2019.03.05

댓글