Skip to content

Instantly share code, notes, and snippets.

@leechunhoe
Last active April 25, 2019 07:14
Show Gist options
  • Save leechunhoe/28fd3303551be7f55712e2d3725f51ca to your computer and use it in GitHub Desktop.
Save leechunhoe/28fd3303551be7f55712e2d3725f51ca to your computer and use it in GitHub Desktop.
Template of view model unit test with Kotlin (androidTest)
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.myapp.MyActivity
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class MyViewModelTest {
@Rule @JvmField
var testRule = ActivityTestRule(MyActivity::class.java)
private lateinit var myViewModel: MyViewModel
@Before
fun setup() {
myViewModel = MyViewModel(testRule.activity.application)
}
@Test
fun doWhatevetTest() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment