Created
March 4, 2018 17:55
-
-
Save vamsitallapudi/6f0a2875f592b16c5d595bca94a2d397 to your computer and use it in GitHub Desktop.
Android Testing Example - Simple Unit test creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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