title: How to inject a mocked ViewModel in a RoboElectric test using Koin
body: <p>I'm pretty new in Android development and currently, I'm testing a basic activity with Roboelectric and Koin.</p>
  
  <p>Code:</p>
  
  <pre><code>class SplashActivity : AppCompatActivity() {
      private val viewModel: LoginViewModel by viewModel()
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_splash)
  
          Stetho.initializeWithDefaults(this)
  
          val user = viewModel.getPersistedUser()
  
          if (user != null) {
              viewModel.setUser(user)
              startActivity(HomeActivity.getStartIntent(this))
          } else {
              startActivity(LoginActivity.getStartIntent(this))
          }
      }
  }
  
  val appModule = module(override = true) {
      ...
  
      viewModel&lt;LoginViewModel&gt;()
  }
  </code></pre>
  
  <p>Now all I want to do in the test is to inject a mocked version of the viewModel to simulate the response of the method getPersistedUser.</p>
  
  <p>How can I do that with Roboelectric and Koin?</p>