本地单元测试Android

时间:2016-08-10 09:05:52

标签: android unit-testing android-instrumentation

有人可以告诉我一个有效的代码来对这段代码进行单元测试吗?

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);
}

请告诉我使用本地单元测试(如果可能的话,使用机电测试等)和仪器测试。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout      xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

<Button
    android:id="@+id/login"
    android:text="Login"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</LinearLayout>

显然,测试会检查是否有创建了 Login 文本的按钮。

1 个答案:

答案 0 :(得分:0)

使用Expresso

text-align: right

以下是有关如何使用Expresso进行设置的details