Spring Boot Test H2 In Memory ์ค์ ํ๊ธฐ
2023. 2. 28. 22:02ใ๐พBackEnd/๐ฑ Spring
๋ฐ์ํ
ํ ์คํธ๋ฅผ ํ๊ธฐ ์ํด์ local์ DB๋ฅผ ์คํ์ ํด์ผ๋๋๋ฐ ์ด๊ฒ์ In Memory๋ฅผ ํตํ์ฌ local์ ์คํํ์ง ์๊ณ ํ ์คํธ๊ฐ ๊ฐ๋ฅํ๋ค.
์ฐ์ ์ค์ ์ ์ํด์ src/test ์์ resources ๋๋ ํ ๋ฆฌ๋ฅผ ์ถ๊ฐํด ์ฃผ๊ณ application.yml๋ ์ถ๊ฐํด์ค๋ค.
์ด๋ ๊ฒ ์ถ๊ฐ๋ application.yml์ test์ main directory ํ์์ ์๋ application.yml๋ณด๋ค ์ฐ์ ๊ถ์ ๊ฐ์ง๊ฒ ๋๋ค.
spring:
datasource:
url: jdbc:h2:mem:test
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
format_sql: true
logging:
level:
org.hibernate.SQL: debug
application.yml์ ๋ค์๊ณผ ๊ฐ์ด ์์ฑํ๋ค. ์ด์ H2 console๋ก DB๋ฅผ ๋์ฐ๋ ์ผ ์์ด In memory DB๋ก ๋ฐ๋ก ํ ์คํธ๋ฅผ ํ ์ ์๋ค.
๋ฐ์ํ
'๐พBackEnd > ๐ฑ Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ RFC ] ๊ณต์ ๋ฌธ์๋ฅผ ํตํ์ฌ Delete์ Status๋ฅผ ์์๋ณด์ (0) | 2023.03.12 |
---|---|
[ Jackson ] Jackson mock ํ ์คํธ ์ญ์ง๋ ฌํ ์ค๋ฅ (0) | 2023.03.11 |
[SpringBoot] Slack์ผ๋ก ์๋ฆผ ๋ณด๋ด๊ธฐ (0) | 2023.02.15 |
JPA ์์์ฑ ์ปจํ ์คํธ (0) | 2023.02.04 |
SPRING ์ฟผ๋ฆฌ๋ฅผ 2๊ฐ๋ฅผ 1๊ฐ๋ก ์ค์ด๋ Merge ์ด์ฉํ๊ธฐ (0) | 2022.11.26 |