Skip to content

Instantly share code, notes, and snippets.

@trietbui85
Last active July 29, 2020 13:41
Show Gist options
  • Save trietbui85/2a58a56fb763bd46ebd8486bd6866483 to your computer and use it in GitHub Desktop.
Save trietbui85/2a58a56fb763bd46ebd8486bd6866483 to your computer and use it in GitHub Desktop.
Unit test Android custom view with AndroidX Test and Robolectric
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="10dp"
android:background="#50000000">
<Button
android:layout_width="@dimen/button_size"
android:layout_height="60dp"
android:id="@+id/buttonSubtract"
android:textSize="@dimen/count_text_size"
android:text="@string/button_subtract" />
<TextView
android:layout_width="100dp"
android:layout_height="50dp"
android:id="@+id/textView"
android:text="0"
android:gravity="center|bottom"
android:padding="5dp"
android:textSize="@dimen/count_text_size"
android:textStyle="bold"
android:textColor="@android:color/black" />
<Button
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/buttonAdd"
android:textSize="@dimen/count_text_size"
android:text="@string/button_add" />
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment