Based off of https://github.com/robolectric/deckard-gradle
Make sure to enable Unit Testing in Android Studio. Then right click and run Unit1ExerciseTests.java
Tests if main Activity exists.
Tests if a TextView called with the id "text" has been added to a layout.
Tests if the TextView with the id "text" contains the string, "Help, I'm stuck in an Android Factory!"
Tests if an ImageView with the id "image" has been added to a layout.
Tests if an ImageView with the id "image" uses the drawable "hello_green.png".
Tests if EditTextAcitivity class exists.
Tests if layout for EditTextActivity exists.
Tests if TextView R.id.counter
displays the number of times a button has been clicked exists in main activity.
Tests if Button with click!
text is created after the TextView R.id.counter
. Every time R.id.button
is clicked, R.id.counter
should be incremented by 1.
Tests if the Activity saves and restores the state of the counter in OnSaveInstanceState
and onRestoreInstanceState
.
Tests if SocialActivity class exists.
Tests if a layout exists for the SocialActivity Class.
Tests if SocialActivity responds to the ACTION_SEND
Intent.
Tests if the Main Activity has a button for social sharing with id R.id.social
.
Write your own unit tests, and then implement features to pass those tests. Take a look at Robolectric for documentation of the testing framework. Feel free to take a look at some of our own tests in unit-1-exercises.