👉 기본 환경
- Language: Java
- DB: MySQL
- IDE: IntelliJ
⌨️ 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import com.example.demo.dao.srt.SrtFcstInfoDAO;
import com.example.demo.dao.srt.SrtFcstInfoRepository;
import com.example.demo.dto.srt.RqstParams;
import com.example.demo.entity.srt.UltraSrtFcst;
import com.example.demo.entity.srt.UltraSrtNcst;
import com.example.demo.entity.srt.VilageFcst;
import com.example.demo.service.srt.SrtFcstInfoServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class srtFcstInfoServiceTest {
@Autowired
SrtFcstInfoService srtFcstInfoService;
@Autowired
SrtFcstInfoRepository srtFcstInfoRepository;
// UltraSrtNcst
@Test
public void 초단기실황조회() throws Exception {
// given
RqstParams rqstParams = createRqstParams();
// when
srtFcstInfoService.getUltraSrtNcst(rqstParams);
// then
List<UltraSrtNcst> savedDataList = srtFcstInfoRepository.findAllUltraSrtNcst();
assertEquals(Integer.parseInt(rqstParams.getNumOfRows()), savedDataList.size());
}
}
|
🖨️오류
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not execute test class 'com.example.demo.service.srtFcstInfoServiceTest'.
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:54)
at java.base@17.0.7/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base@17.0.7/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base@17.0.7/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base@17.0.7/java.lang.reflect.Method.invoke(Method.java:568)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: org.gradle.internal.UncheckedException: java.lang.ClassNotFoundException: com.example.demo.service.srtFcstInfoServiceTest
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:68)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.loadClass(JUnitPlatformTestClassProcessor.java:137)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.access$100(JUnitPlatformTestClassProcessor.java:58)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.execute(JUnitPlatformTestClassProcessor.java:100)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.execute(JUnitPlatformTestClassProcessor.java:90)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
... 18 more
Caused by: java.lang.ClassNotFoundException: com.example.demo.service.srtFcstInfoServiceTest
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.loadClass(JUnitPlatformTestClassProcessor.java:135)
... 23 more
|
📡 원인
1. test class 이름의 시작이 소문자로 시작
😮 대문자로 변경해도 동일한 오류 발생
2. 프로젝트 파일 경로에 한글이 있을 경우, 인코딩 문제로 오류 발생
- IntelliJ에서 콘솔창에 한글 설정을 위해 idea64.exe.vmoptions에 -Dfile.encoding=UTF-8를 추가한 부분에서 문제 발생
- 📚 IntelliJ에서 콘솔창에 한글 설정 참고 자료
📰 해결 방법
1. test class 이름의 시작이 대문자로 변경
😮 대문자로 변경해도 동일한 오류 발생 시,
2. 프로젝트 파일 경로를 모두 영문으로 변경
'Java > Spring with Error' 카테고리의 다른 글
[해결 방법] org.gradle.api.GradleScriptException (0) | 2023.08.27 |
---|---|
[해결 방법] java.lang.IllegalStateException (0) | 2023.08.22 |
[해결 방법] org.springframework.web.client.HttpServerErrorException (0) | 2023.08.21 |
[해결 방법] java.lang.IllegalArgumentException (0) | 2023.08.21 |
[해결 방법] org.json.JSONException (0) | 2023.08.19 |