====== TestFixtures ====== * [[https://docs.gradle.org/current/userguide/java_testing.html#sec:java_test_fixtures|Testing in Java & JVM projects#TestFixtures]] * Multiple Module 프로젝트에서 상위 모듈의 테스트에서 만든 클래스나 리소스를 하위 모듈에서는 원칙적으로 사용할 수 없다. * 이를 극복하기 위해 상위 모듈에 ''testFixtures''라는 소스 디렉토리를 추가하고 해당 디렉토리를 하위 모듈에서 테스트로 의존성을 걸게 하면 상위 모듈, 하위 모듈 모두에서 사용가능해진다. ===== 상위 모듈 설정 ===== * 설정 후 ''module/src/testFixtures/{java/resources}'' 소스 루트에 테스트 픽스처 소스 코드나 리소스를 둔다. plugins { // which produces test fixtures id 'java-test-fixtures' } // 상위 모듈 의존성 dependencies { testImplementation 'junit:junit:4.13' // testFixtures 에 어떤 의존성이 필요할 경우 추가 // 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(":상위모듈"))) }