-
Notifications
You must be signed in to change notification settings - Fork 4
통합 테스트 환경 구축 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Testcontainer for gradlereference
example PR
// build.gradle.kts
dependencies {
...
runtimeOnly("com.mysql:mysql-connector-j")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:mysql")
} package com.group4.ticketingservice
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.TestConfiguration
import org.springframework.boot.testcontainers.service.connection.ServiceConnection
import org.springframework.context.annotation.Bean
import org.testcontainers.containers.MySQLContainer
// @SpringBootTest()
@TestConfiguration(proxyBeanMethods = false)
class MySQLContainerTest {
@Bean
@ServiceConnection
fun mysqlContainer(): MySQLContainer<*> {
return MySQLContainer("mysql:latest")
}
@Test
fun printMysqlVersion() {
val mysqlContainer = mysqlContainer()
mysqlContainer.start()
val mysqlVersion = mysqlContainer.execInContainer("mysql", "--version")
println("MySQL version: $mysqlVersion")
}
} $ ./gradlew test
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32d2b99ba756 mysql:latest "docker-entrypoint.s…" 34 seconds ago Up 33 seconds 33060/tcp, 0.0.0.0:32771->3306/tcp, :::32771->3306/tcp objective_gates
a6ed58c36aa8 testcontainers/ryuk:0.4.0 "/bin/ryuk" 34 seconds ago Up 33 seconds 0.0.0.0:32770->8080/tcp, :::32770->8080/tcp testcontainers-ryuk-6ce2605b-946a-476a-8bdc-901c7294246a
# After test
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Testcontainer for docker-composereference
에러 해결 코드 예시
Testcontainer for git actionsReference Tech Stack
Potential Problem
|
Merged
Merged
2 tasks
경험 공유상황
해당 이슈를 해결 하는 과정에서 여러 글과 공식 문서를 읽었지만 "Kotlin"으로 설명해놓은 최신 (또는 다양한) 예시는 없었다. 따라서 계속적인 검색, GPT 등 여러 방법을 썼으나
위와 같은 문제점에 마주치고, 2일간 (하루에 4시간씩) 체계적 문제 해결에 실패. (계속 뭔지도 모르고 복붙만 진행) 해결방법git repo에 내가 원하는 기술을 검색하고 최신순 정렬을해서, "가장 생생한 예시"를 확인하고 문제 해결 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
testcontainers를 이용한 통합 테스트를 위한 환경 구축
To do
integration test for git push hookdocker-compose + Testcontainer + git actionsect. testcontainer setup study
testcontainer
5. use Docker-composeTest Checklist
The text was updated successfully, but these errors were encountered: