[ERROR][TaskAgile] java.lang.IllegalStateException: Failed to load ApplicationContext; org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class; java.lang.IllegalArgumentException: Could not create type at net.bytebuddy.TypeCache.f..
2020. 11. 29. 22:35ㆍ개발 관련/ERROR
register_existedEmailAddress_shouldFailAndReturn400
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext
...
Caused by: org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface com.taskagile.domain.application.UserService.
...
Underlying exception : java.lang.IllegalArgumentException: Could not create type
at org.springframework.boot.test.mock.mockito.MockDefinition.createMock(MockDefinition.java:157)
...
Caused by: java.lang.IllegalArgumentException: Could not create type
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:140)
...
Caused by: java.lang.NoSuchMethodError: 'net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder.appendMostSpecific(java.util.Collection)'
...
register_validPayload_shouldSucceedAndReturn201
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
...
Caused by: org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface com.taskagile.domain.application.UserService.
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 14
...
Underlying exception : java.lang.IllegalArgumentException: Could not create type
at org.springframework.boot.test.mock.mockito.MockDefinition.createMock(MockDefinition.java:157)
...
Caused by: java.lang.IllegalArgumentException: Could not create type
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:140)
...
Caused by: java.lang.NoSuchMethodError: 'net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder.appendMostSpecific(java.util.Collection)'
at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:89)
...
.... 다 같은 에러
해결 방법
- 나의 mockito-core의 버전이 3.6.0이기 때문에 해당 버전 1.10.5가 적절하다. pom.xml에 추가
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.10.5</version>
</dependency>
참고한 사이트에서 아래와 같이 쓰여있었다.
Initially, I was using mockito-core library version-3.3.3 which actually required byte-buddy 1.10.5.
우선, 나는 mockito-core 라이브러리 버전을 3.3.3을 사용하고 있었는데, 그것은 byte-buddy 1.10.5버전이 필요했다.
So, I downgraded the mockito-core library to 2.21.0 version which uses byte-buddy version 1.8.15.
그래서, 나는 mockito-core 라이브러리를 byte-buddy 버전이 1.8.15인 2.21.0 버전으로 내렸다.
참고 사이트 :