Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vamsitallapudi
Created March 4, 2018 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vamsitallapudi/6f0a2875f592b16c5d595bca94a2d397 to your computer and use it in GitHub Desktop.
Save vamsitallapudi/6f0a2875f592b16c5d595bca94a2d397 to your computer and use it in GitHub Desktop.
Android Testing Example - Simple Unit test creation
package com.coderefer.androidtestingexamples
import kotlinx.android.synthetic.main.activity_main.*
import org.junit.Test
import org.junit.Assert.*
import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
/**
* Simple local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(RobolectricTestRunner::class)
class SimpleUnitTest {
@Test
fun buttonText(){
var activity = Robolectric.setupActivity(MainActivity::class.java)
activity.button.performClick()
assertEquals(activity.textView.text,"hello")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment