Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. Tests run inside the JVM on your workstation in
seconds. Robolectric help to make more efficient unit test.
Here are example how to test android code using robolectric.
First you have to add dependencies in app.gradle file,just like that as your latest robolectric version
testImplementation "org.robolectric:robolectric:3.3.2"
Now you have to write code in test file in unit testing section not in ui testing,
Then, Now you have add some kotlin code,
In Second kotlin code, which is pass some value from on activity one activity to another activity,
Rest of the layout file as your requirement, but you want to details, please see below git hub link
Run as test runner,
the you have to see, test will be passed.
Download and fork git hub code: https://github.com/dharmakshetri/RoboelectricKotlinExample
#HappyCoding #Kotlin #Robolectric #Android