MemberServiceTest 오류
첨부한 사진과 같이 코드를 작성 했는데 아래와 같은 오류가 떴습니다...
혹시 어떻게 해야되는지 여쭤봐도 될까요
============================
CONDITIONS EVALUATION REPORT
============================
Positive matches:
-----------------
None
Negative matches:
-----------------
None
Exclusions:
-----------
None
Unconditional classes:
----------------------
None
답변 1
0
안녕하세요. rnrmf1121님, 공식 서포터즈 y2gcoder입니다.
도움을 드리고 싶지만 질문 내용만으로는 답변을 드리기 어렵습니다.
실제 동작하는 전체 프로젝트를 압축해서 구글 드라이브로 공유해서 링크를 남겨주세요.
구글 드라이브 업로드 방법은 다음을 참고해주세요.
주의: 업로드시 링크에 있는 권한 문제 꼭 확인해주세요
추가로 다음 내용도 코멘트 부탁드립니다.
1. 문제 영역을 실행할 수 있는 방법
2. 문제가 어떻게 나타나는지에 대한 상세한 설명
링크: 공식 서포터즈
링크: 자주하는 질문
감사합니다.
0
https://drive.google.com/file/d/1US2qMe73NPNsn966X5LiUvVt_u6J7Aqq/view?usp=sharing
전체 프로젝트 압축 링크입니다.
MemberServiceTest중 회원가입() 부분을 실행하면 본문과 같은 오류가 뜨는데 혹시 어떻게 해야 될까요
0
https://drive.google.com/file/d/1US2qMe73NPNsn966X5LiUvVt_u6J7Aqq/view?usp=drive_link
프로젝트 압축 링크입니다.
권한 허용했습니다.
0
보내주신 코드 확인했습니다!
먼저 현재 MemberServiceTest 코드를 보시면 이미 에러가 발생하고 있는 것을 보실 수 있습니다!
@RunWith 애노테이션을 불러올 수 없는 것 같습니다. 그 이유는 @RunWith 애노테이션이 테스트 프레임워크인 Junit 4에서 지원하는 애노테이션이기 때문입니다.

스프링 부트 3버전을 사용하고 계신다면 Junit 5를 기본적으로 사용하고 계시기 때문에 해당 기능을 사용하기 위해서는 따로 설정을 해주셔야 합니다!
그래서 프로젝트 환경설정 챕터의 강의자료를 보시면 다음과 같은 설명이 있습니다 🙂

그래서 아래의 build.gradle과 같이 Junit4를 사용하기 위한 설정을 추가한 후 MemberServiceTest를 가서 실행해보시면!
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.8'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'jpabook'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-devtools'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//JUnit4 추가
testImplementation("org.junit.vintage:junit-vintage-engine") {
exclude group: "org.hamcrest", module: "hamcrest-core"
}
}
tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-base:latest'
}
tasks.named('test') {
useJUnitPlatform()
}
강의와 동일하게 테스트 코드를 작성하실 수 있습니다!
1
앗 근데 제가 했을때는 @Runwith 쪽에 문제라고 뜨지는 않긴 한데...
올려주신 코드 넣고 다시 돌려봤는데 회원가입() 부분에서 아래와 같이 뜨면서 오류가 나는데 혹시 다시 알려주실수 있으실까요.... 처음하는거라 익숙하지도 않고 오류 코드 해석하는것도 어렵네요...
java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@1a2e563e testClass = jpabook.jpashop.service.MemberServiceTest, locations = [], classes = [jpabook.jpashop.JpashopApplication], contextInitializerClasses = [], activeProfiles = [], propertySourceLocations = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@4b741d6d, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@7674f035, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@17f62e33, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5149d738, org.springframework.boot.test.context.SpringBootTestAnnotation@eedd3ea0], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
0
제 환경에서는 해당 에러가 발생하지 않는 것 같습니다. 혹시 예외 트레이스를 보면
Caused by: ~
해당 부분까지 전체 예외를 보여주실 수 있을까요?
추가로
h2 DB가 실행 중 인지 확인해주시고,
기존 프로젝트가 안될 때 - 프로젝트 초기화(클릭)을 진행해보시고
인텔리J 자바 JDK 버전 설정, 클래스 파일 인식 문제(클릭) 도 진행해보시길 권해드립니다!
sdk 설정 오류
0
53
2
오탈자 - @Transactional
0
56
1
src/test/resources 테스트 경로 문제
0
50
1
상품 등록후 H2 db 출력 순서 바꿀 수 있나요?
0
64
1
MemberRepositoryTest 실행오류
0
81
1
boot 4.x >>> trasasction rolled back log & p6spy(영한님, 수업 자료 업데이트 해주시면 감사하겠습니다!!)
1
183
2
강의 마지막 QueryDSL 사용 부분 질문있습니다
1
142
2
클라이언트에서 isbn과 author 수정 요청을 한 경우에 대해 질문드립니다.
0
51
1
도메인 모델 패턴 vs 트랜잭션 스크립트 패턴
0
71
1
기본 생성자
0
60
1
h2 DB 연결시 jdbc url 변경 이유가 궁금합니다.
0
103
1
멤버서비스테스트 부분에서 막힙니다.
0
165
4
실무에서도 EntityManager를 이용해서 많이 작업하는 편일까요?
0
116
1
초반에 h2 다운로드 과정 꼭 필요한가요?
0
120
2
자신 필드에도 get으로 접근하는 이유가 있을까요?
0
114
1
24분 27초 연관관계 편의 메서드 위치
0
113
1
단건 주문만 가능하게 한건 의도한 부분이신가요?
0
109
2
빌드 툴, Gradle
0
59
1
h2연결은 된 것 같은데 엔티티 테이블까지 작성 후 확인해보아도 테이블이 안보입니다
0
77
2
Repository에서 EntityManager 주입 방식 차이
0
90
1
롬복과 사용자 정의 setter 메서드
0
72
1
주문 목록 조회 fetch join 질문드립니다
0
82
1
dirty checking 질문드립니다.
0
83
1
동시성 관련 질문입니다
0
75
1






권한 을 허용해주십쇼!!