Skip to content

Commit

Permalink
#101- 메인 스프링 부트 테스트에서 발생하는 문제 해결
Browse files Browse the repository at this point in the history
DB 접근 정보가 환경변수 문법으로 치환되었는데
`@SpringBootTest`가 이를 그대로 읽으면서
올바른 jdbc url 포맷이 아니므로 실패를 유발함

이에 적당히 인메모리 테스트 db인 h2 경로를
새로 만든 테스트 전용 `test` 프로파일에 지정해주고,
테스트 실행 시 이 프로파일을 바라보게 하여
문제 해결
  • Loading branch information
GGHDMS committed May 27, 2023
1 parent 486433a commit 4b89dc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions project-board/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ spring:
token-uri: https://kauth.kakao.com/oauth/token
user-info-uri: https://kapi.kakao.com/v2/user/me
user-name-attribute: id # username 식별자를 id 로 하겠다

---

spring:
config.activate.on-profile: test
datasource.url: jdbc:h2:mem:testdb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
@SpringBootTest
class ProjectBoardApplicationTests {

Expand Down

0 comments on commit 4b89dc1

Please sign in to comment.