인프런 커뮤니티 질문&답변

따뜻한 노새님의 프로필 이미지

작성한 질문수

스프링 테스트 코드 java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null) 오류

작성

·

1K

0

2024-01-30T23:39:16.874+09:00 INFO 37248 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...

2024-01-30T23:39:17.014+09:00 INFO 37248 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:tcp://localhost/~/test user=SA

2024-01-30T23:39:17.016+09:00 INFO 37248 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.

WARNING: A Java agent has been loaded dynamically (C:\Users\ㅋㅋ\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.14.11\f9cb566608fbac6bc7bf54901a7aa11543a989ee\byte-buddy-agent-1.14.11.jar)

WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning

WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information

WARNING: Dynamic loading of agents will be disallowed by default in a future release

2024-01-30T23:39:17.780+09:00 WARN 37248 --- [ main] o.s.test.context.TestContextManager : Caught exception while invoking 'beforeTestMethod' callback on TestExecutionListener [org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener] for test method [public void hello.hellospring.sevice.MemberServiceIntegrationTest.회원가입() throws java.lang.Exception] and test instance [hello.hellospring.sevice.MemberServiceIntegrationTest@3f048c86]

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)

at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:84) ~[mockito-core-5.7.0.jar:na]

at jdk.proxy2/jdk.proxy2.$Proxy74.getHandler(Unknown Source) ~[na:na]

at org.mockito.internal.util.MockUtil.getMockHandlerOrNull(MockUtil.java:158) ~[mockito-core-5.7.0.jar:na]

at org.mockito.internal.util.MockUtil.isMock(MockUtil.java:147) ~[mockito-core-5.7.0.jar:na]

at org.mockito.internal.util.DefaultMockingDetails.isMock(DefaultMockingDetails.java:32) ~[mockito-core-5.7.0.jar:na]

at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:106) ~[spring-boot-test-3.2.2.jar:3.2.2]

at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:85) ~[spring-boot-test-3.2.2.jar:3.2.2]

at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:73) ~[spring-boot-test-3.2.2.jar:3.2.2]

at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.beforeTestMethod(ResetMocksTestExecutionListener.java:60) ~[spring-boot-test-3.2.2.jar:3.2.2]

at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:320) ~[spring-test-6.1.3.jar:6.1.3]

at org.springframework.test.context.junit.jupiter.SpringExtension.beforeEach(SpringExtension.java:240) ~[spring-test-6.1.3.jar:6.1.3]

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:167) ~[junit-jupiter-engine-5.10.1.jar:5.10.1]

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:203) ~[junit-jupiter-engine-5.10.1.jar:5.10.1]

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:203) ~[junit-jupiter-engine-5.10.1.jar:5.10.1]

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:166) ~[junit-jupiter-engine-5.10.1.jar:5.10.1]

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:133) ~[junit-jupiter-engine-5.10.1.jar:5.10.1]

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) ~[junit-jupiter-engine-5.10.1.jar:5.10.1]

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) ~[na:na]

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.10.1.jar:1.10.1]

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.10.1.jar:1.10.1]

 

at org.mockito.Mockito.<clinit>(Mockito.java:1683) ~[mockito-core-5.7.0.jar:na]

at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:105) ~[spring-boot-test-3.2.2.jar:3.2.2]

... 59 common frames omitted

Caused by: java.lang.reflect.InvocationTargetException: null

at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74) ~[na:na]

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[na:na]

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[na:na]

at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.create(DefaultMockitoPlugins.java:103) ~[mockito-core-5.7.0.jar:na]

... 67 common frames omitted

Caused by: org.mockito.exceptions.base.MockitoInitializationException:

Could not initialize inline Byte Buddy mock maker.

It appears as if your JDK does not supply a working agent attachment mechanism.

Java : 21

JVM vendor name : Oracle Corporation

JVM vendor version : 21.0.1+12-29

JVM name : OpenJDK 64-Bit Server VM

JVM version : 21.0.1+12-29

JVM info : mixed mode, sharing

OS name : Windows 10

OS version : 10.0

 

JDK도 자바 17로 사용 하는데 왜 21로 뜨는지도 모르겠고 서버는 잘돌아가는데 왜 테스트만 저러는지 해결 부탁드립니다 .ㅠㅠㅠ

 

답변 3

0

혹시 문제 해결되셨을까요?

0

안녕하세요. 따뜻한 노새님

다음 링크를 참고해서 IntelliJ에 설치된 JDK 버전을 체크해주세요.

https://docs.google.com/document/d/1j0jcJ9EoXMGzwAA2H0b9TOvRtpwlxI5Dtn3sRtuXQas/edit#heading=h.f9xqb7l8nuph

감사합니다.

0

안녕하세요. 따뜻한 노새님, 공식 서포터즈 OMG입니다.

build.gradle에 명시되어 있는 자바 버전이 21로 되어 있을 것으로 예상됩니다. 확인 후 17로 변경하고 우측 상단에 보일 코끼리 버튼을 클릭해서 확인해주세요.

image

영한님의 강의 진행 중 관련한 질문은 인프런 상단 메뉴의 커뮤니티 탭이 아닌 강의 장 내에 있는 커뮤니티 탭을

image

활용해주시면 영한님과 서포터즈가 빠른 질문 확인과 답변이 가능합니다.

감사합니다.

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.2'
    id 'io.spring.dependency-management' version '1.1.4'
}

group = 'hello'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
//  implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    runtimeOnly 'com.h2database:h2'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

 

17로 되어 있는데 자꾸 이런 에러가 떠서 강의내의 커뮤티니티 답변이 너무 느리거나 답변이 안달려서요 ㅠㅠ

안녕하세요. 따뜻한 노새님

"강의내의 커뮤티니티 답변이 너무 느리거나 답변이 안달려서요"라고 말씀을 주셔서, 도움을 드리기 위해 어떤 부분이 불편하셨는지 따뜻한 노새님께서 올리신 질문을 찾아보았습니다.

https://www.inflearn.com/questions/1162838

질문을 24.01.31 저녁 10시 31분에 주셨고, 다음날 아침 9시 14분에 저희 서포터즈님께서 답변을 드리면서 소스 코드 요청을 드렸습니다.

서포터즈 분들도 대부분 실무에서 일을 하시는 분들이어서 바로바로 답변을 드릴 수 없는 점은 이해를 부탁드려요. 하지만 도움을 요청하시면 반드시 해결해드립니다 🙂

좋은 하루 되세요.