title: Hilt - Unit Tests
body: <p>I would like to start using Hilt in my test.</p>
  <p>Gradle:</p>
  <pre><code>android{
  ...
  defaultConfig{
  ...
  testInstrumentationRunner &quot;com.rachapps.myfitapp.HiltTestRunner&quot;
  }
  androidTestImplementation 'com.google.dagger:hilt-android-testing:2.28-alpha'
  kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.38.1'
  </code></pre>
  <p>...</p>
  <pre><code>class HiltTestRunner : AndroidJUnitRunner() {
  
      override fun newApplication(
          cl: ClassLoader?,
          className: String?,
          context: Context?
      ): Application {
          return super.newApplication(cl, HiltTestApplication::class.java.name, context)
      }
  }
  </code></pre>
  <p>test class:</p>
  <pre><code>@SmallTest
  @HiltAndroidTest
  class BodyPartDaoTest {
  
      @get : Rule
      var hiltRule = HiltAndroidRule(this)
  
      @get : Rule
      var instantTaskExecutorRule = InstantTaskExecutorRule()
  
      @Inject
      @Named(&quot;test_db&quot;)
      lateinit var database: MyFitDatabase
  
      private lateinit var bodyPartDao: BodyPartDao
      private lateinit var exerciseDao: ExerciseDao
  
      @Before
      fun setup() {
          hiltRule.inject()
          bodyPartDao = database.bodyPartDao()
          exerciseDao = database.exerciseDao()
      }
  ...
  }
  </code></pre>
  <p>Module:</p>
  <pre><code>@Module
  @InstallIn(SingletonComponent::class)
  object TestAppModule {
      @Provides
      @Named(&quot;test_db&quot;)
      fun provideInMemoryDb(@ApplicationContext context: Context) : MyFitDatabase {
          return Room.inMemoryDatabaseBuilder(context, MyFitDatabase::class.java).allowMainThreadQueries().build()
      }
  }
  </code></pre>
  <p>While executing test I receive an error:</p>
  <pre><code>C:\Radek\Android\MyFitApp\app\build\generated\source\kapt\debugAndroidTest\com\rachapps\myfitapp\data\dao\BodyPartDaoTest_TestComponentDataSupplier.java:14: error: BodyPartDaoTest_TestComponentDataSupplier is not abstract and does not override abstract method get() in TestComponentDataSupplier
  public final class BodyPartDaoTest_TestComponentDataSupplier extends TestComponentDataSupplier {
               ^
  C:\Radek\Android\MyFitApp\app\build\generated\source\kapt\debugAndroidTest\com\rachapps\myfitapp\data\dao\BodyPartDaoTest_TestComponentDataSupplier.java:15: error: get() in BodyPartDaoTest_TestComponentDataSupplier cannot override get() in TestComponentDataSupplier
    protected TestComponentData get() {
                                ^
    return type TestComponentData is not compatible with Map&lt;Class&lt;?&gt;,TestComponentData&gt;
  2 errors
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
  </code></pre>