title: Android Kotlin Testing. lateinit property _db has not been initialized
body: <p>My code:</p>
  
  <pre><code>abstract class DbTest {
  
      @Rule
      @JvmField
      val countingTaskExecutorRule = CountingTaskExecutorRule()
  
      private lateinit var _db : AppDatabase
  
      val db: AppDatabase
          get() = _db
  
      @Before
      fun initDb() {
          _db = Room.inMemoryDatabaseBuilder(
                  InstrumentationRegistry.getInstrumentation().context,
                  AppDatabase::class.java
          ).build()
      }
  
      @After
      fun closeDb() {
          countingTaskExecutorRule.drainTasks(10, TimeUnit.SECONDS)
          _db.close()
      }
  }
  
  @RunWith(AndroidJUnit4::class)
  class PlantDaoTest : DbTest() {
  
      @get:Rule
      var instantTaskExecutorRule = InstantTaskExecutorRule()
  
      @Test
      fun insert_one_plant() {
          val plant = Plant(plantId = 1, name="Plant1")
          db.plantDao.insertOnePlant(plant)
  
          val retrievedPlant = db.plantDao.getPlant(1)
          assert(plant.name==retrievedPlant.name)
  
      }
  }
  </code></pre>
  
  <p>When I run PlantDaoTest, I see this error:
  kotlin.UninitializedPropertyAccessException: lateinit property _db has not been initialized</p>
  
  <p>I really don't know how to fix this. Please help</p>