티스토리 뷰

문제점

  • Spock 테스트 시 Repository를 주입받지 못하는 오류가 발생

해결

  • build.gradle 에서 spring 3.2.4 버전을 기준으로 spock 버전을 재설정하여 해결
testImplementation 'org.spockframework:spock-core:2.4-M1-groovy-4.0'
testImplementation 'org.spockframework:spock-spring:2.4-M1-groovy-4.0'

mariadb testcontainers

// testcontainers
testImplementation 'org.testcontainers:spock:1.19.7'
testImplementation 'org.testcontainers:mariadb:1.19.7'

build.gradle 전체

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.4'
    id 'io.spring.dependency-management' version '1.1.4'
    id 'groovy'
}

group = 'com.valletta'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '21'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

bootJar {
    archiveFileName = 'app.jar'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    testImplementation 'org.spockframework:spock-core:2.4-M1-groovy-4.0'
    testImplementation 'org.spockframework:spock-spring:2.4-M1-groovy-4.0'

    // testcontainers
    testImplementation 'org.testcontainers:spock:1.19.7'
    testImplementation 'org.testcontainers:mariadb:1.19.7'
}

tasks.named('test') {
    useJUnitPlatform()
}
댓글
Total
최근에 올라온 글