Кинжал не может найти DaggerModule в тестовой папке в другом AndroidModule - PullRequest
0 голосов
/ 04 октября 2019

Для тестирования я создал копию модуля репозитория в тестовой папке. Если мой TestComponent ссылается на этот модуль, я получаю ошибку

cannot find symbol: class TestRepositoryModule

Если я ссылаюсь на оригинальный модуль dagerModule в том же модуле Android, что и тестовые компиляции. Как получить правильную ссылку на тестовый модуль?

TestAppComponent.java:6: error: cannot find symbol
symbol: class TestRepositoryModule

структура проекта

data
--main
----RepositoryModule
--test
----TestRepositoryModule
app
--main
----di
------AppComponent
--test
----di
------TestAppComponent

Тестовый компонент приложения

@Singleton
@Component(modules = [
  AppModule::class,
  AndroidSupportInjectionModule::class,
  TestRepositoryModule::class

])
interface TestAppComponent : AndroidInjector<TestApplication> {

  @Component.Builder
  abstract class Builder : AndroidInjector.Builder<TestApplication>()

}

в обоих файлах Gradle, у меня есть следующие зависимости

      daggerCompiler: "com.google.dagger:dagger-compiler:${daggerVersion}",
      daggerSupportCompiler: "com.google.dagger:dagger-android-processor:${daggerVersion}",
junit: "junit:junit:${jUnitVersion}", androidxTest: "androidx.test:runner:${androidxTestVersion}",
      espressoCore: "androidx.test.espresso:espresso-core:${espressoVersion}",
      mockitoCore: "org.mockito:mockito-core:${mockitoVersion}",
      mockitoInline: "org.mockito:mockito-inline:${mockitoInlineVersion}",
      mockitoKotlin: "com.nhaarman.mockitokotlin2:mockito-kotlin:${mockitoKotlinVersion}",
      robolectric: "org.robolectric:robolectric:${robolectricVersion}"
      androidTestImplementation presentationTestDependencies.androidxTest
      androidTestImplementation presentationTestDependencies.espressoCore

      testImplementation ext.junit
      testImplementation ext.mockitoCore
      testImplementation ext.mockitoInline
      testImplementation ext.mockitoKotlin
      testImplementation ext.robolectric
      kaptAndroidTest ext.daggerCompiler
      kaptTest ext.daggerCompiler
      kaptTest ext.daggerSupportCompiler
...