사용자 도구

사이트 도구


gradle:testfixtures

문서의 이전 판입니다!


TestFixtures

  • Multiple Module 프로젝트에서 상위 모듈의 테스트에서 만든 클래스나 리소스를 하위 모듈에서는 원칙적으로 사용할 수 없다.
  • 이를 극복하기 위해 상위 모듈에 testFixtures라는 소스 디렉토리를 추가하고 해당 디렉토리를 하위 모듈에서 테스트로 의존성을 걸게 하면 상위 모듈, 하위 모듈 모두에서 사용가능해진다.

상위 모듈 설정

// 전역 설정
plugins {
    // which produces test fixtures
    id 'java-test-fixtures'
}
 
// 상위 모듈 의존성
dependencies {
    testImplementation 'junit:junit:4.13'
 
    // API dependencies are visible to consumers when building
    testFixturesApi 'org.apache.commons:commons-lang3:3.9'
 
    // Implementation dependencies are not leaked to consumers when building
    testFixturesImplementation 'org.apache.commons:commons-text:1.6'
}

하위 모듈에서 사용

dependencies {
    implementation(project(":상위모듈"))
 
    testImplementation 'junit:junit:4.13'
    testImplementation(testFixtures(project(":상위모듈")))
}
gradle/testfixtures.1649915875.txt.gz · 마지막으로 수정됨: 2022/04/14 14:57 저자 kwon37xi